import os import sys import pytest import tempfile sys.path.insert(0, os.path.join(os.path.dirname(__file__), "..")) @pytest.fixture def ics_sample(): """Return a sample ICS string with 2 events.""" return """BEGIN:VCALENDAR VERSION:2.0 PRODID:-//Test BEGIN:VEVENT UID:evt-001@test.com DTSTAMP:20240101T000000Z DTSTART:20240101T100000Z DTEND:20240101T110000Z SUMMARY:Event One END:VEVENT BEGIN:VEVENT UID:evt-002@test.com DTSTAMP:20240101T000000Z DTSTART:20240102T100000Z DTEND:20240102T110000Z SUMMARY:Event Two END:VEVENT END:VCALENDAR""" @pytest.fixture def ics_sample_modified(): """Return ICS with one modified event and one new event.""" return """BEGIN:VCALENDAR VERSION:2.0 PRODID:-//Test BEGIN:VEVENT UID:evt-001@test.com DTSTAMP:20240101T000000Z DTSTART:20240101T100000Z DTEND:20240101T120000Z SUMMARY:Event One Modified END:VEVENT BEGIN:VEVENT UID:evt-003@test.com DTSTAMP:20240101T000000Z DTSTART:20240103T100000Z DTEND:20240103T110000Z SUMMARY:Event Three END:VEVENT END:VCALENDAR""" @pytest.fixture def tmp_db(): """Return a temp database path.""" with tempfile.NamedTemporaryFile(suffix=".db", delete=False) as f: path = f.name yield path if os.path.exists(path): os.unlink(path) @pytest.fixture(autouse=True) def env_vars(monkeypatch): """Set up required env vars for config tests.""" monkeypatch.setenv("ICS_URL", "https://example.com/cal.ics") monkeypatch.setenv("BAIKAL_URL", "https://baikal.com/dav.php/calendars/user/cal/") monkeypatch.setenv("BAIKAL_USER", "user") monkeypatch.setenv("BAIKAL_PASS", "pass") monkeypatch.setenv("SYNC_FREQUENCY", "5")