78 lines
4.0 KiB
Python
78 lines
4.0 KiB
Python
import requests
|
|
from app import create_app
|
|
from app.models.user import User
|
|
from app.services.jwt_service import JWTService
|
|
|
|
app = create_app()
|
|
with app.app_context():
|
|
admin = User.query.filter_by(email='admin@edu-space.com').first()
|
|
token = JWTService.create_access_token(admin)
|
|
|
|
cookies = {'auth_token': token}
|
|
session = requests.Session()
|
|
session.cookies.update(cookies)
|
|
|
|
tests = [
|
|
# Dashboard y redirecciones
|
|
('GET /main/dashboard (redirect to /dashboard)', 'http://localhost:3000/main/dashboard', 200, ['Edu-Space Admin', 'Aulas Totales']),
|
|
('GET /dashboard', 'http://localhost:3000/dashboard', 200, ['Edu-Space Admin', 'Aulas Totales', 'Reservas de Hoy']),
|
|
|
|
# Classrooms
|
|
('GET /classrooms/list_classrooms', 'http://localhost:3000/classrooms/list_classrooms', 200, ['Aulas y Espacios', 'PB-01', 'Edificio Central']),
|
|
('GET /classrooms/list', 'http://localhost:3000/classrooms/list', 200, ['Aulas y Espacios']),
|
|
('GET /classrooms/add_classroom (Coupled)', 'http://localhost:3000/classrooms/add_classroom', 200, ['Add Classroom', 'Classroom Information']),
|
|
('GET /classrooms/add', 'http://localhost:3000/classrooms/add', 200, ['Add Classroom']),
|
|
|
|
# Schedule
|
|
('GET /schedule/calendar_view', 'http://localhost:3000/schedule/calendar_view', 200, ['Reservations Calendar', 'calendar']),
|
|
('GET /schedule/calendar_data (JSON Feed)', 'http://localhost:3000/schedule/calendar_data', 200, None),
|
|
('GET /schedule/today', 'http://localhost:3000/schedule/today', 200, ['Reservas']),
|
|
('GET /schedule/list_reservations', 'http://localhost:3000/schedule/list_reservations', 200, ['Listado de Reservas']),
|
|
('GET /schedule/add_reservation (Coupled)', 'http://localhost:3000/schedule/add_reservation', 200, ['New Reservation', 'Detalles de la Reserva']),
|
|
('GET /schedule/add', 'http://localhost:3000/schedule/add', 200, ['New Reservation']),
|
|
|
|
# Buildings
|
|
('GET /buildings/list_buildings (Coupled)', 'http://localhost:3000/buildings/list_buildings', 200, ['Gestión de Edificios', 'Edificio Central']),
|
|
('GET /buildings', 'http://localhost:3000/buildings', 200, ['Gestión de Edificios']),
|
|
('GET /buildings/add_building', 'http://localhost:3000/buildings/add_building', 200, ['Nuevo Edificio']),
|
|
|
|
# Admin Features
|
|
('GET /admin/google_sheets_import (Coupled)', 'http://localhost:3000/admin/google_sheets_import', 200, ['Google Sheets', 'Official Schedule Board']),
|
|
('GET /admin/import', 'http://localhost:3000/admin/import', 200, ['Google Sheets']),
|
|
('GET /admin/occupancy_metrics (Coupled)', 'http://localhost:3000/admin/occupancy_metrics', 200, ['Ocupación', 'Métricas']),
|
|
('GET /admin/occupancy-metrics', 'http://localhost:3000/admin/occupancy-metrics', 200, ['Ocupación'])
|
|
]
|
|
|
|
all_passed = True
|
|
print('=== EJECUTANDO SUITE DE PRUEBAS DE INTEGRACION BFF NODE.JS ===')
|
|
for name, url, expected_status, expected_texts in tests:
|
|
r = session.get(url, allow_redirects=True)
|
|
status_ok = r.status_code == expected_status
|
|
text_ok = True
|
|
if 'En Construcción' in r.text:
|
|
text_ok = False
|
|
print(f' [FAIL] Fallback "En Construcción" encountered in {url}')
|
|
if expected_texts:
|
|
for t in expected_texts:
|
|
if t.lower() not in r.text.lower():
|
|
text_ok = False
|
|
print(f' [FAIL] Expected text "{t}" not found in {url}')
|
|
if expected_texts is None: # JSON check
|
|
data = r.json()
|
|
text_ok = isinstance(data, list) and len(data) > 0
|
|
if not text_ok:
|
|
print(f' [FAIL] Expected non-empty JSON list in {url}')
|
|
|
|
if status_ok and text_ok:
|
|
print(f'[PASS] {name} -> Status: {r.status_code} OK')
|
|
else:
|
|
all_passed = False
|
|
print(f'[FAIL] {name} -> Status: {r.status_code} FAIL')
|
|
|
|
print('===============================================================')
|
|
if all_passed:
|
|
print('TODAS LAS PRUEBAS DE INTEGRACION PASARON SATISFACTORIAMENTE (100% OK)')
|
|
else:
|
|
print('SE ENCONTRARON FALLOS EN LA SUITE DE PRUEBAS')
|
|
print('===============================================================')
|