Exemplo n.º 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)
Exemplo n.º 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,
        )
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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()
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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()
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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)
    )
Exemplo n.º 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)
    )
Exemplo n.º 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)
    )