Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tests suite #120

Merged
merged 18 commits into from
Apr 22, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
test: Add tests for get_specific_parameter
  • Loading branch information
lahdjirayhan committed Apr 22, 2022
commit 29995e56083cee06e4805025215ad141d0197784
29 changes: 29 additions & 0 deletions tests/test_get_specific_parameter.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import numpy
import pytest

from utils import api


@pytest.mark.vcr
def test_return_value():
result = api.get_specific_parameter("london", "aqi")

assert isinstance(result, float)


@pytest.mark.vcr
def test_nonexistent_requested_param():
# NOTE, QUESTION (lahdjirayhan)
# Should nonexistent param return nan or raise Exception? (see code)
BAD_PARAM_NAME = "bad_param_name"
result = api.get_specific_parameter("london", BAD_PARAM_NAME)
assert numpy.isnan(result)


@pytest.mark.vcr
def test_bad_city():
with pytest.raises(Exception, match="no known AQI station"):
api.get_specific_parameter("a definitely nonexistent city", "aqi")

with pytest.raises(Exception):
api.get_specific_parameter("", "aqi")