Skip to content

Commit 150dfb9

Browse files
committed
🧪 feat(tests): add JSON output format tests for CLI
1 parent 20a2514 commit 150dfb9

1 file changed

Lines changed: 27 additions & 0 deletions

File tree

tests/test_cli.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -457,3 +457,30 @@ def test_mlst_stderr_surfaced_on_failure(self):
457457
assert result.stderr.strip() != "", (
458458
"Expected mlst error message in stderr, but stderr was empty."
459459
)
460+
461+
# ---------------------------------------------------------------------------
462+
# 9. JSON Output Format
463+
# ---------------------------------------------------------------------------
464+
465+
class TestJsonOutput:
466+
def test_exits_zero(self):
467+
result = _run("--db", _BUNDLED_DB, "--json", _TEST_FA)
468+
assert result.returncode == 0
469+
470+
def test_is_valid_json(self):
471+
import json
472+
result = _run("--db", _BUNDLED_DB, "--json", _TEST_FA)
473+
data = json.loads(result.stdout)
474+
assert isinstance(data, list)
475+
assert len(data) == 1
476+
assert "CC" in data[0]
477+
assert data[0]["NG-MAST/NG-STAR"] == "4186/231"
478+
assert data[0]["FILE"].endswith("test.fa")
479+
480+
def test_json_with_comments(self):
481+
import json
482+
result = _run("--db", _BUNDLED_DB, "--json", "--comments", _TEST_FA)
483+
data = json.loads(result.stdout)
484+
assert len(data) == 1
485+
assert "penA_comments" in data[0]
486+
assert "23S_comments" in data[0]

0 commit comments

Comments
 (0)