Skip to content

Commit

Permalink
fixup! Add unit test for cache_inputs_for_weather_report.
Browse files Browse the repository at this point in the history
  • Loading branch information
linabutler committed Feb 23, 2023
1 parent 6cf36e8 commit 88a0b1d
Showing 1 changed file with 35 additions and 1 deletion.
36 changes: 35 additions & 1 deletion tests/unit/providers/weather/backends/test_accuweather.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"""Unit tests for the AccuWeather backend module."""

import json
from typing import Any, Optional
from typing import Any, Optional, Tuple

import pytest
from httpx import AsyncClient, HTTPError, Request, Response
Expand Down Expand Up @@ -787,3 +787,37 @@ async def test_get_forecast_error(
await accuweather.get_forecast(mock_client, location_key)

assert str(accuweather_error.value) == expected_error_value


@pytest.mark.parametrize(
"cache_inputs_by_location",
[
(Location(country="US", region="CA", city="San Francisco", dma=807), None),
(
Location(region="CA", city="San Francisco", dma=807, postal_code="94105"),
None,
),
(
Location(
country="US",
region="CA",
city="San Francisco",
dma=807,
postal_code="94105",
),
b"US94105",
),
],
)
@pytest.mark.asyncio
async def test_cache_inputs_for_weather_report(
accuweather: AccuweatherBackend,
cache_inputs_by_location: Tuple[Location, Optional[bytes]],
) -> None:
"""Test that `cache_inputs_for_weather_report` computes the correct cache inputs when
given locations with various missing fields.
"""
cache_inputs: Optional[bytes] = accuweather.cache_inputs_for_weather_report(
cache_inputs_by_location[0]
)
assert cache_inputs == cache_inputs_by_location[1]

0 comments on commit 88a0b1d

Please sign in to comment.