Пример #1
0
def test_get_timezone_for_ip(ip, service):
    fake_queue = mock.Mock()
    setup_basic_api_response()
    tzupdate.get_timezone_for_ip(ip=ip, service=service, queue_obj=fake_queue)

    if ip is not None:
        assert_in(ip, httpretty.last_request().path)

    fake_queue.put.assert_called_once_with(FAKE_TIMEZONE)
Пример #2
0
def test_get_timezone_for_ip_empty_val(ip, service):
    fake_queue = mock.Mock()
    setup_basic_api_response(empty_val=True)
    with assert_raises(tzupdate.TimezoneAcquisitionError):
        tzupdate.get_timezone_for_ip(
            ip=ip,
            service=service,
            queue_obj=fake_queue,
        )
Пример #3
0
def test_get_timezone_for_ip_doesnt_raise(ip, service, status):
    fake_queue = mock.Mock()
    setup_basic_api_response(status=status)
    assert (tzupdate.get_timezone_for_ip(
        ip_addr=ip, service=service, queue_obj=fake_queue) is None)
Пример #4
0
def test_get_timezone_for_ip_empty_val(ip, service):
    fake_queue = mock.Mock()
    setup_basic_api_response(empty_val=True)
    assert (tzupdate.get_timezone_for_ip(
        ip_addr=ip, service=service, queue_obj=fake_queue) is None)
Пример #5
0
def test_get_timezone_for_ip_api_error_types(error_body, expected_exception):
    setup_basic_api_response(body=json.dumps(error_body))
    with assert_raises(expected_exception):
        tzupdate.get_timezone_for_ip()
Пример #6
0
def test_get_timezone_for_ip_explicit(ip_octets):
    setup_basic_api_response()
    ip_addr = '.'.join(map(str, ip_octets))
    got_timezone = tzupdate.get_timezone_for_ip(ip_addr)
    eq(got_timezone, FAKE_TIMEZONE)
Пример #7
0
def test_get_timezone_for_ip_none():
    setup_basic_api_response()
    got_timezone = tzupdate.get_timezone_for_ip()
    eq(got_timezone, FAKE_TIMEZONE)
Пример #8
0
def test_get_timezone_for_ip_api_error_types(error_body, expected_exception):
    setup_basic_api_response(body=json.dumps(error_body))
    with assert_raises(expected_exception):
        tzupdate.get_timezone_for_ip()
Пример #9
0
def test_get_timezone_for_ip_explicit(ip_octets):
    setup_basic_api_response()
    ip_addr = '.'.join(map(str, ip_octets))
    got_timezone = tzupdate.get_timezone_for_ip(ip_addr)
    eq(got_timezone, FAKE_TIMEZONE)
Пример #10
0
def test_get_timezone_for_ip_none():
    setup_basic_api_response()
    got_timezone = tzupdate.get_timezone_for_ip()
    eq(got_timezone, FAKE_TIMEZONE)
Пример #11
0
def test_get_timezone_for_ip_doesnt_raise(ip, service, status):
    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)
    )
Пример #12
0
def test_get_timezone_for_ip_empty_val(ip, service):
    fake_queue = mock.Mock()
    setup_basic_api_response(empty_val=True)
    assert_is_none(
        tzupdate.get_timezone_for_ip(ip=ip, service=service, queue_obj=fake_queue)
    )
Пример #13
0
def test_get_timezone_for_ip_empty_resp(ip, service):
    fake_queue = mock.Mock()
    setup_basic_api_response(empty_resp=True)
    assert_is_none(
        tzupdate.get_timezone_for_ip(ip=ip, service=service, queue_obj=fake_queue)
    )