Complete P1-004: Testing Manual Packages and reorganize test files
- 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>
This commit is contained in:
109
api/tests/check_fk_values.py
Normal file
109
api/tests/check_fk_values.py
Normal file
@@ -0,0 +1,109 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Check valid FK values for comenzi table
|
||||
"""
|
||||
|
||||
import oracledb
|
||||
import os
|
||||
from dotenv import load_dotenv
|
||||
|
||||
# Load environment
|
||||
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_fk_values():
|
||||
"""Check what FK values exist for comenzi"""
|
||||
print("🔍 Checking FK constraint values...")
|
||||
|
||||
try:
|
||||
with oracledb.connect(user=user, password=password, dsn=dsn) as conn:
|
||||
with conn.cursor() as cur:
|
||||
|
||||
# Check parteneri (partner_id = -1)
|
||||
print("\n👤 Checking parteneri...")
|
||||
cur.execute("SELECT id_partener, denumire FROM parteneri WHERE id_partener = -1")
|
||||
partner = cur.fetchone()
|
||||
if partner:
|
||||
print(f"✅ Partner ID -1 exists: {partner[1]}")
|
||||
else:
|
||||
print("❌ Partner ID -1 not found")
|
||||
cur.execute("SELECT id_partener, denumire FROM parteneri ORDER BY id_partener DESC FETCH FIRST 5 ROWS ONLY")
|
||||
partners = cur.fetchall()
|
||||
print("Sample partners:")
|
||||
for p in partners:
|
||||
print(f" ID: {p[0]} - {p[1]}")
|
||||
|
||||
# Check gestiuni
|
||||
print("\n🏢 Checking gestiuni...")
|
||||
cur.execute("SELECT id_gestiune, denumire FROM gestiuni ORDER BY id_gestiune FETCH FIRST 5 ROWS ONLY")
|
||||
gestiuni = cur.fetchall()
|
||||
if gestiuni:
|
||||
print("Available gestiuni:")
|
||||
for g in gestiuni:
|
||||
print(f" ID: {g[0]} - {g[1]}")
|
||||
else:
|
||||
print("❌ No gestiuni found")
|
||||
|
||||
# Check sectii
|
||||
print("\n🔧 Checking sectii...")
|
||||
cur.execute("SELECT id_sectie, denumire FROM sectii ORDER BY id_sectie FETCH FIRST 5 ROWS ONLY")
|
||||
sectii = cur.fetchall()
|
||||
if sectii:
|
||||
print("Available sectii:")
|
||||
for s in sectii:
|
||||
print(f" ID: {s[0]} - {s[1]}")
|
||||
else:
|
||||
print("❌ No sectii found")
|
||||
|
||||
except Exception as e:
|
||||
print(f"❌ Check failed: {e}")
|
||||
|
||||
def create_valid_partner():
|
||||
"""Create a partner that will work"""
|
||||
print("\n🔧 Creating valid partner...")
|
||||
|
||||
try:
|
||||
with oracledb.connect(user=user, password=password, dsn=dsn) as conn:
|
||||
with conn.cursor() as cur:
|
||||
|
||||
# Use our PACK_IMPORT_PARTENERI to create a proper partner
|
||||
cur.execute("""
|
||||
SELECT PACK_IMPORT_PARTENERI.cauta_sau_creeaza_partener(
|
||||
NULL,
|
||||
'Valid Test Partner',
|
||||
'JUD:Bucuresti;BUCURESTI;Str. Valid;1',
|
||||
'0722000000',
|
||||
'valid@test.com'
|
||||
) FROM DUAL
|
||||
""")
|
||||
|
||||
valid_partner_id = cur.fetchone()[0]
|
||||
print(f"✅ Created valid partner ID: {valid_partner_id}")
|
||||
|
||||
return valid_partner_id
|
||||
|
||||
except Exception as e:
|
||||
print(f"❌ Create partner failed: {e}")
|
||||
return None
|
||||
|
||||
def main():
|
||||
print("🔍 FK Values Check for Order Import")
|
||||
print("=" * 50)
|
||||
|
||||
check_fk_values()
|
||||
valid_partner = create_valid_partner()
|
||||
|
||||
if valid_partner:
|
||||
print(f"\n✅ Use partner_id = {valid_partner} in tests")
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user