| | @@ -0,0 +1,524 @@ |
| 1 | +"""Tests for navegador.cicd — CI/CD mode, CICDReporter, and `navegador ci` commands."""
|
| 2 | +
|
| 3 | +import json
|
| 4 | +import os
|
| 5 | +from io import StringIO
|
| 6 | +from pathlib import Path
|
| 7 | +from unittest.mock import MagicMock, patch
|
| 8 | +
|
| 9 | +import pytest
|
| 10 | +from click.testing import CliRunner
|
| 11 | +
|
| 12 | +from navegador.cicd import (
|
| 13 | + EXIT_ERROR,
|
| 14 | + EXIT_SUCCESS,
|
| 15 | + EXIT_WARN,
|
| 16 | + CICDReporter,
|
| 17 | + detect_ci,
|
| 18 | + is_ci,
|
| 19 | + is_github_actions,
|
| 20 | +)
|
| 21 | +from navegador.cli.commands import main
|
| 22 | +
|
| 23 | +
|
| 24 | +# ── Helpers ───────────────────────────────────────────────────────────────────
|
| 25 | +
|
| 26 | +
|
| 27 | +def _clear_ci_env(monkeypatch):
|
| 28 | + """Remove all known CI indicator env vars so each test starts clean."""
|
| 29 | + for var in ("GITHUB_ACTIONS", "CI", "GITLAB_CI", "CIRCLECI", "JENKINS_URL"):
|
| 30 | + monkeypatch.delenv(var, raising=False)
|
| 31 | +
|
| 32 | +
|
| 33 | +def _mock_store():
|
| 34 | + store = MagicMock()
|
| 35 | + store.query.return_value = MagicMock(result_set=[])
|
| 36 | + return store
|
| 37 | +
|
| 38 | +
|
| 39 | +# ── CI detection ──────────────────────────────────────────────────────────────
|
| 40 | +
|
| 41 | +
|
| 42 | +class TestDetectCI:
|
| 43 | + def test_returns_none_outside_ci(self, monkeypatch):
|
| 44 | + _clear_ci_env(monkeypatch)
|
| 45 | + assert detect_ci() is None
|
| 46 | +
|
| 47 | + def test_detects_github_actions(self, monkeypatch):
|
| 48 | + _clear_ci_env(monkeypatch)
|
| 49 | + monkeypatch.setenv("GITHUB_ACTIONS", "true")
|
| 50 | + assert detect_ci() == "github_actions"
|
| 51 | +
|
| 52 | + def test_detects_generic_ci(self, monkeypatch):
|
| 53 | + _clear_ci_env(monkeypatch)
|
| 54 | + monkeypatch.setenv("CI", "true")
|
| 55 | + assert detect_ci() == "ci"
|
| 56 | +
|
| 57 | + def test_detects_gitlab_ci(self, monkeypatch):
|
| 58 | + _clear_ci_env(monkeypatch)
|
| 59 | + monkeypatch.setenv("GITLAB_CI", "true")
|
| 60 | + assert detect_ci() == "gitlab_ci"
|
| 61 | +
|
| 62 | + def test_detects_circleci(self, monkeypatch):
|
| 63 | + _clear_ci_env(monkeypatch)
|
| 64 | + monkeypatch.setenv("CIRCLECI", "true")
|
| 65 | + assert detect_ci() == "circleci"
|
| 66 | +
|
| 67 | + def test_detects_jenkins(self, monkeypatch):
|
| 68 | + _clear_ci_env(monkeypatch)
|
| 69 | + monkeypatch.setenv("JENKINS_URL", "http://jenkins.local/")
|
| 70 | + assert detect_ci() == "jenkins"
|
| 71 | +
|
| 72 | + def test_github_actions_takes_priority_over_ci(self, monkeypatch):
|
| 73 | + _clear_ci_env(monkeypatch)
|
| 74 | + monkeypatch.setenv("GITHUB_ACTIONS", "true")
|
| 75 | + monkeypatch.setenv("CI", "true")
|
| 76 | + assert detect_ci() == "github_actions"
|
| 77 | +
|
| 78 | +
|
| 79 | +class TestIsCI:
|
| 80 | + def test_false_outside_ci(self, monkeypatch):
|
| 81 | + _clear_ci_env(monkeypatch)
|
| 82 | + assert is_ci() is False
|
| 83 | +
|
| 84 | + def test_true_in_ci(self, monkeypatch):
|
| 85 | + _clear_ci_env(monkeypatch)
|
| 86 | + monkeypatch.setenv("CI", "true")
|
| 87 | + assert is_ci() is True
|
| 88 | +
|
| 89 | +
|
| 90 | +class TestIsGitHubActions:
|
| 91 | + def test_false_outside_gha(self, monkeypatch):
|
| 92 | + _clear_ci_env(monkeypatch)
|
| 93 | + assert is_github_actions() is False
|
| 94 | +
|
| 95 | + def test_false_for_generic_ci(self, monkeypatch):
|
| 96 | + _clear_ci_env(monkeypatch)
|
| 97 | + monkeypatch.setenv("CI", "true")
|
| 98 | + assert is_github_actions() is False
|
| 99 | +
|
| 100 | + def test_true_for_github_actions(self, monkeypatch):
|
| 101 | + _clear_ci_env(monkeypatch)
|
| 102 | + monkeypatch.setenv("GITHUB_ACTIONS", "true")
|
| 103 | + assert is_github_actions() is True
|
| 104 | +
|
| 105 | +
|
| 106 | +# ── CICDReporter — exit codes ─────────────────────────────────────────────────
|
| 107 | +
|
| 108 | +
|
| 109 | +class TestExitCodes:
|
| 110 | + def test_success_when_clean(self):
|
| 111 | + r = CICDReporter()
|
| 112 | + assert r.exit_code() == EXIT_SUCCESS
|
| 113 | +
|
| 114 | + def test_error_when_error_added(self):
|
| 115 | + r = CICDReporter()
|
| 116 | + r.add_error("something broke")
|
| 117 | + assert r.exit_code() == EXIT_ERROR
|
| 118 | +
|
| 119 | + def test_warn_when_only_warnings(self):
|
| 120 | + r = CICDReporter()
|
| 121 | + r.add_warning("heads up")
|
| 122 | + assert r.exit_code() == EXIT_WARN
|
| 123 | +
|
| 124 | + def test_error_takes_priority_over_warning(self):
|
| 125 | + r = CICDReporter()
|
| 126 | + r.add_warning("minor issue")
|
| 127 | + r.add_error("fatal issue")
|
| 128 | + assert r.exit_code() == EXIT_ERROR
|
| 129 | +
|
| 130 | + def test_exit_code_constants(self):
|
| 131 | + assert EXIT_SUCCESS == 0
|
| 132 | + assert EXIT_ERROR == 1
|
| 133 | + assert EXIT_WARN == 2
|
| 134 | +
|
| 135 | +
|
| 136 | +# ── CICDReporter — JSON output ────────────────────────────────────────────────
|
| 137 | +
|
| 138 | +
|
| 139 | +class TestJSONOutput:
|
| 140 | + def _edata=None, monkeypatch=None) -> dict:
|
| 141 | + data"] == {"files": 5, "fif monkeypatch:
|
| 142 | + _clear_ci_enveporter.emit(data=data, file=buf)
|
| 143 | + return json.loads(buf.getvalue())
|
| 144 | +
|
| 145 | + dAB_CI", "trr = CICDReporter()
|
| 146 | + )
|
| 147 | + assert outTests for navegador.cicdegador.cicd — CI/CDerrorleci(self, monkeypatch):
|
| 148 | + boom)
|
| 149 | + assert out["status"] == "error"
|
| 150 | +
|
| 151 | + def test_status_warning(selfAB_CI", "trmands."""
|
| 152 | +
|
| 153 | +import json
|
| 154 | +import o"""Tests for naveonkeypatch)
|
| 155 | + assert out["status"] == "warning"
|
| 156 | +
|
| 157 | + def test_AB_CI", "trr = CICDReporter()
|
| 158 | + r.add_error("err1")
|
| 159 | + r.add_error("err2")
|
| 160 | + )
|
| 161 | + assert out["errors"] == ["err1", "err2"]
|
| 162 | +
|
| 163 | + def test_warnings_list_in_payload(selfAB_CI", "trr.add_warning("w1")
|
| 164 | + )
|
| 165 | + assert onkeypatch)
|
| 166 | + assert out["warnings"] == ["w1"]
|
| 167 | +
|
| 168 | + def test_data_AB_CI", "trr = CICDReporter()
|
| 169 | + data=ry.write_text("# Previous con)
|
| 170 | + assert out["data"] == {"files": 5, "functions": 20}
|
| 171 | +
|
| 172 | + def test_data_absent_when_not_provided(selfAB_CI", "trr = CICDReporter()
|
| 173 | + )
|
| 174 | + assert "data" not in out
|
| 175 | +
|
| 176 | + def tesAB_CI", "trr.add_error("oops")
|
| 177 | + r.add_warning("watch out")
|
| 178 | + buf = StringIO()
|
| 179 | + r.emit(data={"key": "value"}, file=buf)
|
| 180 | + parsed = json.loads(buf.getvalue())
|
| 181 | + assert isinstance(parsed, dict)
|
| 182 | +
|
| 183 | +
|
| 184 | +# ── CICDReporter — GitHub Actions annotations ─────────────────────────────────
|
| 185 | +
|
| 186 | +
|
| 187 | +class TestGitHubActionsAnnotations:
|
| 188 | + def test_annotations_emitted_in_gha(self, monkeypatch):
|
| 189 | + _clear_ci_env(monkeypatch)
|
| 190 | + monkeypatch.setenv("GITHUB_ACTIONS", "true")
|
| 191 | +
|
| 192 | + r = CICDReporter()
|
| 193 | + r.add_error("bad thing")
|
| 194 | + r.add_warning("odd thing")
|
| 195 | +
|
| 196 | + buf = StringIO()
|
| 197 | + r.emit(file=buf)
|
| 198 | + output = buf.getvalue()
|
| 199 | +
|
| 200 | + assert "::error::bad thing" in output
|
| 201 | + assert "::warning::odd thing" in output
|
| 202 | +
|
| 203 | + def test_no_annotations_outside_gha(self, monkeypatch):
|
| 204 | + _clear_ci_env(monkeypatch)
|
| 205 | + monkeypatch.setenv("CI", "true")
|
| 206 | +
|
| 207 | + r = CICDReporter()
|
| 208 | + r.add_error("something")
|
| 209 | +
|
| 210 | + buf = StringIO()
|
| 211 | + r.emit(file=buf)
|
| 212 | + output = buf.getvalue()
|
| 213 | +
|
| 214 | + assert "::error::" not in output
|
| 215 | +
|
| 216 | + def test_multiple_errors_all_annotated(self, monkeypatch):
|
| 217 | + _clear_ci_env(monkeypatch)
|
| 218 | + monkeypatch.setenv("GITHUB_ACTIONS", "true")
|
| 219 | +
|
| 220 | + r = CICDReporter()
|
| 221 | + r.add_error("e1")
|
| 222 | + r.add_error("e2")
|
| 223 | +
|
| 224 | + buf = StringIO()
|
| 225 | + r.emit(file=buf)
|
| 226 | + output = buf.getvalue()
|
| 227 | +
|
| 228 | + assert "::error::e1" in output
|
| 229 | + assert "::error::e2" in output
|
| 230 | +
|
| 231 | +
|
| 232 | +# ── CICDReporter — GitHub Actions step summary ────────────────────────────────
|
| 233 | +
|
| 234 | +
|
| 235 | +class TestGitHubStepSummary:
|
| 236 | + def test_writes_summary_file(self, monkeypatch, tmp_path):
|
| 237 | + _clear_ci_env(monkeypatch)
|
| 238 | + monkeypatch.setenv("GITHUB_ACTIONS", "true")
|
| 239 | + summary = tmp_path / "summary.md"
|
| 240 | + monkeypatch.setenv("GITHUB_STEP_SUMMARY", str(summary))
|
| 241 | +
|
| 242 | + r = CICDReporter()
|
| 243 | + r.emit(data={"files": 3}, file=StringIO())
|
| 244 | +
|
| 245 | + content = summary.read_text()
|
| 246 | + assert "Navegador" in content
|
| 247 | + assert "files" in content
|
| 248 | +
|
| 249 | + def test_summary_includes_errors(self, monkeypatch, tmp_path):
|
| 250 | + _clear_ci_env(monkeypatch)
|
| 251 | + monkeypatch.setenv("GITHUB_ACTIONS", "true")
|
| 252 | + summary = tmp_path / "summary.md"
|
| 253 | + monkeypatch.setenv("GITHUB_STEP_SUMMARY", str(summary))
|
| 254 | +
|
| 255 | + r = CICDReporter()
|
| 256 | + r.add_error("ingest failed")
|
| 257 | + r.emit(file=StringIO())
|
| 258 | +
|
| 259 | + content = summary.read_text()
|
| 260 | + assert "ingest failed" in content
|
| 261 | +
|
| 262 | + def test_summary_includes_warnings(self, monkeypatch, tmp_path):
|
| 263 | + _clear_ci_env(monkeypatch)
|
| 264 | + monkeypatch.setenv("GITHUB_ACTIONS", "true")
|
| 265 | + summary = tmp_path / "summary.md"
|
| 266 | + monkeypatch.setenv("GITHUB_STEP_SUMMARY", str(summary))
|
| 267 | +
|
| 268 | + r = CICDReporter()
|
| 269 | + r.add_warning("no files found")
|
| 270 | + r.emit(file=StringIO())
|
| 271 | +
|
| 272 | + content = summary.read_text()
|
| 273 | + assert "no files found" in content
|
| 274 | +
|
| 275 | + def test_no_summary_without_env_var(self, monkeypatch, tmp_path):
|
| 276 | + _clear_ci_env(monkeypatch)
|
| 277 | + monkeypatch.setenv("GITHUB_ACTIONS", "true")
|
| 278 | + monkeypatch.delenv("GITHUB_STEP_SUMMARY", raising=False)
|
| 279 | +
|
| 280 | + r = CICDReporter()
|
| 281 | + # Should not raise even when GITHUB_STEP_SUMMARY is absent
|
| 282 | + r.emit(file=StringIO())
|
| 283 | +
|
| 284 | + def test_summary_appends_not_overwrites(self, monkeypatch, tmp_path):
|
| 285 | + _clear_ci_env(monkeypatch)
|
| 286 | + monkeypatch.setenv("GITHUB_ACTIONS", "true")
|
| 287 | + summary = tmp_path / "summary.md"
|
| 288 | + summary.write_text("# Previous content\n")
|
| 289 | + monkeypatch.setenv("GITHUB_STEP_SUMMARY", str(summary))
|
| 290 | +
|
| 291 | + r = CICDReporter()
|
| 292 | + r.emit(file=StringIO())
|
| 293 | +
|
| 294 | + content = summary.read_text()
|
| 295 | + assert "# Previous content" in content
|
| 296 | + assert "Navegador" in content
|
| 297 | +
|
| 298 | + def test_summary_handles_oserror_gracefully(self, monkeypatch, tmp_path):
|
| 299 | + _clear_ci_env(monkeypatch)
|
| 300 | + monkeypatch.setenv("GITHUB_ACTIONS", "true")
|
| 301 | + # Point to a directory instead of a file — open() will raise OSError
|
| 302 | + monkeypatch.setenv("GITHUB_STEP_SUMMARY", str(tmp_path))
|
| 303 | +
|
| 304 | + r = CICDReporter()
|
| 305 | + # Should not raise
|
| 306 | + r.emit(file=StringIO())
|
| 307 | +
|
| 308 | + def test_annotations_default_to_stdout(self, monkeypatch, capsys):
|
| 309 | + _clear_ci_env(monkeypatch)
|
| 310 | + monkeypatch.setenv("GITHUB_ACTIONS", "true")
|
| 311 | + monkeypatch.delenv("GITHUB_STEP_SUMMARY", raising=False)
|
| 312 | +
|
| 313 | + r = CICDReporter()
|
| 314 | + r.add_error("test error")
|
| 315 | + r._emit_github_annotations()
|
| 316 | + captured = capsys.readouterr()
|
| 317 | + assert "::error::test error" in captured.out
|
| 318 | +
|
| 319 | +
|
| 320 | +# ── CLI: navegador ci ingest ──────────────────────────────────────────────────
|
| 321 | +
|
| 322 | +
|
| 323 | +class TestCIIngestCommand:
|
| 324 | + def tes):ort pytest
|
| 325 | +from click.testing import CliRunner
|
| 326 | +
|
| 327 | +from navegador.cicd import (
|
| 328 | + EXIT_ERROR,
|
| 329 | + EXIT_SUCCESS,
|
| 330 | + EXIT_WARN,
|
| 331 | + CICDReporter,
|
| 332 | + detect_ci,
|
| 333 | + is_ci,
|
| 334 | + is_github_actions,
|
| 335 | +)
|
| 336 | +from navegador.cli.commands import main
|
| 337 | +
|
| 338 | +
|
| 339 | +# ── Helpers ──────────────────────────�"""Tests for navegador.cicd — CI/CD mode, CICDReporter, and `navegador ci` commands."""
|
| 340 | +
|
| 341 | +import json
|
| 342 | +import os
|
| 343 | +from io import StringIO
|
| 344 | +from pathlib import Path
|
| 345 | +from unittest.mock import MagicMock, patch
|
| 346 | +
|
| 347 | +import pytest
|
| 348 | +from click.testing import CliRunner
|
| 349 | +
|
| 350 | +from navegador.cicd import (
|
| 351 | + EXIT_ERROR,
|
| 352 | + EXIT_SUCCESS,
|
| 353 | + EXIT_WARN,
|
| 354 | + CICD):ort pytest
|
| 355 | +from click.testing import CliRunner
|
| 356 | +
|
| 357 | +from navegador.cicd import (
|
| 358 | + EXIT_ERROR,
|
| 359 | + EXIT_SUCCESS,
|
| 360 | + EXIT_WARN,
|
| 361 | + CICDReporter,
|
| 362 | + detect_ci,
|
| 363 | + is_ci,
|
| 364 | + is_github_actions,
|
| 365 | +)
|
| 366 | +from navegador.cli.commands import main
|
| 367 | +
|
| 368 | +
|
| 369 | +# ── Helpers ──────────────────────────�"""Tests for navegador.cicd — CI/CD mode, CICDReporter, and `navegador ci` commands."""
|
| 370 | +
|
| 371 | +import json
|
| 372 | +import os
|
| 373 | +from io import StringIO
|
| 374 | +from pathlib import Path
|
| 375 | +from unittest.mock import MagicMock, patch
|
| 376 | +
|
| 377 | +import pytest
|
| 378 | +from click.testing import CliRunner
|
| 379 | +
|
| 380 | +from navegador.cicd import (
|
| 381 | + EXIT_ERROR,
|
| 382 | + EXIT_SUCCESS,
|
| 383 | + EXI):ort pytest
|
| 384 | +from click.testing import CliRunner
|
| 385 | +
|
| 386 | +from navegador.cicd import (
|
| 387 | + EXIT_ERROR,
|
| 388 | + EXIT_SUCCESS,
|
| 389 | + EXIT_WARN,
|
| 390 | + CICDReporter,
|
| 391 | + detect_ci,
|
| 392 | + is_ci,
|
| 393 | + is_github_actions,
|
| 394 | +)
|
| 395 | +from navegador.cli.commands import main
|
| 396 | +
|
| 397 | +
|
| 398 | +# ── Helpers ─────────�"""Tests for navegador.cicd — CI/CD mode, CICDReporter, and `navegador ci` commands."""
|
| 399 | +
|
| 400 | +import json
|
| 401 | +import os
|
| 402 | +from io import StringIO
|
| 403 | +from pathlib import Path
|
| 404 | +from unittest.mock import MagicMock, patch
|
| 405 | +
|
| 406 | +import pytest
|
| 407 | +from click.testing import CliRunner
|
| 408 | +
|
| 409 | +from navegador.cicd import (
|
| 410 | + EXIT_ERROR,
|
| 411 | + EXIT_SUCCESS,
|
| 412 | + EXIT_WARN,
|
| 413 | + C):ort pytest
|
| 414 | +from click.testing import CliRunner
|
| 415 | +
|
| 416 | +from navegador.cicd import (
|
| 417 | + EXIT_ERROR,
|
| 418 | + EXIT_SUCCESS,
|
| 419 | + EXIT_WARN,
|
| 420 | + CICDReporter,
|
| 421 | + detect_ci,
|
| 422 | + is_ci,
|
| 423 | + is_github_actions,
|
| 424 | +)
|
| 425 | +from navegador.cli.commands import main
|
| 426 | +
|
| 427 | +
|
| 428 | +# ── Helpers ───────────────────────────────────────────────────────────────────
|
| 429 | +
|
| 430 | +
|
| 431 | +def _clear_ci_env(monkeypatch):
|
| 432 | + """Remove all known CI indicator env vars so each test starts clean."""
|
| 433 | + for var in ("GITHUB_ACTIONS", "CI", "GITLAB_CI", "CIRCLECI", "JENKINS_URL"):
|
| 434 | + monkeypatch.delenv(var, raising=False)
|
| 435 | +
|
| 436 | +
|
| 437 | +def _mock_store():
|
| 438 | + store = MagicMock()
|
| 439 | + store.query.return_value = MagicMock(result_set=[])
|
| 440 | + return store
|
| 441 | +
|
| 442 | +
|
| 443 | +# ── CI detection ──────────────────────────────────────────────────────────────
|
| 444 | +
|
| 445 | +
|
| 446 | +class TestDetectCI:
|
| 447 | + def test_returns_none_outside_ci(self, monkeypatch):
|
| 448 | + _clear_ci_env(monkeypatch)
|
| 449 | + assert detect_ci() is None""gester") as MockRI:
|
| 450 | + MockRI.return_value.ingest.side_effect = RuntimeError("DB unavailable")
|
| 451 | + result = runner.invoke(main, ["ci", "ingest", "src"])
|
| 452 | + assert result.exit_code == 1
|
| 453 | + payload = json.loads(result.output)
|
| 454 | + assert payload["status"] == "error"
|
| 455 | + assert "DB unavailable" in payload["errors"][0]
|
| 456 | +
|
| 457 | + def test_output_is_valid_json(self, monkeypatch):
|
| 458 | + _clear_ci_env(monkeypatch):gester") as MockRI:
|
| 459 | + MockRI.return_value.ingest.side_effect = RuntimeEr.cli.commands._get_store", side_effect=RuntimeError("no db")):
|
| 460 | + result = r)
|
| 461 | + ass1 payload = json.loads(result.output)
|
| 462 | + assert payload["status"]error"mary.read_text()
|
| 463 | + assercheckch):
|
| 464 | + _clear_ci_env(monkeypatch)
|
| 465 | + monkeypatch.setenv("CI", "true")
|
| 466 | + assert detect_ci() == "ci"
|
| 467 | +
|
| 468 | + def test_detects_gitlab_ci(───────Checkatch.setenv("GITHUB_ACTIONS", when_schema_current(self):stCIStatsCommand:
|
| 469 | + def _store_with_counts(self):
|
| 470 | + store = MagicMock()
|
| 471 | +
|
| 472 | + def _query(cypher, *args, **kwargs):
|
| 473 | + result = MagicMock()
|
| 474 | + if "NODE" in cypher.upper() or "node" in cypher.lower():
|
| 475 | + result.result_set = [["Function", 10], ["Class", 3]]
|
| 476 | + else:
|
| 477 | + result.result_set = [["CALLS", 25]]
|
| 478 | + return result
|
| 479 | +
|
| 480 | + store.query.side_effect = _query
|
| 481 | + return store
|
| 482 | +
|
| 483 | + def test_outputs_json_stats(self, monkeypatch):
|
| 484 | + _clear_ci_env(monkeypatch)
|
| 485 | + runner = CliRunner()
|
| 486 | + with pa):
|
| 487 | + s# Return versi store = MagicMock()
|
| 488 | + store.query.return_value = MagicMock(result_set=[[CURRENT_SCHEMA_VERSION]])
|
| 489 | +
|
| 490 | + runner = CliRunner()
|
| 491 | + with patch("navegador.cli.commands._get_store", return_value=store):
|
| 492 | + result = runner.invoke(main, ["ci", "check"])
|
| 493 | + payload = json.loads(result.output)
|
| 494 | + assert "schema_version" in payload["data"]
|
| 495 | + assert "current_schema_version" in payload["data"]
|
| 496 | +e = MagicMock(result_set=[[0]])
|
| 497 | +
|
| 498 | + runner = CliRunner()
|
| 499 | + with patch("navegador.cli.commands._get_store", return_value=store):
|
| 500 | + result = runner.invoke(main, ["ci", "check"])
|
| 501 | + assert result.exit_code == 2
|
| 502 | + payload = json.loads(result.output)
|
| 503 | + assert payload["status"] == "warning"
|
| 504 | + assert payload["warnings"]
|
| 505 | +
|
| 506 | + def test_):gester") as MockRI:
|
| 507 | + MockRI.return_value.ingest.side_effect = RuntimeEr.cli.commands._get_store", side_effect=RuntimeError("no db")):
|
| 508 | + result = runner.invoke(main, ["ci", "check"])
|
| 509 | + assert result.exit_code == 1
|
| 510 | + payload = json.loads(result.output)
|
| 511 | + assert payload["status"] == "error"
|
| 512 | +
|
| 513 | + def test_payload):stCIStatsCommand:
|
| 514 | + def _store_with_counts(self):
|
| 515 | + store = MagicMock()
|
| 516 | +
|
| 517 | + def _query(cypher, *args, **kwargs):
|
| 518 | + result = MagicMock()
|
| 519 | + if "NODE" in cypher.upper() or "node" in cypher.lower():
|
| 520 | + result.result_set = [["Function", 10], ["Class", 3]]
|
| 521 | + else:
|
| 522 | + respayload = json.loads(result.output)
|
| 523 | + assert "schema_version" in payload["data"]
|
| 524 | + assert "current_schema_v |