bmc_hub/keepforlater/test_vtiger_modules.py
Christian a604a3cc44 Add comprehensive test suite for vTiger integration and ticket module
- Implemented test scripts for vTiger account retrieval, contact data, and modules.
- Created a detailed test suite for the ticket module, covering database schema validation, ticket number generation, prepaid card constraints, and service logic.
- Added tests for vTiger field inspection and various queries related to accounts and sales orders.
- Introduced SQL migration scripts for the ALSO Cloud Billing foundation, including import jobs, lines, and mapping tables with necessary constraints and indices.
- Enhanced workflow columns in the import lines table to support matching and validation timestamps.
2026-06-20 03:29:51 +02:00

59 lines
2.0 KiB
Python

"""
Test vTiger modules and queries
"""
import asyncio
import sys
sys.path.insert(0, '/app')
from app.services.vtiger_service import get_vtiger_service
async def test_vtiger():
vtiger = get_vtiger_service()
# Test connection
print("🔑 Testing vTiger connection...")
connected = await vtiger.test_connection()
if not connected:
print("❌ Connection failed!")
return
print("\n" + "="*60)
print("Testing different module queries for account 3x760")
print("="*60)
# Test various queries
queries = [
# Try different module names
("Services", "SELECT * FROM Services WHERE account_id='3x760' LIMIT 5;"),
("Products", "SELECT * FROM Products WHERE account_id='3x760' LIMIT 5;"),
("SalesOrder", "SELECT * FROM SalesOrder WHERE account_id='3x760' LIMIT 5;"),
("Invoice", "SELECT * FROM Invoice WHERE account_id='3x760' LIMIT 5;"),
("Quotes", "SELECT * FROM Quotes WHERE account_id='3x760' LIMIT 5;"),
("Contacts", "SELECT * FROM Contacts WHERE account_id='3x760' LIMIT 5;"),
# Try without account filter to see structure
("SalesOrder (all)", "SELECT * FROM SalesOrder LIMIT 2;"),
("Invoice (all)", "SELECT * FROM Invoice LIMIT 2;"),
]
for name, query in queries:
print(f"\n📋 Testing: {name}")
print(f"Query: {query}")
try:
results = await vtiger.query(query)
if results:
print(f"✅ Found {len(results)} records")
if len(results) > 0:
print(f"Sample keys: {list(results[0].keys())[:10]}")
# Show first record
print("\nFirst record:")
for key, value in list(results[0].items())[:15]:
print(f" {key}: {value}")
else:
print("⚠️ No results")
except Exception as e:
print(f"❌ Error: {e}")
if __name__ == "__main__":
asyncio.run(test_vtiger())