Skip to content

Commit 1ccc313

Browse files
committed
fix: correct key type hint, isolate all catalog tests from env
- Fix key parameter type to str | None (defaults to None) - Add HOME/USERPROFILE monkeypatch and clear SPECKIT_INTEGRATION_CATALOG_URL in all TestCatalogFetch tests for full environment isolation
1 parent 88cde3c commit 1ccc313

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

src/specify_cli/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2221,7 +2221,7 @@ def integration_switch(
22212221

22222222
@integration_app.command("upgrade")
22232223
def integration_upgrade(
2224-
key: str = typer.Argument(None, help="Integration key to upgrade (default: current integration)"),
2224+
key: str | None = typer.Argument(None, help="Integration key to upgrade (default: current integration)"),
22252225
force: bool = typer.Option(False, "--force", help="Force upgrade even if files are modified"),
22262226
script: str | None = typer.Option(None, "--script", help="Script type: sh or ps (default: from init-options.json or platform default)"),
22272227
integration_options: str | None = typer.Option(None, "--integration-options", help="Options for the integration"),

tests/integrations/test_integration_catalog.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ class TestActiveCatalogs:
7676
def test_defaults_when_no_config(self, tmp_path, monkeypatch):
7777
monkeypatch.setenv("HOME", str(tmp_path))
7878
monkeypatch.setenv("USERPROFILE", str(tmp_path))
79+
monkeypatch.delenv("SPECKIT_INTEGRATION_CATALOG_URL", raising=False)
7980
(tmp_path / ".specify").mkdir()
8081
cat = IntegrationCatalog(tmp_path)
8182
active = cat.get_active_catalogs()
@@ -153,6 +154,9 @@ def fake_urlopen(url, timeout=10):
153154
monkeypatch.setattr(urllib.request, "urlopen", fake_urlopen)
154155

155156
def test_fetch_and_search_all(self, tmp_path, monkeypatch):
157+
monkeypatch.setenv("HOME", str(tmp_path))
158+
monkeypatch.setenv("USERPROFILE", str(tmp_path))
159+
monkeypatch.delenv("SPECKIT_INTEGRATION_CATALOG_URL", raising=False)
156160
(tmp_path / ".specify").mkdir()
157161
cat = IntegrationCatalog(tmp_path)
158162

@@ -178,6 +182,9 @@ def test_fetch_and_search_all(self, tmp_path, monkeypatch):
178182
assert "acme-coder" in ids
179183

180184
def test_search_by_tag(self, tmp_path, monkeypatch):
185+
monkeypatch.setenv("HOME", str(tmp_path))
186+
monkeypatch.setenv("USERPROFILE", str(tmp_path))
187+
monkeypatch.delenv("SPECKIT_INTEGRATION_CATALOG_URL", raising=False)
181188
(tmp_path / ".specify").mkdir()
182189
cat = IntegrationCatalog(tmp_path)
183190

@@ -195,6 +202,9 @@ def test_search_by_tag(self, tmp_path, monkeypatch):
195202
assert all("cli" in r.get("tags", []) for r in results)
196203

197204
def test_search_by_query(self, tmp_path, monkeypatch):
205+
monkeypatch.setenv("HOME", str(tmp_path))
206+
monkeypatch.setenv("USERPROFILE", str(tmp_path))
207+
monkeypatch.delenv("SPECKIT_INTEGRATION_CATALOG_URL", raising=False)
198208
(tmp_path / ".specify").mkdir()
199209
cat = IntegrationCatalog(tmp_path)
200210

@@ -213,6 +223,9 @@ def test_search_by_query(self, tmp_path, monkeypatch):
213223
assert results[0]["id"] == "claude"
214224

215225
def test_get_integration_info(self, tmp_path, monkeypatch):
226+
monkeypatch.setenv("HOME", str(tmp_path))
227+
monkeypatch.setenv("USERPROFILE", str(tmp_path))
228+
monkeypatch.delenv("SPECKIT_INTEGRATION_CATALOG_URL", raising=False)
216229
(tmp_path / ".specify").mkdir()
217230
cat = IntegrationCatalog(tmp_path)
218231

@@ -232,6 +245,9 @@ def test_get_integration_info(self, tmp_path, monkeypatch):
232245
assert cat.get_integration_info("nonexistent") is None
233246

234247
def test_invalid_catalog_format(self, tmp_path, monkeypatch):
248+
monkeypatch.setenv("HOME", str(tmp_path))
249+
monkeypatch.setenv("USERPROFILE", str(tmp_path))
250+
monkeypatch.delenv("SPECKIT_INTEGRATION_CATALOG_URL", raising=False)
235251
(tmp_path / ".specify").mkdir()
236252
cat = IntegrationCatalog(tmp_path)
237253

0 commit comments

Comments
 (0)