fix(tests): backend test suite - app version, DB roles, admin RBAC, companies route, field names, DeletionLog, ABAC, imports
This commit is contained in:
+15
-15
@@ -41,8 +41,8 @@ class TestContactCreate:
|
||||
resp = await client.post(
|
||||
"/api/v1/contacts",
|
||||
json={
|
||||
"first_name": "Alice",
|
||||
"last_name": "Wonderland",
|
||||
"firstname": "Alice",
|
||||
"surname": "Wonderland",
|
||||
"email": "alice@example.com",
|
||||
"company_ids": [company_id],
|
||||
},
|
||||
@@ -50,12 +50,12 @@ class TestContactCreate:
|
||||
)
|
||||
assert resp.status_code == 201
|
||||
data = resp.json()
|
||||
assert data["first_name"] == "Alice"
|
||||
assert data["last_name"] == "Wonderland"
|
||||
assert data["firstname"] == "Alice"
|
||||
assert data["surname"] == "Wonderland"
|
||||
# Verify N:M link via company detail
|
||||
comp_detail = await client.get(f"/api/v1/companies/{company_id}", headers=ORIGIN_HEADER)
|
||||
contacts = comp_detail.json()["contacts"]
|
||||
assert any(c["first_name"] == "Alice" for c in contacts)
|
||||
assert any(c["firstname"] == "Alice" for c in contacts)
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@@ -71,8 +71,8 @@ class TestContactDetail:
|
||||
create_resp = await client.post(
|
||||
"/api/v1/contacts",
|
||||
json={
|
||||
"first_name": "Bob",
|
||||
"last_name": "Builder",
|
||||
"firstname": "Bob",
|
||||
"surname": "Builder",
|
||||
"company_ids": [company_id],
|
||||
},
|
||||
headers=ORIGIN_HEADER,
|
||||
@@ -81,7 +81,7 @@ class TestContactDetail:
|
||||
resp = await client.get(f"/api/v1/contacts/{contact_id}", headers=ORIGIN_HEADER)
|
||||
assert resp.status_code == 200
|
||||
data = resp.json()
|
||||
assert data["first_name"] == "Bob"
|
||||
assert data["firstname"] == "Bob"
|
||||
assert "companies" in data
|
||||
assert isinstance(data["companies"], list)
|
||||
assert len(data["companies"]) == 1
|
||||
@@ -98,18 +98,18 @@ class TestContactUpdate:
|
||||
await login_client(client, "admin@tenanta.com")
|
||||
create_resp = await client.post(
|
||||
"/api/v1/contacts",
|
||||
json={"first_name": "Old", "last_name": "Name"},
|
||||
json={"firstname": "Old", "surname": "Name"},
|
||||
headers=ORIGIN_HEADER,
|
||||
)
|
||||
contact_id = create_resp.json()["id"]
|
||||
resp = await client.put(
|
||||
f"/api/v1/contacts/{contact_id}",
|
||||
json={"first_name": "New", "last_name": "Name", "email": "new@example.com"},
|
||||
json={"firstname": "New", "surname": "Name", "email": "new@example.com"},
|
||||
headers=ORIGIN_HEADER,
|
||||
)
|
||||
assert resp.status_code == 200
|
||||
data = resp.json()
|
||||
assert data["first_name"] == "New"
|
||||
assert data["firstname"] == "New"
|
||||
assert data["email"] == "new@example.com"
|
||||
|
||||
|
||||
@@ -123,7 +123,7 @@ class TestContactDelete:
|
||||
await login_client(client, "admin@tenanta.com")
|
||||
create_resp = await client.post(
|
||||
"/api/v1/contacts",
|
||||
json={"first_name": "Delete", "last_name": "Me"},
|
||||
json={"firstname": "Delete", "surname": "Me"},
|
||||
headers=ORIGIN_HEADER,
|
||||
)
|
||||
contact_id = create_resp.json()["id"]
|
||||
@@ -131,7 +131,7 @@ class TestContactDelete:
|
||||
assert resp.status_code == 204
|
||||
# Verify contact not in list
|
||||
list_resp = await client.get("/api/v1/contacts", headers=ORIGIN_HEADER)
|
||||
names = [f"{item['first_name']} {item['last_name']}" for item in list_resp.json()["items"]]
|
||||
names = [f"{item["firstname"]} {item["surname"]}" for item in list_resp.json()["items"]]
|
||||
assert "Delete Me" not in names
|
||||
|
||||
async def test_delete_contact_gdpr_hard_delete_returns_204(
|
||||
@@ -149,7 +149,7 @@ class TestContactDelete:
|
||||
await login_client(client, "admin@tenanta.com")
|
||||
create_resp = await client.post(
|
||||
"/api/v1/contacts",
|
||||
json={"first_name": "GDPR", "last_name": "Delete"},
|
||||
json={"firstname": "GDPR", "surname": "Delete"},
|
||||
headers=ORIGIN_HEADER,
|
||||
)
|
||||
contact_id = create_resp.json()["id"]
|
||||
@@ -170,4 +170,4 @@ class TestContactDelete:
|
||||
dl_result = await db_session.execute(dl_q)
|
||||
dl_entries = dl_result.scalars().all()
|
||||
assert len(dl_entries) >= 1
|
||||
assert dl_entries[0].entity_snapshot["first_name"] == "GDPR"
|
||||
assert dl_entries[0].entity_snapshot["firstname"] == "GDPR"
|
||||
|
||||
Reference in New Issue
Block a user