|
|
|
""" |
|
Integration test for APScheduler with Flask application. |
|
Tests the actual application startup and scheduler initialization. |
|
""" |
|
|
|
import sys |
|
import os |
|
import subprocess |
|
import time |
|
from pathlib import Path |
|
|
|
def test_app_startup_with_scheduler(): |
|
"""Test that the Flask application starts with APScheduler visible.""" |
|
try: |
|
|
|
project_dir = Path(__file__).parent |
|
os.chdir(project_dir) |
|
|
|
|
|
print("π Starting Flask application with APScheduler...") |
|
process = subprocess.Popen( |
|
[sys.executable, "start_app.py"], |
|
stdout=subprocess.PIPE, |
|
stderr=subprocess.STDOUT, |
|
text=True, |
|
bufsize=1, |
|
universal_newlines=True |
|
) |
|
|
|
|
|
startup_timeout = 30 |
|
start_time = time.time() |
|
|
|
scheduler_found = False |
|
verification_found = False |
|
while time.time() - start_time < startup_timeout: |
|
output = process.stdout.readline() |
|
if output: |
|
print(output.strip()) |
|
|
|
|
|
if "Initializing APScheduler" in output: |
|
scheduler_found = True |
|
print("β
APScheduler initialization message found!") |
|
|
|
|
|
if "β
APScheduler initialized successfully" in output: |
|
verification_found = True |
|
print("β
APScheduler verification message found!") |
|
|
|
|
|
if "running on http" in output.lower(): |
|
break |
|
|
|
|
|
process.terminate() |
|
process.wait(timeout=10) |
|
|
|
if scheduler_found and verification_found: |
|
print("β
APScheduler is visible during application startup") |
|
return True |
|
else: |
|
print("β APScheduler messages not found in startup logs") |
|
return False |
|
|
|
except Exception as e: |
|
print(f"β Error testing app startup: {e}") |
|
return False |
|
|
|
def main(): |
|
"""Main integration test function.""" |
|
print("π Testing APScheduler integration with Flask application...") |
|
print("=" * 60) |
|
|
|
success = test_app_startup_with_scheduler() |
|
|
|
print("\n" + "=" * 60) |
|
if success: |
|
print("π Integration test passed! APScheduler is working in the Flask app.") |
|
else: |
|
print("β οΈ Integration test failed. APScheduler may not be properly configured.") |
|
|
|
return success |
|
|
|
if __name__ == "__main__": |
|
success = main() |
|
sys.exit(0 if success else 1) |