Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ jobs:
# Pytest fixtures (tests/conftest.py) build a temp workspaceStorage and
# exercise Flask routes via app.test_client(). Only listed files — not
# `pytest tests/` — to avoid re-collecting unittest.TestCase classes above.
run: python -m pytest tests/test_api_endpoints.py tests/test_pdf_export.py tests/test_search_helpers.py -v --tb=short
run: python -m pytest tests/test_api_search.py tests/test_api_workspaces.py tests/test_api_export.py tests/test_pdf_export.py tests/test_search_helpers.py -v --tb=short

# ── PyInstaller desktop build (Windows only, once per workflow) ────────
# Closes #44. Builds the onedir bundle and smoke-tests --help so the
Expand Down Expand Up @@ -149,7 +149,9 @@ jobs:
- name: Install runtime deps + mypy
# Install from the pinned lock file for deterministic resolution,
# then add mypy (dev-only; not in requirements-lock.txt).
# Flask 3.1+ ships inline types — do not install types-Flask (conflicts).
# Flask 3.1+ includes inline type hints — do not add or install types-Flask
# (it will conflict with our pip installs). Preventative guidance for future
# maintainers editing the steps below.
run: |
python -m pip install --upgrade pip
python -m pip install -r requirements-lock.txt
Expand Down
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ __pycache__/
venv/
.venv/
env/
.mypy-ci-test/

# Packaging
*.egg-info/
Expand Down
11 changes: 9 additions & 2 deletions api/export_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import zipfile
from datetime import datetime
from pathlib import Path
from typing import Any, cast
from typing import Any

from flask import Blueprint, Response, request

Expand Down Expand Up @@ -45,7 +45,14 @@ def _get_export_state() -> dict[str, Any]:
if os.path.isfile(state_path):
try:
with open(state_path, "r", encoding="utf-8") as f:
return cast(dict[str, Any], json.load(f))
parsed = json.load(f)
if isinstance(parsed, dict):
return parsed
_logger.warning(
"Export state in %s is not a JSON object (got %s); ignoring",
state_path,
type(parsed).__name__,
)
except (json.JSONDecodeError, ValueError, OSError) as e:
_logger.warning(
"Could not read export state from %s: %s",
Expand Down
24 changes: 24 additions & 0 deletions tests/_helpers.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
"""Shared test helpers that must not live in conftest.

pytest treats conftest specially and it is not guaranteed to be importable as
``tests.conftest`` under non-default import modes (e.g. ``--import-mode=importlib``).
"""
from __future__ import annotations

from flask.testing import FlaskClient

from app import create_app
from utils.exclusion_rules import tokenize_rule


def client_with_rules(rule_lines: list[str]) -> FlaskClient:
"""Flask test client with EXCLUSION_RULES parsed from the given lines.

Requires WORKSPACE_PATH / CLI_CHATS_PATH to already be set (e.g. by
``workspace_storage`` fixture).
"""
parsed = [tokenize_rule(line) for line in rule_lines]
app = create_app()
app.config["TESTING"] = True
app.config["EXCLUSION_RULES"] = [r for r in parsed if r]
return app.test_client()
1 change: 0 additions & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
HAPPY_WORKSPACE_ID,
)


def _make_global_state_db(path: str) -> None:
"""globalStorage/state.vscdb with one composerData + one bubbleId row."""
# contextlib.closing guarantees conn.close() even if an exec/commit raises
Expand Down
248 changes: 0 additions & 248 deletions tests/test_api_endpoints.py

This file was deleted.

Loading
Loading