oedb-backend/test_osm_cal_api.py

48 lines
1.3 KiB
Python
Raw Normal View History

2025-09-26 11:57:54 +02:00
#!/usr/bin/env python3
"""
Test script for the OSM Calendar extractor with different parameter combinations.
This script tests the functionality of the osm_cal.py script with various
combinations of max_events and offset parameters.
"""
import sys
import os
from extractors.osm_cal import main as osm_cal_main
def run_test(max_events, offset):
"""
Run the OSM Calendar extractor with the specified parameters.
Args:
max_events (int): Maximum number of events to insert
offset (int): Number of events to skip from the beginning of the RSS feed
"""
print(f"\n=== Testing with max_events={max_events}, offset={offset} ===")
osm_cal_main(max_events=max_events, offset=offset)
print("=== Test completed ===\n")
def main():
"""
Run tests with different parameter combinations.
"""
print("Starting OSM Calendar API tests...")
# Test 1: Default parameters (max_events=1, offset=0)
run_test(1, 0)
# Test 2: Multiple events (max_events=3, offset=0)
run_test(3, 0)
# Test 3: With offset (max_events=2, offset=2)
run_test(2, 2)
# Test 4: Large offset (max_events=1, offset=10)
run_test(1, 10)
# Test 5: Large max_events (max_events=10, offset=0)
run_test(10, 0)
print("All tests completed.")
if __name__ == "__main__":
main()