chore(quality): apply ruff autofixes and formatting (223 fixes, regression-free: 118/118 tests pass)
This commit is contained in:
+67
-21
@@ -44,9 +44,7 @@ async def session_factory(
|
||||
engine: AsyncEngine,
|
||||
) -> async_sessionmaker[AsyncSession]:
|
||||
"""Session factory bound to the test engine."""
|
||||
return async_sessionmaker(
|
||||
bind=engine, expire_on_commit=False, class_=AsyncSession
|
||||
)
|
||||
return async_sessionmaker(bind=engine, expire_on_commit=False, class_=AsyncSession)
|
||||
|
||||
|
||||
@pytest_asyncio.fixture
|
||||
@@ -131,7 +129,9 @@ async def second_user(
|
||||
"/api/v1/auth/login",
|
||||
data={"username": payload["email"], "password": payload["password"]},
|
||||
)
|
||||
assert login_resp.status_code == 200, f"login failed: {login_resp.status_code} {login_resp.text}"
|
||||
assert login_resp.status_code == 200, (
|
||||
f"login failed: {login_resp.status_code} {login_resp.text}"
|
||||
)
|
||||
token = login_resp.json()["access_token"]
|
||||
|
||||
return {
|
||||
@@ -167,7 +167,12 @@ async def seed_data(
|
||||
# 2 accounts
|
||||
acc1 = await client.post(
|
||||
"/api/v1/accounts/",
|
||||
json={"name": "Acme Corp", "industry": "sme", "size": "sme", "website": "https://acme.test"},
|
||||
json={
|
||||
"name": "Acme Corp",
|
||||
"industry": "sme",
|
||||
"size": "sme",
|
||||
"website": "https://acme.test",
|
||||
},
|
||||
headers=headers,
|
||||
)
|
||||
assert acc1.status_code == 201, f"seed acc1: {acc1.status_code} {acc1.text}"
|
||||
@@ -184,7 +189,12 @@ async def seed_data(
|
||||
# 3 contacts (2 with account, 1 standalone)
|
||||
c1 = await client.post(
|
||||
"/api/v1/contacts/",
|
||||
json={"first_name": "Anna", "last_name": "Schmidt", "email": "anna@acme.example", "account_id": acc1_id},
|
||||
json={
|
||||
"first_name": "Anna",
|
||||
"last_name": "Schmidt",
|
||||
"email": "anna@acme.example",
|
||||
"account_id": acc1_id,
|
||||
},
|
||||
headers=headers,
|
||||
)
|
||||
assert c1.status_code == 201, c1.text
|
||||
@@ -192,7 +202,12 @@ async def seed_data(
|
||||
|
||||
c2 = await client.post(
|
||||
"/api/v1/contacts/",
|
||||
json={"first_name": "Bob", "last_name": "Mueller", "email": "bob@globex.example", "account_id": acc2_id},
|
||||
json={
|
||||
"first_name": "Bob",
|
||||
"last_name": "Mueller",
|
||||
"email": "bob@globex.example",
|
||||
"account_id": acc2_id,
|
||||
},
|
||||
headers=headers,
|
||||
)
|
||||
assert c2.status_code == 201, c2.text
|
||||
@@ -208,13 +223,15 @@ async def seed_data(
|
||||
|
||||
# 5 deals (different stages)
|
||||
deal_ids: list[int] = []
|
||||
for i, (title, stage) in enumerate([
|
||||
("Deal A", "lead"),
|
||||
("Deal B", "qualified"),
|
||||
("Deal C", "proposal"),
|
||||
("Deal D", "negotiation"),
|
||||
("Deal E", "won"),
|
||||
]):
|
||||
for i, (title, stage) in enumerate(
|
||||
[
|
||||
("Deal A", "lead"),
|
||||
("Deal B", "qualified"),
|
||||
("Deal C", "proposal"),
|
||||
("Deal D", "negotiation"),
|
||||
("Deal E", "won"),
|
||||
]
|
||||
):
|
||||
d = await client.post(
|
||||
"/api/v1/deals/",
|
||||
json={
|
||||
@@ -230,6 +247,7 @@ async def seed_data(
|
||||
|
||||
# 10 activities (4 overdue, 4 future, 2 completed)
|
||||
from datetime import UTC, datetime, timedelta
|
||||
|
||||
past = (datetime.now(UTC) - timedelta(days=2)).isoformat()
|
||||
future = (datetime.now(UTC) + timedelta(days=2)).isoformat()
|
||||
future2 = (datetime.now(UTC) + timedelta(days=10)).isoformat()
|
||||
@@ -237,10 +255,20 @@ async def seed_data(
|
||||
for i in range(10):
|
||||
if i < 4:
|
||||
due = past
|
||||
body_data: dict[str, object] = {"type": "task", "subject": f"Overdue task {i}", "due_date": due, "deal_id": deal_ids[i % 5]}
|
||||
body_data: dict[str, object] = {
|
||||
"type": "task",
|
||||
"subject": f"Overdue task {i}",
|
||||
"due_date": due,
|
||||
"deal_id": deal_ids[i % 5],
|
||||
}
|
||||
elif i < 8:
|
||||
due = future if i % 2 == 0 else future2
|
||||
body_data = {"type": "call", "subject": f"Upcoming call {i}", "due_date": due, "account_id": acc1_id}
|
||||
body_data = {
|
||||
"type": "call",
|
||||
"subject": f"Upcoming call {i}",
|
||||
"due_date": due,
|
||||
"account_id": acc1_id,
|
||||
}
|
||||
else:
|
||||
body_data = {"type": "meeting", "subject": f"Done meeting {i}", "account_id": acc1_id}
|
||||
a = await client.post("/api/v1/activities/", json=body_data, headers=headers)
|
||||
@@ -250,18 +278,36 @@ async def seed_data(
|
||||
# 3 tags
|
||||
tag_ids: list[int] = []
|
||||
for name in ["VIP", "Strategic", "Enterprise"]:
|
||||
t = await client.post("/api/v1/tags/", json={"name": name, "color": "#FF0080"}, headers=headers)
|
||||
t = await client.post(
|
||||
"/api/v1/tags/", json={"name": name, "color": "#FF0080"}, headers=headers
|
||||
)
|
||||
assert t.status_code == 201, t.text
|
||||
tag_ids.append(t.json()["id"])
|
||||
|
||||
# 4 notes (mixed parents: 2 account, 1 contact, 1 deal)
|
||||
n1 = await client.post("/api/v1/notes/", json={"body": "Note on Acme", "parent_type": "account", "parent_id": acc1_id}, headers=headers)
|
||||
n1 = await client.post(
|
||||
"/api/v1/notes/",
|
||||
json={"body": "Note on Acme", "parent_type": "account", "parent_id": acc1_id},
|
||||
headers=headers,
|
||||
)
|
||||
assert n1.status_code == 201, n1.text
|
||||
n2 = await client.post("/api/v1/notes/", json={"body": "Note on Globex", "parent_type": "account", "parent_id": acc2_id}, headers=headers)
|
||||
n2 = await client.post(
|
||||
"/api/v1/notes/",
|
||||
json={"body": "Note on Globex", "parent_type": "account", "parent_id": acc2_id},
|
||||
headers=headers,
|
||||
)
|
||||
assert n2.status_code == 201, n2.text
|
||||
n3 = await client.post("/api/v1/notes/", json={"body": "Note on Anna", "parent_type": "contact", "parent_id": c1_id}, headers=headers)
|
||||
n3 = await client.post(
|
||||
"/api/v1/notes/",
|
||||
json={"body": "Note on Anna", "parent_type": "contact", "parent_id": c1_id},
|
||||
headers=headers,
|
||||
)
|
||||
assert n3.status_code == 201, n3.text
|
||||
n4 = await client.post("/api/v1/notes/", json={"body": "Note on Deal A", "parent_type": "deal", "parent_id": deal_ids[0]}, headers=headers)
|
||||
n4 = await client.post(
|
||||
"/api/v1/notes/",
|
||||
json={"body": "Note on Deal A", "parent_type": "deal", "parent_id": deal_ids[0]},
|
||||
headers=headers,
|
||||
)
|
||||
assert n4.status_code == 201, n4.text
|
||||
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user