feat(onboarding): add first-run membership activation
This commit is contained in:
+45
-1
@@ -438,7 +438,10 @@ class AppConfigTests(TempDirMixin, unittest.TestCase):
|
||||
ai = appconfig.ai_config(config)
|
||||
self.assertEqual("cmhub", ai["backend"])
|
||||
self.assertEqual("cmhub", appconfig.ai_backend(config))
|
||||
self.assertEqual("", appconfig.cmhub_config(config)["base_url"])
|
||||
self.assertEqual(
|
||||
appconfig.DEFAULT_CMHUB_BASE_URL,
|
||||
appconfig.cmhub_config(config)["base_url"],
|
||||
)
|
||||
self.assertEqual(
|
||||
appconfig.CMHUB_CONNECT_TIMEOUT_DEFAULT,
|
||||
appconfig.cmhub_config(config)["connect_timeout"],
|
||||
@@ -480,6 +483,47 @@ class AppConfigTests(TempDirMixin, unittest.TestCase):
|
||||
|
||||
self.assert_removed(temp_dir)
|
||||
|
||||
def test_default_gateway_url_and_first_use_state_preserve_existing_config(self):
|
||||
with self.make_temp_dir() as temp_dir:
|
||||
config_path = os.path.join(temp_dir, "config.json")
|
||||
with open(config_path, "w", encoding="utf-8") as fh:
|
||||
json.dump({"ai": {"cmhub": {"base_url": ""}}}, fh)
|
||||
|
||||
migrated = appconfig.load_config(config_path)
|
||||
|
||||
self.assertEqual(
|
||||
appconfig.DEFAULT_CMHUB_BASE_URL,
|
||||
appconfig.cmhub_config(migrated)["base_url"],
|
||||
)
|
||||
self.assertEqual("", appconfig.first_use_guide_state(migrated))
|
||||
|
||||
migrated["ai"]["cmhub"]["base_url"] = "https://gateway.example.com/api/v1"
|
||||
saved = appconfig.save_config(migrated, path=config_path)
|
||||
self.assertEqual(
|
||||
"https://gateway.example.com",
|
||||
appconfig.cmhub_config(saved)["base_url"],
|
||||
)
|
||||
|
||||
pending = appconfig.save_first_use_guide_state(
|
||||
"pending",
|
||||
path=config_path,
|
||||
)
|
||||
self.assertEqual("pending", appconfig.first_use_guide_state(pending))
|
||||
self.assertEqual(
|
||||
"https://gateway.example.com",
|
||||
appconfig.cmhub_config(pending)["base_url"],
|
||||
)
|
||||
|
||||
dismissed = appconfig.save_first_use_guide_state(
|
||||
"dismissed",
|
||||
path=config_path,
|
||||
)
|
||||
self.assertEqual("dismissed", appconfig.first_use_guide_state(dismissed))
|
||||
with self.assertRaises(appconfig.ConfigError):
|
||||
appconfig.save_first_use_guide_state("unknown", path=config_path)
|
||||
|
||||
self.assert_removed(temp_dir)
|
||||
|
||||
def test_subscription_notice_id_persists_without_credentials(self):
|
||||
with self.make_temp_dir() as temp_dir:
|
||||
config_path = os.path.join(temp_dir, "config.json")
|
||||
|
||||
Reference in New Issue
Block a user