core/tests/components/nextbus/conftest.py

39 lines
1.2 KiB
Python
Raw Normal View History

2023-09-19 15:10:29 +00:00
"""Test helpers for NextBus tests."""
from unittest.mock import MagicMock
import pytest
@pytest.fixture
def mock_nextbus_lists(mock_nextbus: MagicMock) -> MagicMock:
"""Mock all list functions in nextbus to test validate logic."""
instance = mock_nextbus.return_value
instance.get_agency_list.return_value = {
"agency": [{"tag": "sf-muni", "title": "San Francisco Muni"}]
}
instance.get_route_list.return_value = {
"route": [{"tag": "F", "title": "F - Market & Wharves"}]
}
instance.get_route_config.return_value = {
"route": {
"stop": [
{"tag": "5650", "title": "Market St & 7th St"},
{"tag": "5651", "title": "Market St & 7th St"},
# Error case test. Duplicate title with no unique direction
{"tag": "5652", "title": "Market St & 7th St"},
2023-09-19 15:10:29 +00:00
],
"direction": [
{
"name": "Outbound",
"stop": [{"tag": "5650"}],
},
{
"name": "Inbound",
"stop": [{"tag": "5651"}],
},
],
}
}
return instance