Skip to content

Commit c7bd9d2

Browse files
committed
fix: reviewer's findings
1 parent 94bb396 commit c7bd9d2

5 files changed

Lines changed: 34 additions & 17 deletions

File tree

tests/_helpers.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
"""Shared test helpers that must not live in conftest.
2+
3+
pytest treats conftest specially and it is not guaranteed to be importable as
4+
``tests.conftest`` under non-default import modes (e.g. ``--import-mode=importlib``).
5+
"""
6+
from __future__ import annotations
7+
8+
from flask.testing import FlaskClient
9+
10+
from app import create_app
11+
from utils.exclusion_rules import tokenize_rule
12+
13+
14+
def client_with_rules(rule_lines: list[str]) -> FlaskClient:
15+
"""Flask test client with EXCLUSION_RULES parsed from the given lines.
16+
17+
Requires WORKSPACE_PATH / CLI_CHATS_PATH to already be set (e.g. by
18+
``workspace_storage`` fixture).
19+
"""
20+
parsed = [tokenize_rule(line) for line in rule_lines]
21+
app = create_app()
22+
app.config["TESTING"] = True
23+
app.config["EXCLUSION_RULES"] = [r for r in parsed if r]
24+
return app.test_client()

tests/conftest.py

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@
2222
HAPPY_COMPOSER_ID,
2323
HAPPY_WORKSPACE_ID,
2424
)
25-
from utils.exclusion_rules import tokenize_rule
26-
2725

2826
def _make_global_state_db(path: str) -> None:
2927
"""globalStorage/state.vscdb with one composerData + one bubbleId row."""
@@ -142,19 +140,6 @@ def client(workspace_storage: str):
142140
return app.test_client()
143141

144142

145-
def client_with_rules(rule_lines: list[str]) -> FlaskClient:
146-
"""Flask test client with EXCLUSION_RULES parsed from the given lines.
147-
148-
Requires WORKSPACE_PATH / CLI_CHATS_PATH to already be set (e.g. by
149-
``workspace_storage`` fixture).
150-
"""
151-
parsed = [tokenize_rule(line) for line in rule_lines]
152-
app = create_app()
153-
app.config["TESTING"] = True
154-
app.config["EXCLUSION_RULES"] = [r for r in parsed if r]
155-
return app.test_client()
156-
157-
158143
@pytest.fixture
159144
def empty_workspace_client() -> Generator[FlaskClient, None, None]:
160145
"""Flask test client bound to a workspaceStorage with no workspaces.

tests/test_api_export.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,8 @@ def test_since_last_with_no_prior_state_exports_all(
134134
def test_since_last_after_export_returns_404_when_nothing_new(
135135
self, client, export_state_dir
136136
):
137+
# Relies on the seeded composer's lastUpdatedAt (May 2024 in conftest)
138+
# being older than the export state's lastExportTime set by the first call.
137139
first = _post_export(client, {"since": "all"})
138140
assert first.status_code == 200
139141

tests/test_api_search.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from unittest.mock import patch
66

77
from tests._fixture_ids import HAPPY_COMPOSER_ID, HAPPY_WORKSPACE_ID
8-
from tests.conftest import client_with_rules
8+
from tests._helpers import client_with_rules
99

1010

1111
def _assert_search_result_shape(hit: dict) -> None:

tests/test_api_workspaces.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from unittest.mock import patch
66

77
from tests._fixture_ids import HAPPY_COMPOSER_ID, HAPPY_WORKSPACE_ID
8-
from tests.conftest import client_with_rules
8+
from tests._helpers import client_with_rules
99

1010

1111
def _assert_project_shape(project: dict) -> None:
@@ -104,6 +104,12 @@ def test_summary_query_returns_tab_list_without_bubbles(self, client):
104104
assert isinstance(tab["messageCount"], int)
105105
assert "bubbles" not in tab
106106

107+
def test_summary_query_global_workspace(self, client):
108+
response = client.get("/api/workspaces/global/tabs?summary=1")
109+
assert response.status_code == 200
110+
body = response.get_json()
111+
assert "tabs" in body and isinstance(body["tabs"], list)
112+
107113

108114
class TestGetWorkspaceTab:
109115
def test_happy_path_returns_single_tab(self, client):

0 commit comments

Comments
 (0)