diff --git a/requirements-dev.txt b/requirements-dev.txt index ba61167..f360e6b 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -1,6 +1,6 @@ requests==2.34.2 pytest==9.1.1 -ruff==0.16.5 -pydantic==2.8.2 -pytest-cov==7.1.0 -bandit==1.7.9 +ruff==0.16.4 +pydantic==2.13.5 +pytest-cov==5.0.0 +bandit==1.9.4 diff --git a/requirements.txt b/requirements.txt index fa9c107..3a9fe7c 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,2 @@ requests==2.34.2 -pydantic==2.8.2 -structlog -sentry-sdk \ No newline at end of file +pydantic==2.13.5 \ No newline at end of file diff --git a/tests/test_comprehensive.py b/tests/test_comprehensive.py index 7825655..13f51de 100644 --- a/tests/test_comprehensive.py +++ b/tests/test_comprehensive.py @@ -1,75 +1,35 @@ -import sys -sys.path.insert(0, "linear-audit") +import sys +sys.path.insert(0, 'linear-audit') +import json, tempfile, pathlib, os from unittest.mock import Mock, patch - -import fetch_issues -import refresh_dashboard -import register_webhook -import remediate -import run_audit - - +import fetch_issues, run_audit, remediate, refresh_dashboard, register_webhook def test_fetch(): - with patch("fetch_issues.requests.post") as m: - + with patch('fetch_issues.requests.post') as m: def se(*a, **kw): - r = Mock() - r.raise_for_status = Mock() - r.json.return_value = { - "data": { - "team": { - "name": "T", - "issues": { - "edges": [ - {"node": {"id": "1", "identifier": "LIN-1", "title": "t", "state": {"type": "backlog"}}} - ], - "pageInfo": {"hasNextPage": False, "endCursor": None}, - }, - } - } - } + r=Mock(); r.raise_for_status=Mock() + r.json.return_value={"data": {"team": {"name": "T", "issues": {"edges": [{"node": {"id": "1", "identifier": "LIN-1", "title": "t", "state": {"type": "backlog"}}}], "pageInfo": {"hasNextPage": False, "endCursor": None}}}}} return r - - m.side_effect = se + m.side_effect=se result = fetch_issues.fetch_all_issues(api_key="k", team_id="team1", max_pages=1) - assert len(result) == 1 - - + assert len(result)==1 + from fetch_issues import transform_to_flat + flat=transform_to_flat({"id": "1", "identifier": "LIN-1", "title": "t", "state": {"type": "backlog"}, "priority": 1}) + assert flat.get("identifier")=="LIN-1" or flat.get("id")=="LIN-1" def test_refresh(): - md, _, _ = refresh_dashboard.generate_dashboard_content([], now_str="2026-01-01 00:00 UTC") + md, entries, stats = refresh_dashboard.generate_dashboard_content([], now_str="2026-01-01 00:00 UTC") assert isinstance(md, str) - - def test_register(): - with patch("register_webhook.gql", return_value={"data": {"webhooks": {"nodes": []}}}): + with patch('register_webhook.gql', return_value={"data": {"webhooks": {"nodes": []}}}): assert register_webhook.list_webhooks(api_key="k") == [] - - def test_remediate(): - c = remediate.LinearClient(api_key="k") + c=remediate.LinearClient(api_key="k") assert "Authorization" in c.headers - - def test_run_audit(): - import json as js - import pathlib - import tempfile - + import tempfile, pathlib, json as js with tempfile.TemporaryDirectory() as td: - p = pathlib.Path(td) / "x.json" - p.write_text( - js.dumps( - [ - { - "id": "1", - "identifier": "LIN-1", - "title": "t", - "state": {"type": "backlog"}, - "project": "p1", - "estimate": 1, - } - ] - ) - ) - assert len(run_audit.load_issues(p)) == 1 + p=pathlib.Path(td)/"issues.json" + p.write_text(js.dumps([{"id": "1", "identifier": "LIN-1", "title": "t", "state": {"type": "backlog"}, "project": "p1", "estimate": 1}])) + issues=run_audit.load_issues(p) + result=run_audit.run_audit(issues) + assert isinstance(result, dict)