Publish curated MobilityOps source snapshot
This commit is contained in:
commit
7adc072f5e
317 files changed
+48851
No files matched your search
@@ -0,0 +1,33 @@
|
||||
import pytest
|
||||
from sqlalchemy import text
|
||||
from sqlalchemy.exc import IntegrityError
|
||||
|
||||
from app.core.db import SessionLocal
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
("statement", "constraint_name"),
|
||||
(
|
||||
(
|
||||
"UPDATE vehicles SET odometer_km = -1 WHERE public_ref = 'MO-001'",
|
||||
"ck_vehicles_odometer",
|
||||
),
|
||||
(
|
||||
"UPDATE bookings SET ends_at = starts_at WHERE public_ref = 'BK-DEMO-RETURN'",
|
||||
"ck_bookings_time_window",
|
||||
),
|
||||
(
|
||||
"UPDATE data_quality_issues SET status = 'invented' "
|
||||
"WHERE public_ref = 'DQ-DEMO-DUPLICATE'",
|
||||
"ck_data_quality_status",
|
||||
),
|
||||
("UPDATE outbox_events SET attempts = -1", "ck_outbox_attempts"),
|
||||
),
|
||||
)
|
||||
def test_database_rejects_invalid_domain_state(statement: str, constraint_name: str) -> None:
|
||||
with SessionLocal() as db:
|
||||
with pytest.raises(IntegrityError) as caught:
|
||||
db.execute(text(statement))
|
||||
db.commit()
|
||||
db.rollback()
|
||||
assert constraint_name in str(caught.value)
|
||||
Reference in new issue
Block a user