feat: add redis cache

This commit is contained in:
2024-08-21 22:53:50 +03:00
parent 0638fb8d50
commit d3ef03a6a0
19 changed files with 194 additions and 24 deletions

View File

@@ -8,12 +8,12 @@ from gallery.painting.gismeteo.mock import GISMETEO_MOCK_DATA
@pytest.fixture(name="gismeteo_api", scope="module")
def gismeteo_api_fixture() -> GismeteoApi:
class MockSource:
async def request(self, endpoint: str):
return GISMETEO_MOCK_DATA.get_html(endpoint.split("/")[-1])
api = GismeteoApi()
async def _request(endpoint: str) -> str:
return GISMETEO_MOCK_DATA.get_html(endpoint.split("/")[-1])
api._request = _request
api.SOURCE = MockSource()
return api

View File

@@ -8,16 +8,16 @@ from gallery.painting.matchtv.mock import MATCHTV_MOCK_DATA
@pytest.fixture(name="matchtv_api", scope="module")
def matchtv_api_fixture() -> MatchTvApi:
class MockSource:
async def request(self, endpoint: str):
return MATCHTV_MOCK_DATA.get_html(endpoint.split("/")[1])
api = MatchTvApi()
async def _request(endpoint: str) -> str:
return MATCHTV_MOCK_DATA.get_html(endpoint.split("/")[1])
api._request = _request
api.SOURCE = MockSource()
return api
async def test_channel(matchtv_api: MatchTvApi):
result = await matchtv_api.get_channel_schedule("matchtv", datetime.date.today())
result = await matchtv_api.get_channel_schedule("test", datetime.date.today())
assert result is not None
assert len(result.values) > 0