dragndrop_hld/backend/test_access_points.py

85 lines
2.1 KiB
Python
Raw Normal View History

"""
Test upload script for Access Points
Uploads first 10 records to test the field name fix (isLocked -> locked)
"""
import os
import sys
from pathlib import Path
from verofy_uploader import VerofyUploader
# Get credentials from environment
EMAIL = os.getenv("VEROFY_USER")
PASSWORD = os.getenv("VEROFY_PASS")
if not EMAIL or not PASSWORD:
print("❌ Missing environment variables: Please set VEROFY_USER and VEROFY_PASS")
sys.exit(1)
# Configuration
MAP_ID = 16950
TEMP_DIR = Path("../temp")
LIMIT = 10 # Upload only first 10 records
print("=" * 60)
print("VEROFY API ACCESS POINTS TEST")
print("=" * 60)
print(f"Map ID: {MAP_ID}")
print(f"Temp Directory: {TEMP_DIR}")
print(f"Limit: {LIMIT} records")
print(f"Email: {EMAIL}")
print(f"Fix Applied: isLocked → locked")
print("=" * 60)
print()
# Initialize uploader
uploader = VerofyUploader(EMAIL, PASSWORD)
# Authenticate
if not uploader.authenticate():
print("❌ Authentication failed")
sys.exit(1)
results = {
"success": True,
"uploaded": {},
"errors": []
}
# Test access points
print("📤 Testing access_points.shp...")
shapefile_path = TEMP_DIR / "access_points.shp"
if shapefile_path.exists():
try:
count, errors = uploader._upload_access_points(shapefile_path, MAP_ID, LIMIT)
results["uploaded"]["access_points.shp"] = count
if errors:
results["errors"].extend(errors)
print(f"✅ Uploaded {count} access points")
except Exception as e:
error_msg = f"Error uploading access_points.shp: {str(e)}"
print(f"{error_msg}")
results["errors"].append(error_msg)
results["success"] = False
else:
print("⚠️ access_points.shp not found")
# Display results
print()
print("=" * 60)
print("ACCESS POINTS TEST RESULTS")
print("=" * 60)
print(f"Success: {results['success']}")
print()
print("Uploaded counts:")
for shapefile, count in results.get('uploaded', {}).items():
print(f" {shapefile}: {count} records")
if results.get('errors'):
print()
print("Errors encountered:")
for error in results['errors']:
print(f" - {error}")
print("=" * 60)