Navegador

fix: CI/CD tests fail in GitHub Actions due to leaked env vars Tests that parse JSON from CICDReporter output now clear GITHUB_ACTIONS and CI env vars to prevent GH Actions annotations from corrupting the JSON buffer. Also suppress ResourceWarning from mock objects in pytest. Bumps to 0.7.1.

lmata 2026-03-23 13:49 trunk
Commit a3b55eec36382d8bdf82dea5d4676593acb81823750c8013ea9f33e6da013c2b
--- navegador/__init__.py
+++ navegador/__init__.py
@@ -1,10 +1,10 @@
11
"""
22
Navegador — AST + knowledge graph context engine for AI coding agents.
33
"""
44
5
-__version__ = "0.7.0"
5
+__version__ = "0.7.1"
66
__author__ = "CONFLICT LLC"
77
88
from navegador.sdk import Navegador
99
1010
__all__ = ["Navegador"]
1111
--- navegador/__init__.py
+++ navegador/__init__.py
@@ -1,10 +1,10 @@
1 """
2 Navegador — AST + knowledge graph context engine for AI coding agents.
3 """
4
5 __version__ = "0.7.0"
6 __author__ = "CONFLICT LLC"
7
8 from navegador.sdk import Navegador
9
10 __all__ = ["Navegador"]
11
--- navegador/__init__.py
+++ navegador/__init__.py
@@ -1,10 +1,10 @@
1 """
2 Navegador — AST + knowledge graph context engine for AI coding agents.
3 """
4
5 __version__ = "0.7.1"
6 __author__ = "CONFLICT LLC"
7
8 from navegador.sdk import Navegador
9
10 __all__ = ["Navegador"]
11
+4 -1
--- pyproject.toml
+++ pyproject.toml
@@ -2,11 +2,11 @@
22
requires = ["setuptools>=69.0", "wheel"]
33
build-backend = "setuptools.build_meta"
44
55
[project]
66
name = "navegador"
7
-version = "0.7.0"
7
+version = "0.7.1"
88
description = "AST + knowledge graph context engine for AI coding agents"
99
readme = "README.md"
1010
license = "MIT"
1111
requires-python = ">=3.12"
1212
authors = [
@@ -117,5 +117,8 @@
117117
118118
[tool.pytest.ini_options]
119119
testpaths = ["tests"]
120120
python_files = "test_*.py"
121121
addopts = "--cov=navegador"
122
+filterwarnings = [
123
+ "ignore::ResourceWarning",
124
+]
122125
--- pyproject.toml
+++ pyproject.toml
@@ -2,11 +2,11 @@
2 requires = ["setuptools>=69.0", "wheel"]
3 build-backend = "setuptools.build_meta"
4
5 [project]
6 name = "navegador"
7 version = "0.7.0"
8 description = "AST + knowledge graph context engine for AI coding agents"
9 readme = "README.md"
10 license = "MIT"
11 requires-python = ">=3.12"
12 authors = [
@@ -117,5 +117,8 @@
117
118 [tool.pytest.ini_options]
119 testpaths = ["tests"]
120 python_files = "test_*.py"
121 addopts = "--cov=navegador"
 
 
 
122
--- pyproject.toml
+++ pyproject.toml
@@ -2,11 +2,11 @@
2 requires = ["setuptools>=69.0", "wheel"]
3 build-backend = "setuptools.build_meta"
4
5 [project]
6 name = "navegador"
7 version = "0.7.1"
8 description = "AST + knowledge graph context engine for AI coding agents"
9 readme = "README.md"
10 license = "MIT"
11 requires-python = ">=3.12"
12 authors = [
@@ -117,5 +117,8 @@
117
118 [tool.pytest.ini_options]
119 testpaths = ["tests"]
120 python_files = "test_*.py"
121 addopts = "--cov=navegador"
122 filterwarnings = [
123 "ignore::ResourceWarning",
124 ]
125
+38 -29
--- tests/test_cicd.py
+++ tests/test_cicd.py
@@ -135,58 +135,58 @@
135135
136136
# ── CICDReporter — JSON output ────────────────────────────────────────────────
137137
138138
139139
class TestJSONOutput:
140
- def _emit_to_str(self, reporter, data=None, monkeypatch=None) -> dict:
140
+ def _emit_to_str(self, reporter, monkeypatch, data=None) -> dict:
141
+ _clear_ci_env(monkeypatch)
141142
buf = StringIO()
142
- if monkeypatch:
143
- _clear_ci_env(monkeypatch)
144143
reporter.emit(data=data, file=buf)
145144
return json.loads(buf.getvalue())
146145
147
- def test_status_success(self):
146
+ def test_status_success(self, monkeypatch):
148147
r = CICDReporter()
149
- out = self._emit_to_str(r)
148
+ out = self._emit_to_str(r, monkeypatch)
150149
assert out["status"] == "success"
151150
152
- def test_status_error(self):
151
+ def test_status_error(self, monkeypatch):
153152
r = CICDReporter()
154153
r.add_error("boom")
155
- out = self._emit_to_str(r)
154
+ out = self._emit_to_str(r, monkeypatch)
156155
assert out["status"] == "error"
157156
158
- def test_status_warning(self):
157
+ def test_status_warning(self, monkeypatch):
159158
r = CICDReporter()
160159
r.add_warning("careful")
161
- out = self._emit_to_str(r)
160
+ out = self._emit_to_str(r, monkeypatch)
162161
assert out["status"] == "warning"
163162
164
- def test_errors_list_in_payload(self):
163
+ def test_errors_list_in_payload(self, monkeypatch):
165164
r = CICDReporter()
166165
r.add_error("err1")
167166
r.add_error("err2")
168
- out = self._emit_to_str(r)
167
+ out = self._emit_to_str(r, monkeypatch)
169168
assert out["errors"] == ["err1", "err2"]
170169
171
- def test_warnings_list_in_payload(self):
170
+ def test_warnings_list_in_payload(self, monkeypatch):
172171
r = CICDReporter()
173172
r.add_warning("w1")
174
- out = self._emit_to_str(r)
173
+ out = self._emit_to_str(r, monkeypatch)
175174
assert out["warnings"] == ["w1"]
176175
177
- def test_data_included_when_provided(self):
176
+ def test_data_included_when_provided(self, monkeypatch):
178177
r = CICDReporter()
179
- out = self._emit_to_str(r, data={"files": 5, "functions": 20})
178
+ out = self._emit_to_str(r, monkeypatch, data={"files": 5, "functions": 20})
180179
assert out["data"] == {"files": 5, "functions": 20}
181180
182
- def test_data_absent_when_not_provided(self):
181
+ def test_data_absent_when_not_provided(self, monkeypatch):
183182
r = CICDReporter()
184
- out = self._emit_to_str(r)
183
+ out = self._emit_to_str(r, monkeypatch)
185184
assert "data" not in out
186185
187
- def test_output_is_valid_json(self):
186
+ def test_output_is_valid_json(self, monkeypatch):
187
+ _clear_ci_env(monkeypatch)
188188
r = CICDReporter()
189189
r.add_error("oops")
190190
r.add_warning("watch out")
191191
buf = StringIO()
192192
r.emit(data={"key": "value"}, file=buf)
@@ -332,11 +332,12 @@
332332
333333
# ── CLI: navegador ci ingest ──────────────────────────────────────────────────
334334
335335
336336
class TestCIIngestCommand:
337
- def test_success_outputs_json(self):
337
+ def test_success_outputs_json(self, monkeypatch):
338
+ _clear_ci_env(monkeypatch)
338339
runner = CliRunner()
339340
with runner.isolated_filesystem():
340341
Path("src").mkdir()
341342
with patch("navegador.cli.commands._get_store", return_value=_mock_store()), \
342343
patch("navegador.ingestion.RepoIngester") as MockRI:
@@ -345,11 +346,12 @@
345346
assert result.exit_code == 0
346347
payload = json.loads(result.output)
347348
assert payload["status"] == "success"
348349
assert payload["data"]["files"] == 5
349350
350
- def test_warning_when_no_files_ingested(self):
351
+ def test_warning_when_no_files_ingested(self, monkeypatch):
352
+ _clear_ci_env(monkeypatch)
351353
runner = CliRunner()
352354
with runner.isolated_filesystem():
353355
Path("src").mkdir()
354356
with patch("navegador.cli.commands._get_store", return_value=_mock_store()), \
355357
patch("navegador.ingestion.RepoIngester") as MockRI:
@@ -358,11 +360,12 @@
358360
assert result.exit_code == 2
359361
payload = json.loads(result.output)
360362
assert payload["status"] == "warning"
361363
assert payload["warnings"]
362364
363
- def test_error_on_ingest_exception(self):
365
+ def test_error_on_ingest_exception(self, monkeypatch):
366
+ _clear_ci_env(monkeypatch)
364367
runner = CliRunner()
365368
with runner.isolated_filesystem():
366369
Path("src").mkdir()
367370
with patch("navegador.cli.commands._get_store", return_value=_mock_store()), \
368371
patch("navegador.ingestion.RepoIngester") as MockRI:
@@ -371,11 +374,12 @@
371374
assert result.exit_code == 1
372375
payload = json.loads(result.output)
373376
assert payload["status"] == "error"
374377
assert "DB unavailable" in payload["errors"][0]
375378
376
- def test_output_is_valid_json(self):
379
+ def test_output_is_valid_json(self, monkeypatch):
380
+ _clear_ci_env(monkeypatch)
377381
runner = CliRunner()
378382
with runner.isolated_filesystem():
379383
Path("src").mkdir()
380384
with patch("navegador.cli.commands._get_store", return_value=_mock_store()), \
381385
patch("navegador.ingestion.RepoIngester") as MockRI:
@@ -401,11 +405,12 @@
401405
return result
402406
403407
store.query.side_effect = _query
404408
return store
405409
406
- def test_outputs_json_stats(self):
410
+ def test_outputs_json_stats(self, monkeypatch):
411
+ _clear_ci_env(monkeypatch)
407412
runner = CliRunner()
408413
with patch("navegador.cli.commands._get_store", return_value=self._store_with_counts()):
409414
result = runner.invoke(main, ["ci", "stats"])
410415
assert result.exit_code == 0
411416
payload = json.loads(result.output)
@@ -412,11 +417,12 @@
412417
assert payload["status"] == "success"
413418
assert "data" in payload
414419
assert "total_nodes" in payload["data"]
415420
assert "total_edges" in payload["data"]
416421
417
- def test_error_on_store_failure(self):
422
+ def test_error_on_store_failure(self, monkeypatch):
423
+ _clear_ci_env(monkeypatch)
418424
runner = CliRunner()
419425
with patch("navegador.cli.commands._get_store", side_effect=RuntimeError("no db")):
420426
result = runner.invoke(main, ["ci", "stats"])
421427
assert result.exit_code == 1
422428
payload = json.loads(result.output)
@@ -425,11 +431,12 @@
425431
426432
# ── CLI: navegador ci check ───────────────────────────────────────────────────
427433
428434
429435
class TestCICheckCommand:
430
- def test_success_when_schema_current(self):
436
+ def test_success_when_schema_current(self, monkeypatch):
437
+ _clear_ci_env(monkeypatch)
431438
from navegador.graph.migrations import CURRENT_SCHEMA_VERSION
432439
433440
store = MagicMock()
434441
store.query.return_value = MagicMock(result_set=[[CURRENT_SCHEMA_VERSION]])
435442
@@ -439,13 +446,13 @@
439446
assert result.exit_code == 0
440447
payload = json.loads(result.output)
441448
assert payload["status"] == "success"
442449
assert payload["data"]["schema_version"] == CURRENT_SCHEMA_VERSION
443450
444
- def test_warning_when_migration_needed(self):
451
+ def test_warning_when_migration_needed(self, monkeypatch):
452
+ _clear_ci_env(monkeypatch)
445453
store = MagicMock()
446
- # Return version 0 so migration is needed
447454
store.query.return_value = MagicMock(result_set=[[0]])
448455
449456
runner = CliRunner()
450457
with patch("navegador.cli.commands._get_store", return_value=store):
451458
result = runner.invoke(main, ["ci", "check"])
@@ -452,19 +459,21 @@
452459
assert result.exit_code == 2
453460
payload = json.loads(result.output)
454461
assert payload["status"] == "warning"
455462
assert payload["warnings"]
456463
457
- def test_error_on_store_failure(self):
464
+ def test_error_on_store_failure(self, monkeypatch):
465
+ _clear_ci_env(monkeypatch)
458466
runner = CliRunner()
459467
with patch("navegador.cli.commands._get_store", side_effect=RuntimeError("no db")):
460468
result = runner.invoke(main, ["ci", "check"])
461469
assert result.exit_code == 1
462470
payload = json.loads(result.output)
463471
assert payload["status"] == "error"
464472
465
- def test_payload_includes_version_info(self):
473
+ def test_payload_includes_version_info(self, monkeypatch):
474
+ _clear_ci_env(monkeypatch)
466475
from navegador.graph.migrations import CURRENT_SCHEMA_VERSION
467476
468477
store = MagicMock()
469478
store.query.return_value = MagicMock(result_set=[[CURRENT_SCHEMA_VERSION]])
470479
471480
--- tests/test_cicd.py
+++ tests/test_cicd.py
@@ -135,58 +135,58 @@
135
136 # ── CICDReporter — JSON output ────────────────────────────────────────────────
137
138
139 class TestJSONOutput:
140 def _emit_to_str(self, reporter, data=None, monkeypatch=None) -> dict:
 
141 buf = StringIO()
142 if monkeypatch:
143 _clear_ci_env(monkeypatch)
144 reporter.emit(data=data, file=buf)
145 return json.loads(buf.getvalue())
146
147 def test_status_success(self):
148 r = CICDReporter()
149 out = self._emit_to_str(r)
150 assert out["status"] == "success"
151
152 def test_status_error(self):
153 r = CICDReporter()
154 r.add_error("boom")
155 out = self._emit_to_str(r)
156 assert out["status"] == "error"
157
158 def test_status_warning(self):
159 r = CICDReporter()
160 r.add_warning("careful")
161 out = self._emit_to_str(r)
162 assert out["status"] == "warning"
163
164 def test_errors_list_in_payload(self):
165 r = CICDReporter()
166 r.add_error("err1")
167 r.add_error("err2")
168 out = self._emit_to_str(r)
169 assert out["errors"] == ["err1", "err2"]
170
171 def test_warnings_list_in_payload(self):
172 r = CICDReporter()
173 r.add_warning("w1")
174 out = self._emit_to_str(r)
175 assert out["warnings"] == ["w1"]
176
177 def test_data_included_when_provided(self):
178 r = CICDReporter()
179 out = self._emit_to_str(r, data={"files": 5, "functions": 20})
180 assert out["data"] == {"files": 5, "functions": 20}
181
182 def test_data_absent_when_not_provided(self):
183 r = CICDReporter()
184 out = self._emit_to_str(r)
185 assert "data" not in out
186
187 def test_output_is_valid_json(self):
 
188 r = CICDReporter()
189 r.add_error("oops")
190 r.add_warning("watch out")
191 buf = StringIO()
192 r.emit(data={"key": "value"}, file=buf)
@@ -332,11 +332,12 @@
332
333 # ── CLI: navegador ci ingest ──────────────────────────────────────────────────
334
335
336 class TestCIIngestCommand:
337 def test_success_outputs_json(self):
 
338 runner = CliRunner()
339 with runner.isolated_filesystem():
340 Path("src").mkdir()
341 with patch("navegador.cli.commands._get_store", return_value=_mock_store()), \
342 patch("navegador.ingestion.RepoIngester") as MockRI:
@@ -345,11 +346,12 @@
345 assert result.exit_code == 0
346 payload = json.loads(result.output)
347 assert payload["status"] == "success"
348 assert payload["data"]["files"] == 5
349
350 def test_warning_when_no_files_ingested(self):
 
351 runner = CliRunner()
352 with runner.isolated_filesystem():
353 Path("src").mkdir()
354 with patch("navegador.cli.commands._get_store", return_value=_mock_store()), \
355 patch("navegador.ingestion.RepoIngester") as MockRI:
@@ -358,11 +360,12 @@
358 assert result.exit_code == 2
359 payload = json.loads(result.output)
360 assert payload["status"] == "warning"
361 assert payload["warnings"]
362
363 def test_error_on_ingest_exception(self):
 
364 runner = CliRunner()
365 with runner.isolated_filesystem():
366 Path("src").mkdir()
367 with patch("navegador.cli.commands._get_store", return_value=_mock_store()), \
368 patch("navegador.ingestion.RepoIngester") as MockRI:
@@ -371,11 +374,12 @@
371 assert result.exit_code == 1
372 payload = json.loads(result.output)
373 assert payload["status"] == "error"
374 assert "DB unavailable" in payload["errors"][0]
375
376 def test_output_is_valid_json(self):
 
377 runner = CliRunner()
378 with runner.isolated_filesystem():
379 Path("src").mkdir()
380 with patch("navegador.cli.commands._get_store", return_value=_mock_store()), \
381 patch("navegador.ingestion.RepoIngester") as MockRI:
@@ -401,11 +405,12 @@
401 return result
402
403 store.query.side_effect = _query
404 return store
405
406 def test_outputs_json_stats(self):
 
407 runner = CliRunner()
408 with patch("navegador.cli.commands._get_store", return_value=self._store_with_counts()):
409 result = runner.invoke(main, ["ci", "stats"])
410 assert result.exit_code == 0
411 payload = json.loads(result.output)
@@ -412,11 +417,12 @@
412 assert payload["status"] == "success"
413 assert "data" in payload
414 assert "total_nodes" in payload["data"]
415 assert "total_edges" in payload["data"]
416
417 def test_error_on_store_failure(self):
 
418 runner = CliRunner()
419 with patch("navegador.cli.commands._get_store", side_effect=RuntimeError("no db")):
420 result = runner.invoke(main, ["ci", "stats"])
421 assert result.exit_code == 1
422 payload = json.loads(result.output)
@@ -425,11 +431,12 @@
425
426 # ── CLI: navegador ci check ───────────────────────────────────────────────────
427
428
429 class TestCICheckCommand:
430 def test_success_when_schema_current(self):
 
431 from navegador.graph.migrations import CURRENT_SCHEMA_VERSION
432
433 store = MagicMock()
434 store.query.return_value = MagicMock(result_set=[[CURRENT_SCHEMA_VERSION]])
435
@@ -439,13 +446,13 @@
439 assert result.exit_code == 0
440 payload = json.loads(result.output)
441 assert payload["status"] == "success"
442 assert payload["data"]["schema_version"] == CURRENT_SCHEMA_VERSION
443
444 def test_warning_when_migration_needed(self):
 
445 store = MagicMock()
446 # Return version 0 so migration is needed
447 store.query.return_value = MagicMock(result_set=[[0]])
448
449 runner = CliRunner()
450 with patch("navegador.cli.commands._get_store", return_value=store):
451 result = runner.invoke(main, ["ci", "check"])
@@ -452,19 +459,21 @@
452 assert result.exit_code == 2
453 payload = json.loads(result.output)
454 assert payload["status"] == "warning"
455 assert payload["warnings"]
456
457 def test_error_on_store_failure(self):
 
458 runner = CliRunner()
459 with patch("navegador.cli.commands._get_store", side_effect=RuntimeError("no db")):
460 result = runner.invoke(main, ["ci", "check"])
461 assert result.exit_code == 1
462 payload = json.loads(result.output)
463 assert payload["status"] == "error"
464
465 def test_payload_includes_version_info(self):
 
466 from navegador.graph.migrations import CURRENT_SCHEMA_VERSION
467
468 store = MagicMock()
469 store.query.return_value = MagicMock(result_set=[[CURRENT_SCHEMA_VERSION]])
470
471
--- tests/test_cicd.py
+++ tests/test_cicd.py
@@ -135,58 +135,58 @@
135
136 # ── CICDReporter — JSON output ────────────────────────────────────────────────
137
138
139 class TestJSONOutput:
140 def _emit_to_str(self, reporter, monkeypatch, data=None) -> dict:
141 _clear_ci_env(monkeypatch)
142 buf = StringIO()
 
 
143 reporter.emit(data=data, file=buf)
144 return json.loads(buf.getvalue())
145
146 def test_status_success(self, monkeypatch):
147 r = CICDReporter()
148 out = self._emit_to_str(r, monkeypatch)
149 assert out["status"] == "success"
150
151 def test_status_error(self, monkeypatch):
152 r = CICDReporter()
153 r.add_error("boom")
154 out = self._emit_to_str(r, monkeypatch)
155 assert out["status"] == "error"
156
157 def test_status_warning(self, monkeypatch):
158 r = CICDReporter()
159 r.add_warning("careful")
160 out = self._emit_to_str(r, monkeypatch)
161 assert out["status"] == "warning"
162
163 def test_errors_list_in_payload(self, monkeypatch):
164 r = CICDReporter()
165 r.add_error("err1")
166 r.add_error("err2")
167 out = self._emit_to_str(r, monkeypatch)
168 assert out["errors"] == ["err1", "err2"]
169
170 def test_warnings_list_in_payload(self, monkeypatch):
171 r = CICDReporter()
172 r.add_warning("w1")
173 out = self._emit_to_str(r, monkeypatch)
174 assert out["warnings"] == ["w1"]
175
176 def test_data_included_when_provided(self, monkeypatch):
177 r = CICDReporter()
178 out = self._emit_to_str(r, monkeypatch, data={"files": 5, "functions": 20})
179 assert out["data"] == {"files": 5, "functions": 20}
180
181 def test_data_absent_when_not_provided(self, monkeypatch):
182 r = CICDReporter()
183 out = self._emit_to_str(r, monkeypatch)
184 assert "data" not in out
185
186 def test_output_is_valid_json(self, monkeypatch):
187 _clear_ci_env(monkeypatch)
188 r = CICDReporter()
189 r.add_error("oops")
190 r.add_warning("watch out")
191 buf = StringIO()
192 r.emit(data={"key": "value"}, file=buf)
@@ -332,11 +332,12 @@
332
333 # ── CLI: navegador ci ingest ──────────────────────────────────────────────────
334
335
336 class TestCIIngestCommand:
337 def test_success_outputs_json(self, monkeypatch):
338 _clear_ci_env(monkeypatch)
339 runner = CliRunner()
340 with runner.isolated_filesystem():
341 Path("src").mkdir()
342 with patch("navegador.cli.commands._get_store", return_value=_mock_store()), \
343 patch("navegador.ingestion.RepoIngester") as MockRI:
@@ -345,11 +346,12 @@
346 assert result.exit_code == 0
347 payload = json.loads(result.output)
348 assert payload["status"] == "success"
349 assert payload["data"]["files"] == 5
350
351 def test_warning_when_no_files_ingested(self, monkeypatch):
352 _clear_ci_env(monkeypatch)
353 runner = CliRunner()
354 with runner.isolated_filesystem():
355 Path("src").mkdir()
356 with patch("navegador.cli.commands._get_store", return_value=_mock_store()), \
357 patch("navegador.ingestion.RepoIngester") as MockRI:
@@ -358,11 +360,12 @@
360 assert result.exit_code == 2
361 payload = json.loads(result.output)
362 assert payload["status"] == "warning"
363 assert payload["warnings"]
364
365 def test_error_on_ingest_exception(self, monkeypatch):
366 _clear_ci_env(monkeypatch)
367 runner = CliRunner()
368 with runner.isolated_filesystem():
369 Path("src").mkdir()
370 with patch("navegador.cli.commands._get_store", return_value=_mock_store()), \
371 patch("navegador.ingestion.RepoIngester") as MockRI:
@@ -371,11 +374,12 @@
374 assert result.exit_code == 1
375 payload = json.loads(result.output)
376 assert payload["status"] == "error"
377 assert "DB unavailable" in payload["errors"][0]
378
379 def test_output_is_valid_json(self, monkeypatch):
380 _clear_ci_env(monkeypatch)
381 runner = CliRunner()
382 with runner.isolated_filesystem():
383 Path("src").mkdir()
384 with patch("navegador.cli.commands._get_store", return_value=_mock_store()), \
385 patch("navegador.ingestion.RepoIngester") as MockRI:
@@ -401,11 +405,12 @@
405 return result
406
407 store.query.side_effect = _query
408 return store
409
410 def test_outputs_json_stats(self, monkeypatch):
411 _clear_ci_env(monkeypatch)
412 runner = CliRunner()
413 with patch("navegador.cli.commands._get_store", return_value=self._store_with_counts()):
414 result = runner.invoke(main, ["ci", "stats"])
415 assert result.exit_code == 0
416 payload = json.loads(result.output)
@@ -412,11 +417,12 @@
417 assert payload["status"] == "success"
418 assert "data" in payload
419 assert "total_nodes" in payload["data"]
420 assert "total_edges" in payload["data"]
421
422 def test_error_on_store_failure(self, monkeypatch):
423 _clear_ci_env(monkeypatch)
424 runner = CliRunner()
425 with patch("navegador.cli.commands._get_store", side_effect=RuntimeError("no db")):
426 result = runner.invoke(main, ["ci", "stats"])
427 assert result.exit_code == 1
428 payload = json.loads(result.output)
@@ -425,11 +431,12 @@
431
432 # ── CLI: navegador ci check ───────────────────────────────────────────────────
433
434
435 class TestCICheckCommand:
436 def test_success_when_schema_current(self, monkeypatch):
437 _clear_ci_env(monkeypatch)
438 from navegador.graph.migrations import CURRENT_SCHEMA_VERSION
439
440 store = MagicMock()
441 store.query.return_value = MagicMock(result_set=[[CURRENT_SCHEMA_VERSION]])
442
@@ -439,13 +446,13 @@
446 assert result.exit_code == 0
447 payload = json.loads(result.output)
448 assert payload["status"] == "success"
449 assert payload["data"]["schema_version"] == CURRENT_SCHEMA_VERSION
450
451 def test_warning_when_migration_needed(self, monkeypatch):
452 _clear_ci_env(monkeypatch)
453 store = MagicMock()
 
454 store.query.return_value = MagicMock(result_set=[[0]])
455
456 runner = CliRunner()
457 with patch("navegador.cli.commands._get_store", return_value=store):
458 result = runner.invoke(main, ["ci", "check"])
@@ -452,19 +459,21 @@
459 assert result.exit_code == 2
460 payload = json.loads(result.output)
461 assert payload["status"] == "warning"
462 assert payload["warnings"]
463
464 def test_error_on_store_failure(self, monkeypatch):
465 _clear_ci_env(monkeypatch)
466 runner = CliRunner()
467 with patch("navegador.cli.commands._get_store", side_effect=RuntimeError("no db")):
468 result = runner.invoke(main, ["ci", "check"])
469 assert result.exit_code == 1
470 payload = json.loads(result.output)
471 assert payload["status"] == "error"
472
473 def test_payload_includes_version_info(self, monkeypatch):
474 _clear_ci_env(monkeypatch)
475 from navegador.graph.migrations import CURRENT_SCHEMA_VERSION
476
477 store = MagicMock()
478 store.query.return_value = MagicMock(result_set=[[CURRENT_SCHEMA_VERSION]])
479
480

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button