49 lines
2.2 KiB
Python
49 lines
2.2 KiB
Python
import io
|
|
import sys
|
|
import urllib.request
|
|
import json
|
|
import ssl
|
|
|
|
if sys.platform == 'win32':
|
|
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8', errors='replace')
|
|
sys.stderr = io.TextIOWrapper(sys.stderr.buffer, encoding='utf-8', errors='replace')
|
|
|
|
ctx = ssl.create_default_context()
|
|
ctx.check_hostname = False
|
|
ctx.verify_mode = ssl.CERT_NONE
|
|
|
|
API_URL = "https://pacifictrans.almeira.com.co"
|
|
|
|
print("1. Probando geocodificacion inversa satelital en Cali...")
|
|
req_cali = urllib.request.Request(f"{API_URL}/api/geo/reverse?lat=3.4215&lng=-76.5320")
|
|
try:
|
|
with urllib.request.urlopen(req_cali, context=ctx, timeout=10) as res:
|
|
data = json.loads(res.read().decode("utf-8"))
|
|
print(f" [OK] Cali geocodificado: {data.get('address')} | Ciudad: {data.get('city')}")
|
|
assert data.get('success') is True
|
|
except Exception as e:
|
|
print(" Aviso / Error:", e)
|
|
|
|
print("\n2. Probando geocodificacion inversa satelital en Buenaventura...")
|
|
req_bv = urllib.request.Request(f"{API_URL}/api/geo/reverse?lat=3.8820&lng=-77.0250")
|
|
try:
|
|
with urllib.request.urlopen(req_bv, context=ctx, timeout=10) as res:
|
|
data = json.loads(res.read().decode("utf-8"))
|
|
print(f" [OK] Buenaventura geocodificado: {data.get('address')} | Ciudad: {data.get('city')}")
|
|
assert data.get('success') is True
|
|
except Exception as e:
|
|
print(" Aviso / Error:", e)
|
|
|
|
print("\n3. Verificando campos de direccion y botones GPS en index.html...")
|
|
req_html = urllib.request.Request(f"{API_URL}/")
|
|
with urllib.request.urlopen(req_html, context=ctx, timeout=10) as res:
|
|
html = res.read().decode("utf-8")
|
|
assert "freight-pickup-address" in html, "Falta freight-pickup-address"
|
|
assert "freight-delivery-address" in html, "Falta freight-delivery-address"
|
|
assert "btn-freight-gps-pickup" in html, "Falta btn-freight-gps-pickup"
|
|
assert "btn-freight-gps-delivery" in html, "Falta btn-freight-gps-delivery"
|
|
assert "btn-native-gps-cali" in html, "Falta btn-native-gps-cali"
|
|
print(" [OK] Todos los campos de direccion y botones GPS de ubicacion actual estan activos en la interfaz.")
|
|
|
|
print("\n[OK] Verificacion de direccion por ubicacion actual completada exitosamente.")
|