Tests cover providers, dedup, Telegram, scoring, main runner, and Airbnb stubs. Ticketmaster and SeatGeek use configurable lat/lon/radius (Thornhill default). Pipeline filters noise listings, merges same-day sports duplicates, optional MIN_ALERT_SCORE, and Telegram severity summary. Made-with: Cursor
36 lines
1.1 KiB
Python
36 lines
1.1 KiB
Python
"""Tests for Airbnb authentication / storage state management."""
|
|
|
|
from pathlib import Path
|
|
from unittest.mock import MagicMock, patch
|
|
|
|
import pytest
|
|
|
|
from src.airbnb.auth import load_authenticated_context, DEFAULT_STATE_PATH
|
|
|
|
|
|
class TestLoadAuthenticatedContext:
|
|
def test_raises_when_state_file_missing(self, tmp_path):
|
|
browser = MagicMock()
|
|
missing_path = tmp_path / "nonexistent.json"
|
|
|
|
with pytest.raises(FileNotFoundError, match="No saved session"):
|
|
load_authenticated_context(browser, state_path=missing_path)
|
|
|
|
def test_loads_context_when_state_exists(self, tmp_path):
|
|
state_path = tmp_path / "state.json"
|
|
state_path.write_text("{}")
|
|
|
|
mock_context = MagicMock()
|
|
mock_browser = MagicMock()
|
|
mock_browser.new_context.return_value = mock_context
|
|
|
|
ctx = load_authenticated_context(mock_browser, state_path=state_path)
|
|
|
|
mock_browser.new_context.assert_called_once_with(
|
|
storage_state=str(state_path)
|
|
)
|
|
assert ctx is mock_context
|
|
|
|
def test_default_state_path(self):
|
|
assert DEFAULT_STATE_PATH == Path("state.json")
|