- Implement test script for new SAG module endpoints BE-003 (Tag State Management) and BE-004 (Bulk Operations). - Create test cases for creating, updating, and bulk operations on cases and tags. - Add a test for module deactivation to ensure data integrity is maintained. - Include setup and teardown for tests to clear database state before and after each test.
29 lines
760 B
Python
29 lines
760 B
Python
from app.core.database import get_db_connection, init_db, release_db_connection
|
|
|
|
init_db()
|
|
|
|
sql = """
|
|
CREATE TABLE IF NOT EXISTS case_location_relations (
|
|
id SERIAL PRIMARY KEY,
|
|
case_id INTEGER NOT NULL REFERENCES sag_sager(id) ON DELETE CASCADE,
|
|
location_id INTEGER NOT NULL REFERENCES locations_locations(id) ON DELETE CASCADE,
|
|
relation_type VARCHAR(50) DEFAULT 'located_at',
|
|
created_at TIMESTAMP DEFAULT NOW(),
|
|
deleted_at TIMESTAMP,
|
|
UNIQUE(case_id, location_id)
|
|
);
|
|
"""
|
|
|
|
conn = get_db_connection()
|
|
try:
|
|
with conn.cursor() as cursor:
|
|
cursor.execute(sql)
|
|
conn.commit()
|
|
print("Table created.")
|
|
except Exception as e:
|
|
conn.rollback()
|
|
print(f"Error: {e}")
|
|
raise
|
|
finally:
|
|
release_db_connection(conn)
|