diff --git a/tests/unit_tests.py b/tests/unit_tests.py index 6c5e7cc..bf9f072 100644 --- a/tests/unit_tests.py +++ b/tests/unit_tests.py @@ -13,8 +13,8 @@ ) from nose.tools import assert_raises, eq_ as eq, assert_true, assert_is_none, assert_in from parameterized import parameterized -from hypothesis import given, settings -from hypothesis.strategies import sampled_from, none, one_of, text +from hypothesis import given, settings, assume +from hypothesis.strategies import sampled_from, none, one_of, text, integers @httpretty.activate @@ -53,6 +53,22 @@ def test_get_timezone_for_ip_empty_val(ip, service): ) +@httpretty.activate +@given( + one_of(IP_ADDRESSES, none()), + sampled_from(FAKE_SERVICES), + integers(min_value=400, max_value=599), +) +@settings(max_examples=20) +def test_get_timezone_for_ip_doesnt_raise(ip, service, status): + assume(status in httpretty.http.STATUSES) + fake_queue = mock.Mock() + setup_basic_api_response(status=status) + assert_is_none( + tzupdate.get_timezone_for_ip(ip=ip, service=service, queue_obj=fake_queue) + ) + + @mock.patch("tzupdate.os.unlink") @mock.patch("tzupdate.os.symlink") @mock.patch("tzupdate.os.path.isfile")