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:
124
api/tests/debug_functions.py
Normal file
124
api/tests/debug_functions.py
Normal file
@@ -0,0 +1,124 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Debug PACK_IMPORT_COMENZI functions - check correct parameter order
|
||||
"""
|
||||
|
||||
import oracledb
|
||||
import os
|
||||
import json
|
||||
from datetime import datetime
|
||||
from dotenv import load_dotenv
|
||||
|
||||
# Load environment
|
||||
load_dotenv('.env')
|
||||
|
||||
# Oracle configuration
|
||||
user = os.environ['ORACLE_USER']
|
||||
password = os.environ['ORACLE_PASSWORD']
|
||||
dsn = os.environ['ORACLE_DSN']
|
||||
|
||||
# Initialize Oracle client (thick mode)
|
||||
try:
|
||||
instantclient_path = os.environ.get('INSTANTCLIENTPATH', '/opt/oracle/instantclient_23_9')
|
||||
oracledb.init_oracle_client(lib_dir=instantclient_path)
|
||||
print(f"✅ Oracle thick mode initialized: {instantclient_path}")
|
||||
except Exception as e:
|
||||
print(f"⚠️ Oracle thick mode failed, using thin mode: {e}")
|
||||
|
||||
def debug_gaseste_articol():
|
||||
"""Debug gaseste_articol_roa function parameters and results"""
|
||||
print("\n🔍 Debug PACK_IMPORT_COMENZI.gaseste_articol_roa...")
|
||||
|
||||
try:
|
||||
with oracledb.connect(user=user, password=password, dsn=dsn) as conn:
|
||||
with conn.cursor() as cur:
|
||||
|
||||
# Check existing mappings first
|
||||
print("\n📋 Existing mappings in ARTICOLE_TERTI:")
|
||||
cur.execute("SELECT sku, codmat, cantitate_roa, procent_pret, activ FROM ARTICOLE_TERTI ORDER BY sku")
|
||||
mappings = cur.fetchall()
|
||||
for mapping in mappings:
|
||||
print(f" {mapping[0]} -> {mapping[1]}: qty={mapping[2]}, pct={mapping[3]}%, active={mapping[4]}")
|
||||
|
||||
# Test with correct parameter order: p_sku, p_pret_web, p_cantitate_web
|
||||
print("\n☕ Test CAFE100 with correct parameters:")
|
||||
print(" Parameters: SKU='CAFE100', pret_web=50.0, cantitate_web=2")
|
||||
cur.execute("""
|
||||
SELECT * FROM TABLE(PACK_IMPORT_COMENZI.gaseste_articol_roa('CAFE100', 50.0, 2))
|
||||
""")
|
||||
results = cur.fetchall()
|
||||
print(f" Results count: {len(results)}")
|
||||
for i, row in enumerate(results):
|
||||
print(f" Row {i+1}: id_articol={row[0]}, codmat={row[1]}, cant_roa={row[2]}, pret={row[3]}, success={row[4]}, error='{row[5]}'")
|
||||
|
||||
print("\n🎁 Test SET01 with correct parameters:")
|
||||
print(" Parameters: SKU='SET01', pret_web=200.0, cantitate_web=1")
|
||||
cur.execute("""
|
||||
SELECT * FROM TABLE(PACK_IMPORT_COMENZI.gaseste_articol_roa('SET01', 200.0, 1))
|
||||
""")
|
||||
results = cur.fetchall()
|
||||
print(f" Results count: {len(results)}")
|
||||
for i, row in enumerate(results):
|
||||
print(f" Row {i+1}: id_articol={row[0]}, codmat={row[1]}, cant_roa={row[2]}, pret={row[3]}, success={row[4]}, error='{row[5]}'")
|
||||
|
||||
# Test non-existent SKU
|
||||
print("\n❓ Test unknown SKU:")
|
||||
print(" Parameters: SKU='UNKNOWN', pret_web=100.0, cantitate_web=1")
|
||||
cur.execute("""
|
||||
SELECT * FROM TABLE(PACK_IMPORT_COMENZI.gaseste_articol_roa('UNKNOWN', 100.0, 1))
|
||||
""")
|
||||
results = cur.fetchall()
|
||||
print(f" Results count: {len(results)}")
|
||||
for i, row in enumerate(results):
|
||||
print(f" Row {i+1}: id_articol={row[0]}, codmat={row[1]}, cant_roa={row[2]}, pret={row[3]}, success={row[4]}, error='{row[5]}'")
|
||||
|
||||
except Exception as e:
|
||||
print(f"❌ Debug failed: {e}")
|
||||
|
||||
def check_nom_articole():
|
||||
"""Check if we have any articles in nom_articole to test with"""
|
||||
print("\n🔍 Checking nom_articole table...")
|
||||
|
||||
try:
|
||||
with oracledb.connect(user=user, password=password, dsn=dsn) as conn:
|
||||
with conn.cursor() as cur:
|
||||
|
||||
# Count total articles
|
||||
cur.execute("SELECT COUNT(*) FROM nom_articole")
|
||||
total_count = cur.fetchone()[0]
|
||||
print(f"Total articles in nom_articole: {total_count}")
|
||||
|
||||
# Find some sample articles
|
||||
print("\nSample articles (first 10):")
|
||||
cur.execute("""
|
||||
SELECT id_articol, codmat, denumire
|
||||
FROM nom_articole
|
||||
WHERE ROWNUM <= 10
|
||||
ORDER BY id_articol
|
||||
""")
|
||||
articles = cur.fetchall()
|
||||
for art in articles:
|
||||
print(f" ID={art[0]}: {art[1]} - {art[2]}")
|
||||
|
||||
# Look for articles that might match our test SKUs
|
||||
print(f"\nSearching for articles matching test patterns...")
|
||||
test_patterns = ['CAF%', 'FILTR%', '%CAFE%', '%SET%']
|
||||
for pattern in test_patterns:
|
||||
cur.execute("SELECT codmat, denumire FROM nom_articole WHERE codmat LIKE ? AND ROWNUM <= 3", [pattern])
|
||||
matches = cur.fetchall()
|
||||
if matches:
|
||||
print(f" Pattern '{pattern}': {matches}")
|
||||
|
||||
except Exception as e:
|
||||
print(f"❌ Check nom_articole failed: {e}")
|
||||
|
||||
def main():
|
||||
"""Run debug functions"""
|
||||
print("🔍 Debug PACK_IMPORT_COMENZI Functions")
|
||||
print("=" * 50)
|
||||
|
||||
check_nom_articole()
|
||||
debug_gaseste_articol()
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user