Files
kite/.planning/phases/06.1-close-v1-audit-gaps/06.1-01-SUMMARY.md
T
curo1305 ec14fc722f docs(6.1-01): complete plan — promote test_shares.py stubs to real tests
- 2/2 tasks complete: second_auth_user fixture + 7 real share tests
- 7 PASSED in Docker (0 xfailed, 0 failed)
- SHARE-01..05 requirements covered
2026-05-30 23:13:09 +02:00

4.4 KiB

phase, plan, subsystem, tags, dependency_graph, tech_stack, key_files, decisions, metrics
phase plan subsystem tags dependency_graph tech_stack key_files decisions metrics
6.1 06.1-01 testing
shares
test-promotion
xfail-removal
SHARE-01
SHARE-02
SHARE-03
SHARE-04
SHARE-05
requires provides affects
04-04
SHARE-01-tests
SHARE-02-tests
SHARE-03-tests
SHARE-04-tests
SHARE-05-tests
backend/tests/test_shares.py
backend/tests/conftest.py
added patterns
pytest_asyncio fixture
ORM direct-insert helper
pytestmark module-level
created modified
backend/tests/test_shares.py
backend/tests/conftest.py
second_auth_user fixture uses user2_ handle prefix to prevent collisions with auth_user's testuser_ prefix
_make_doc() helper inserts Document row directly via ORM (no upload endpoint) — same pattern as test_documents.py
pytestmark = pytest.mark.asyncio at module level replaces per-test decorators — consistent with other test files
duration completed_date tasks_completed tasks_total files_modified
~15 minutes 2026-05-30 2 2 2

Phase 6.1 Plan 01: Promote test_shares.py stubs to real tests (SHARE-01..05) Summary

One-liner: Seven xfail stubs replaced with real integration tests that exercise POST/GET/DELETE /api/shares via in-memory SQLite, plus a second_auth_user fixture enabling sharer/recipient scenarios.

Tasks Completed

Task Description Commit
1 Add second_auth_user fixture to conftest.py b7df971
2 Rewrite test_shares.py — 7 real tests replacing xfail stubs 9973f42

What Was Built

Task 1 — second_auth_user fixture (conftest.py)

Added @pytest_asyncio.fixture async def second_auth_user(db_session) immediately after auth_user. The fixture creates a second User with handle prefix user2_ and email user2_{hex8}@example.com, plus a Quota row with limit_bytes=100MB and used_bytes=0. Returns the same {user, token, headers} dict shape as auth_user. This fixture enables sharing tests that need a distinct sharer and recipient within the same test case.

Task 2 — Real tests in test_shares.py

Completely rewrote backend/tests/test_shares.py:

  • Removed: all 7 @pytest.mark.xfail(strict=False) decorators, all 7 pytest.xfail("not implemented yet") calls, import os (was unused)
  • Added: pytestmark = pytest.mark.asyncio, import uuid as _uuid, import pytest_asyncio
  • Added: async def _make_doc(db_session, owner_user) helper that inserts an uploaded Document row via ORM and returns str(doc_id)
  • Implemented 7 real tests:
Test Requirement Assertion
test_share_success SHARE-01 POST 201, body has id/document_id/recipient_id; recipient sees doc in /received
test_share_handle_not_found SHARE-01 POST with nonexistent handle → 404
test_shared_with_me SHARE-02 /received has required fields; extracted_text absent (T-04-04-03); owner_handle correct
test_share_no_quota_impact SHARE-03 Recipient /quota used_bytes == 0 after share (T-04-04-04)
test_revoke_share SHARE-04 DELETE 204; doc no longer in recipient /received
test_share_revoke_wrong_owner_404 SHARE-04 Recipient DELETE → 404 not 403 (IDOR protection T-04-04-02)
test_share_duplicate SHARE-05 Second POST with same doc+recipient → 409

Verification

docker compose exec backend python -m pytest tests/test_shares.py -v

Result: 7 passed, 0 failed, 0 xfailed, 0 xpassed (verified in Docker with pytest 9.0.3, asyncio mode=AUTO).

Deviations from Plan

None — plan executed exactly as written. The second_auth_user fixture was added to the worktree conftest.py at the exact position specified (after auth_user, before admin_user). All 7 tests match the plan spec.

Known Stubs

None. All 7 tests have real assertions against the live API.

Threat Flags

None. No new network endpoints, auth paths, file access patterns, or schema changes introduced. This plan is test-only.

Self-Check: PASSED

  • backend/tests/conftest.py contains second_auth_user fixture at line 229
  • backend/tests/test_shares.py has zero pytest.xfail calls
  • backend/tests/test_shares.py has zero @pytest.mark.xfail decorators
  • import os is absent from test_shares.py
  • pytestmark = pytest.mark.asyncio is present at module level
  • Commit b7df971 exists (Task 1)
  • Commit 9973f42 exists (Task 2)
  • Docker test run: 7 passed, 0 failed