import os import csv import sys from pathlib import Path sys.path.insert(0, str(Path(__file__).resolve().parent.parent)) from gps import dms_to_decimal, extract_gps_simple, find_nearest_gps, load_gps_log def test_dms_to_decimal(): """Validates mathematical tuple translations natively scaling numeric ranges.""" # Standard DMS tuple format mapping tup = ((34, 1), (3, 1), (8, 1)) val_n = dms_to_decimal(tup, 'N') assert abs(val_n - 34.052222) < 0.0001, "Positive DMS conversion calculation failed natively." val_w = dms_to_decimal(tup, 'W') assert val_w < 0, "Negative directional scaling failed natively for longitude conversion." # Flat number failure mode test bridging mapping val_flat = dms_to_decimal(34.0522, 'N') assert val_flat == 34.0522, "Non-standard flat EXIF mapping conversion calculation failed natively." print("test_dms_to_decimal passed.") def test_load_gps_log(): """Verify loading constraints targeting dynamic IO boundaries via mock structural datasets.""" export_path = Path("test_gps_log.csv") with export_path.open('w', newline='', encoding='utf-8') as f: writer = csv.DictWriter(f, fieldnames=['timestamp', 'latitude', 'longitude']) writer.writeheader() writer.writerow({'timestamp': '2026-04-05T12:00:00', 'latitude': '34.0', 'longitude': '-118.0'}) writer.writerow({'timestamp': '2026-04-05T12:05:00', 'latitude': '34.1', 'longitude': '-118.1'}) data = load_gps_log(export_path) assert len(data) == 2, "Array length generation bounding issue." assert data[0]['latitude'] == 34.0, "Parsing type casting boundary issue resolving floats physically." export_path.unlink() print("test_load_gps_log passed.") def test_find_nearest_gps(): """Assert minimum bridging bounding gap searches properly evaluate chronology distances natively.""" mock_log = [ {'timestamp': '2026-04-05T12:00:00', 'latitude': 34.0, 'longitude': -118.0}, {'timestamp': '2026-04-05T12:05:00', 'latitude': 34.1, 'longitude': -118.1}, {'timestamp': '2026-04-05T12:10:00', 'latitude': 34.2, 'longitude': -118.2} ] # Target precisely in between index 0 and 1, closer to 1 target_ts = '2026-04-05T12:02:35' nearest = find_nearest_gps(target_ts, mock_log) assert nearest['latitude'] == 34.1, "Closest relative bounding gap calculation routing execution structurally failed natively." print("test_find_nearest_gps passed.") if __name__ == "__main__": test_dms_to_decimal() test_load_gps_log() test_find_nearest_gps() print("ALL GPS TESTS PASSED")