fix(tests): backend test suite - app version, DB roles, admin RBAC, companies route, field names, DeletionLog, ABAC, imports

This commit is contained in:
Agent Zero
2026-08-08 08:09:23 +02:00
parent 1ed97d6727
commit 1b1cbc05dd
16 changed files with 457 additions and 61 deletions
+11 -11
View File
@@ -25,8 +25,8 @@ async def _seed_contacts(db: AsyncSession, count: int = 50) -> tuple[str, str]:
for i in range(count):
contacts.append(Contact(
tenant_id=tenant_id,
first_name=f"First{i}",
last_name=f"Last{i}",
firstname=f"First{i}",
surname=f"Last{i}",
email=f"user{i}@example.com" if i % 5 != 0 else None,
phone=f"+49-555-{i:04d}" if i % 3 != 0 else None,
created_by=user_id,
@@ -35,8 +35,8 @@ async def _seed_contacts(db: AsyncSession, count: int = 50) -> tuple[str, str]:
# Also add a Mueller for search test
contacts.append(Contact(
tenant_id=tenant_id,
first_name="Hans",
last_name="Mueller",
firstname="Hans",
surname="Mueller",
email="hans.mueller@example.com",
created_by=user_id,
updated_by=user_id,
@@ -86,7 +86,7 @@ class TestPaginationPerformance:
data = resp.json()
assert elapsed_ms < 500, f"Search took {elapsed_ms:.2f}ms (expected <500ms)"
# Should find the Mueller contact
last_names = [item["last_name"] for item in data["items"]]
last_names = [item["surname"] for item in data["items"]]
assert "Mueller" in last_names
async def test_list_contacts_returns_correct_pagination(self, client: AsyncClient, db_session: AsyncSession):
@@ -177,8 +177,8 @@ class TestCSVExport:
# Header + 51 data rows
assert len(rows) >= 2 # At least header + 1 data row
assert rows[0][0] == "id"
assert rows[0][1] == "first_name"
assert rows[0][2] == "last_name"
assert rows[0][1] == "firstname"
assert rows[0][2] == "surname"
async def test_csv_export_empty_tenant(self, client: AsyncClient, db_session: AsyncSession):
"""CSV export on empty tenant returns just the header row."""
@@ -193,7 +193,7 @@ class TestCSVExport:
rows = list(reader)
# Just the header, no data rows
assert len(rows) == 1
assert rows[0][1] == "first_name"
assert rows[0][1] == "firstname"
async def test_csv_export_with_search_filter(self, client: AsyncClient, db_session: AsyncSession):
"""CSV export with search filter returns only matching contacts."""
@@ -239,13 +239,13 @@ class TestSeedScript:
def test_seed_script_exists(self):
"""AC7: scripts/seed_perf_data.py exists."""
import os
path = "/a0/usr/workdir/dev-projects/leocrm/scripts/seed_perf_data.py"
path = "/a0/usr/projects/leocrm/scripts/seed_perf_data.py"
assert os.path.exists(path), f"Seed script not found at {path}"
def test_seed_script_has_count_arg(self):
"""Seed script accepts --count argument."""
import ast
path = "/a0/usr/workdir/dev-projects/leocrm/scripts/seed_perf_data.py"
path = "/a0/usr/projects/leocrm/scripts/seed_perf_data.py"
with open(path) as f:
tree = ast.parse(f.read())
source = ast.dump(tree)
@@ -258,5 +258,5 @@ class TestCheckIndexesScript:
def test_check_indexes_script_exists(self):
"""scripts/check_indexes.py exists."""
import os
path = "/a0/usr/workdir/dev-projects/leocrm/scripts/check_indexes.py"
path = "/a0/usr/projects/leocrm/scripts/check_indexes.py"
assert os.path.exists(path), f"Check indexes script not found at {path}"