Files
maddin 6fbd1bb3c2
CI / checks (push) Has been cancelled
chore: initialize public repository
2026-03-22 12:57:09 +00:00

69 lines
2.5 KiB
Python

from fastapi.testclient import TestClient
def test_bulk_entry_create_and_update(app):
with TestClient(app) as client_a, TestClient(app) as client_b:
register_a = client_a.post(
"/auth/register",
json={"email": "bulk-a@example.com", "password": "strongpasswordBulkA1"},
)
assert register_a.status_code == 200
csrf_a = register_a.json()["csrf_token"]
register_b = client_b.post(
"/auth/register",
json={"email": "bulk-b@example.com", "password": "strongpasswordBulkB1"},
)
assert register_b.status_code == 200
create_range = client_a.post(
"/bulk-entry",
data={
"from_date": "2026-03-02",
"to_date": "2026-03-13",
"weekdays_values": ["0", "1", "2", "3", "4"],
"start_time": "08:00",
"end_time": "12:00",
"break_minutes": "0",
"mode": "only_missing",
"notes": "nachtrag",
"csrf_token": csrf_a,
},
follow_redirects=False,
)
assert create_range.status_code == 303
list_a = client_a.get("/time-entries", params={"from": "2026-03-01", "to": "2026-03-31"})
assert list_a.status_code == 200
assert len(list_a.json()["items"]) == 10
update_range = client_a.post(
"/bulk-entry",
data={
"from_date": "2026-03-02",
"to_date": "2026-03-13",
"weekdays_values": ["0", "1", "2", "3", "4"],
"start_time": "08:30",
"end_time": "13:30",
"break_minutes": "30",
"mode": "upsert",
"notes": "korrigiert",
"csrf_token": csrf_a,
},
follow_redirects=False,
)
assert update_range.status_code == 303
list_a_updated = client_a.get("/time-entries", params={"from": "2026-03-01", "to": "2026-03-31"})
assert list_a_updated.status_code == 200
items = list_a_updated.json()["items"]
assert len(items) == 10
assert items[0]["start_time"] == "08:30"
assert items[0]["end_time"] == "13:30"
assert items[0]["break_minutes"] == 30
assert items[0]["notes"] == "korrigiert"
list_b = client_b.get("/time-entries", params={"from": "2026-03-01", "to": "2026-03-31"})
assert list_b.status_code == 200
assert list_b.json()["items"] == []