- 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>
175 lines
7.2 KiB
Python
175 lines
7.2 KiB
Python
#!/usr/bin/env python3
|
||
"""
|
||
Check nom_articole structure and look for CAF01, FILTRU01
|
||
"""
|
||
|
||
import oracledb
|
||
import os
|
||
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
|
||
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_table_structure():
|
||
"""Check nom_articole table structure"""
|
||
print("🔍 Checking nom_articole table structure...")
|
||
|
||
try:
|
||
with oracledb.connect(user=user, password=password, dsn=dsn) as conn:
|
||
with conn.cursor() as cur:
|
||
|
||
# Get column info
|
||
cur.execute("""
|
||
SELECT column_name, data_type, nullable, data_length
|
||
FROM user_tab_columns
|
||
WHERE table_name = 'NOM_ARTICOLE'
|
||
ORDER BY column_id
|
||
""")
|
||
columns = cur.fetchall()
|
||
print(f"\nColumns in nom_articole:")
|
||
for col in columns:
|
||
print(f" {col[0]}: {col[1]}({col[3]}) - {'NULL' if col[2] == 'Y' else 'NOT NULL'}")
|
||
|
||
# Check codmat values
|
||
print(f"\nCodmat value distribution:")
|
||
cur.execute("""
|
||
SELECT
|
||
COUNT(*) as total,
|
||
COUNT(codmat) as non_null,
|
||
COUNT(*) - COUNT(codmat) as null_count
|
||
FROM nom_articole
|
||
""")
|
||
stats = cur.fetchone()
|
||
print(f" Total records: {stats[0]}")
|
||
print(f" Non-null codmat: {stats[1]}")
|
||
print(f" Null codmat: {stats[2]}")
|
||
|
||
# Look for our test CODMATs
|
||
print(f"\nSearching for test CODMATs (CAF01, FILTRU01)...")
|
||
test_codmats = ['CAF01', 'FILTRU01']
|
||
for codmat in test_codmats:
|
||
cur.execute("SELECT id_articol, codmat, denumire FROM nom_articole WHERE codmat = :1", [codmat])
|
||
results = cur.fetchall()
|
||
if results:
|
||
for result in results:
|
||
print(f" ✅ Found {codmat}: ID={result[0]}, name='{result[2]}'")
|
||
else:
|
||
print(f" ❌ Not found: {codmat}")
|
||
|
||
# Look for similar patterns
|
||
print(f"\nSearching for similar patterns...")
|
||
cur.execute("SELECT codmat, denumire FROM nom_articole WHERE codmat LIKE 'CAF%' AND codmat IS NOT NULL")
|
||
results = cur.fetchall()
|
||
if results:
|
||
print(f" CAF* patterns found: {len(results)}")
|
||
for result in results[:5]: # Show first 5
|
||
print(f" {result[0]} - {result[1]}")
|
||
else:
|
||
print(f" No CAF* patterns found")
|
||
|
||
cur.execute("SELECT codmat, denumire FROM nom_articole WHERE codmat LIKE '%FILTR%' AND codmat IS NOT NULL")
|
||
results = cur.fetchall()
|
||
if results:
|
||
print(f" *FILTR* patterns found: {len(results)}")
|
||
for result in results[:5]: # Show first 5
|
||
print(f" {result[0]} - {result[1]}")
|
||
else:
|
||
print(f" No *FILTR* patterns found")
|
||
|
||
except Exception as e:
|
||
print(f"❌ Check failed: {e}")
|
||
|
||
def create_test_articles():
|
||
"""Create test articles CAF01 and FILTRU01 for testing"""
|
||
print("\n🔧 Creating test articles for package testing...")
|
||
|
||
try:
|
||
with oracledb.connect(user=user, password=password, dsn=dsn) as conn:
|
||
with conn.cursor() as cur:
|
||
|
||
# Check if they already exist
|
||
cur.execute("SELECT codmat FROM nom_articole WHERE codmat IN ('CAF01', 'FILTRU01')")
|
||
existing = [row[0] for row in cur.fetchall()]
|
||
|
||
articles_to_create = [
|
||
('CAF01', 'CAFEA TEST - Produs test pentru import web'),
|
||
('FILTRU01', 'FILTRU CAFEA TEST - Produs test pentru seturi')
|
||
]
|
||
|
||
created_count = 0
|
||
for codmat, denumire in articles_to_create:
|
||
if codmat not in existing:
|
||
try:
|
||
# Insert new article (using negative ID for test)
|
||
cur.execute("""
|
||
INSERT INTO nom_articole (
|
||
id_articol,
|
||
codmat,
|
||
denumire,
|
||
dep,
|
||
id_subgrupa,
|
||
cant_bax,
|
||
sters,
|
||
id_mod,
|
||
inactiv,
|
||
in_stoc,
|
||
in_crm,
|
||
dnf,
|
||
pretachctva,
|
||
taxa_reconditionare,
|
||
greutate
|
||
) VALUES (
|
||
-999999 - :seq, -- Unique negative ID
|
||
:codmat,
|
||
:denumire,
|
||
0, -- dep
|
||
1, -- id_subgrupa
|
||
1, -- cant_bax
|
||
0, -- sters
|
||
0, -- id_mod
|
||
0, -- inactiv
|
||
1, -- in_stoc
|
||
0, -- in_crm
|
||
0, -- dnf
|
||
0, -- pretachctva
|
||
0, -- taxa_reconditionare
|
||
0 -- greutate
|
||
)
|
||
""", {'seq': created_count, 'codmat': codmat, 'denumire': denumire})
|
||
created_count += 1
|
||
print(f" ✅ Created: {codmat}")
|
||
except Exception as e:
|
||
print(f" ❌ Failed to create {codmat}: {e}")
|
||
else:
|
||
print(f" ✅ Already exists: {codmat}")
|
||
|
||
if created_count > 0:
|
||
conn.commit()
|
||
print(f"✅ Successfully created {created_count} test articles")
|
||
else:
|
||
print(f"ℹ️ All test articles already exist")
|
||
|
||
except Exception as e:
|
||
print(f"❌ Create test articles failed: {e}")
|
||
|
||
def main():
|
||
print("🔍 nom_articole Analysis for P1-004 Testing")
|
||
print("=" * 50)
|
||
|
||
check_table_structure()
|
||
create_test_articles()
|
||
|
||
if __name__ == "__main__":
|
||
main() |