- Complete manual testing of all Oracle PL/SQL packages - Document 75% success rate (3/4 components passing) - Move all test scripts from api/ to api/tests/ subdirectory - Update P1-004 story with comprehensive test results - Identify external dependency blocking full order import - Mark Phase 1 as 95% complete, ready for Phase 2 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
125 lines
4.0 KiB
Python
125 lines
4.0 KiB
Python
#!/usr/bin/env python3
|
|
"""
|
|
Check FK constraints for comenzi table
|
|
"""
|
|
|
|
import oracledb
|
|
import os
|
|
from dotenv import load_dotenv
|
|
|
|
load_dotenv('.env')
|
|
|
|
user = os.environ['ORACLE_USER']
|
|
password = os.environ['ORACLE_PASSWORD']
|
|
dsn = os.environ['ORACLE_DSN']
|
|
|
|
try:
|
|
instantclient_path = os.environ.get('INSTANTCLIENTPATH', '/opt/oracle/instantclient_23_9')
|
|
oracledb.init_oracle_client(lib_dir=instantclient_path)
|
|
except Exception as e:
|
|
pass
|
|
|
|
def check_constraints():
|
|
"""Check FK constraints for comenzi table"""
|
|
print("🔍 Checking FK constraints...")
|
|
|
|
try:
|
|
with oracledb.connect(user=user, password=password, dsn=dsn) as conn:
|
|
with conn.cursor() as cur:
|
|
|
|
# Check FK_COMENZI_002 constraint
|
|
cur.execute("""
|
|
SELECT
|
|
constraint_name,
|
|
table_name,
|
|
r_constraint_name,
|
|
delete_rule,
|
|
status
|
|
FROM user_constraints
|
|
WHERE constraint_name = 'FK_COMENZI_002'
|
|
""")
|
|
|
|
constraint = cur.fetchone()
|
|
if constraint:
|
|
print(f"FK_COMENZI_002 found:")
|
|
print(f" Table: {constraint[1]}")
|
|
print(f" References: {constraint[2]}")
|
|
print(f" Status: {constraint[4]}")
|
|
|
|
# Get referenced table
|
|
cur.execute("""
|
|
SELECT table_name
|
|
FROM user_constraints
|
|
WHERE constraint_name = ?
|
|
""", [constraint[2]])
|
|
|
|
ref_table = cur.fetchone()
|
|
if ref_table:
|
|
print(f" Referenced table: {ref_table[0]}")
|
|
else:
|
|
print("❌ FK_COMENZI_002 not found")
|
|
|
|
# Check all FK constraints for comenzi
|
|
cur.execute("""
|
|
SELECT
|
|
constraint_name,
|
|
column_name
|
|
FROM user_cons_columns
|
|
WHERE table_name = 'COMENZI'
|
|
AND constraint_name LIKE 'FK_%'
|
|
ORDER BY constraint_name, position
|
|
""")
|
|
|
|
fk_columns = cur.fetchall()
|
|
if fk_columns:
|
|
print(f"\nAll FK constraints for COMENZI:")
|
|
for fk in fk_columns:
|
|
print(f" {fk[0]}: {fk[1]}")
|
|
|
|
except Exception as e:
|
|
print(f"❌ Check failed: {e}")
|
|
|
|
def test_simple_insert():
|
|
"""Test simple insert to see what breaks"""
|
|
print("\n🧪 Testing simple insert...")
|
|
|
|
try:
|
|
with oracledb.connect(user=user, password=password, dsn=dsn) as conn:
|
|
with conn.cursor() as cur:
|
|
|
|
# Test minimal insert
|
|
try:
|
|
cur.execute("""
|
|
INSERT INTO comenzi (
|
|
id_comanda,
|
|
numar,
|
|
data_comanda,
|
|
id_partener,
|
|
interna
|
|
) VALUES (
|
|
-999999,
|
|
'TEST-MINIMAL',
|
|
SYSDATE,
|
|
-1,
|
|
2
|
|
)
|
|
""")
|
|
|
|
print("✅ Minimal insert succeeded")
|
|
cur.execute("DELETE FROM comenzi WHERE id_comanda = -999999")
|
|
|
|
except Exception as e:
|
|
print(f"❌ Minimal insert failed: {e}")
|
|
|
|
except Exception as e:
|
|
print(f"❌ Test failed: {e}")
|
|
|
|
def main():
|
|
print("🔍 FK Constraints Analysis")
|
|
print("=" * 40)
|
|
|
|
check_constraints()
|
|
test_simple_insert()
|
|
|
|
if __name__ == "__main__":
|
|
main() |