Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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:
Comment thread
coderabbitai[bot] marked this conversation as resolved.
_logger.warning(
"Could not read export state from %s: %s",
Expand Down
14 changes: 14 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
HAPPY_COMPOSER_ID,
HAPPY_WORKSPACE_ID,
)
from utils.exclusion_rules import tokenize_rule


def _make_global_state_db(path: str) -> None:
Expand Down Expand Up @@ -141,6 +142,19 @@ def client(workspace_storage: str):
return app.test_client()


def client_with_rules(rule_lines: list[str]) -> FlaskClient:
Comment thread
bradjin8 marked this conversation as resolved.
Outdated
"""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()


@pytest.fixture
def empty_workspace_client() -> Generator[FlaskClient, None, None]:
"""Flask test client bound to a workspaceStorage with no workspaces.
Expand Down
248 changes: 0 additions & 248 deletions tests/test_api_endpoints.py

This file was deleted.

Loading
Loading