fix: seed outfit factory config
This commit is contained in:
@@ -27,6 +27,10 @@ class _Base(unittest.TestCase):
|
||||
(self.app / "config" / "templates.json").write_text("{}", encoding="utf-8")
|
||||
(self.app / "config" / "ai_models.json").write_text(
|
||||
json.dumps({"models": [{"name": "factory"}]}), encoding="utf-8")
|
||||
(self.app / "config" / "outfit_prompt.txt").write_text(
|
||||
"factory outfit", encoding="utf-8")
|
||||
(self.app / "config" / "title_prompt.txt").write_text(
|
||||
"factory title", encoding="utf-8")
|
||||
self.data = self.tmp / "data"
|
||||
self._prev = os.environ.get("CMBOT_DATA_DIR")
|
||||
os.environ["CMBOT_DATA_DIR"] = str(self.data)
|
||||
@@ -51,17 +55,31 @@ class TestSeed(_Base):
|
||||
self.assertTrue((self.data / "config" / "app_config.json").exists())
|
||||
self.assertTrue((self.data / "config" / "templates.json").exists())
|
||||
self.assertTrue((self.data / "config" / "ai_models.json").exists())
|
||||
self.assertTrue((self.data / "config" / "outfit_prompt.txt").exists())
|
||||
self.assertTrue((self.data / "config" / "title_prompt.txt").exists())
|
||||
|
||||
def test_seed_does_not_overwrite(self):
|
||||
(self.data / "config").mkdir(parents=True)
|
||||
(self.data / "config" / "app_config.json").write_text('{"update_source":"USER"}', encoding="utf-8")
|
||||
(self.data / "config" / "ai_models.json").write_text(
|
||||
json.dumps({"models": [{"name": "user"}]}), encoding="utf-8")
|
||||
(self.data / "config" / "outfit_prompt.txt").write_text(
|
||||
"user outfit", encoding="utf-8")
|
||||
(self.data / "config" / "title_prompt.txt").write_text(
|
||||
"user title", encoding="utf-8")
|
||||
launcher.seed_defaults(self.app, self.data)
|
||||
kept = json.loads((self.data / "config" / "app_config.json").read_text(encoding="utf-8"))
|
||||
self.assertEqual(kept["update_source"], "USER")
|
||||
kept_models = json.loads((self.data / "config" / "ai_models.json").read_text(encoding="utf-8"))
|
||||
self.assertEqual(kept_models["models"][0]["name"], "user")
|
||||
self.assertEqual(
|
||||
(self.data / "config" / "outfit_prompt.txt").read_text(encoding="utf-8"),
|
||||
"user outfit",
|
||||
)
|
||||
self.assertEqual(
|
||||
(self.data / "config" / "title_prompt.txt").read_text(encoding="utf-8"),
|
||||
"user title",
|
||||
)
|
||||
|
||||
|
||||
class TestRun(_Base):
|
||||
|
||||
Reference in New Issue
Block a user