Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Jan 22, 2025
1 parent b16bf30 commit b963026
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 15 deletions.
12 changes: 5 additions & 7 deletions tests/awqms/test_e2e.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,9 @@
awqms_datastreams,
awqms_schedule,
)
from userCode.awqms.types import (
ALL_RELEVANT_STATIONS
)
from userCode.awqms.types import ALL_RELEVANT_STATIONS
from userCode.env import API_BACKEND_URL
from userCode.helper_classes import (
get_datastream_time_range
)
from userCode.helper_classes import get_datastream_time_range

from ..lib import (
wipe_datastreams,
Expand Down Expand Up @@ -135,7 +131,9 @@ def test_full_pipeline():

# Verify updated time range
update_range = get_datastream_time_range(first_datastream_iotid)
assert update_range.start < update_range.end, "Updated range start must be before end"
assert (
update_range.start < update_range.end
), "Updated range start must be before end"
assert update_range.start == range.start, "Start date should not change on update"
assert update_range.end >= range.end, "End date should advance or stay same"

Expand Down
20 changes: 12 additions & 8 deletions tests/awqms/test_lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,12 @@
import tempfile
from unittest.mock import patch, Mock

from userCode.awqms.lib import read_csv, fetch_station, fetch_observations, fetch_observation_ids
from userCode.awqms.lib import (
read_csv,
fetch_station,
fetch_observations,
fetch_observation_ids,
)


@pytest.fixture
Expand Down Expand Up @@ -94,22 +99,21 @@ def test_fetch_observations_invalid_json(mock_shelve_cache_cls):
def test_fetch_observation_ids():
datastream_id = "12005-ORDEQ-2704"
api_url = f"https://localhost:8080/FROST-Server/v1.1/Datastreams('{datastream_id}')/Observations"

mock_response_1 = {
"value": [{"@iot.id": 1}, {"@iot.id": 2}],
"@iot.nextLink": f"{api_url}?$skip=2"
"@iot.nextLink": f"{api_url}?$skip=2",
}

mock_response_2 = {"value": [{"@iot.id": 3}, {"@iot.id": 4}]}

with patch("userCode.awqms.lib.requests.get") as mock_get:

mock_get.side_effect = [
Mock(status_code=200, json=Mock(return_value=mock_response_1)),
Mock(status_code=200, json=Mock(return_value=mock_response_2))
Mock(status_code=200, json=Mock(return_value=mock_response_2)),
]

result = fetch_observation_ids(datastream_id)

assert result == {1, 2, 3, 4}
assert mock_get.call_count == 2

0 comments on commit b963026

Please sign in to comment.