Пример #1
0
def test_resolved(aws_ip_range_data, test_ip_range_cache, test_aws_ip, app):
    ipresolver = IPResolver(app)
    ipresolver.amazon_ranges = test_ip_range_cache["all_amazon"]
    ipresolver.sync_token = test_ip_range_cache["sync_token"]

    assert ipresolver.resolve_ip(test_aws_ip) == ResolvedLocation(
        provider="aws",
        service=None,
        sync_token=123456789,
        country_iso_code=None)
    assert ipresolver.resolve_ip("10.0.0.2") == ResolvedLocation(
        provider="aws",
        service=None,
        sync_token=123456789,
        country_iso_code=None)
    assert ipresolver.resolve_ip("6.0.0.2") == ResolvedLocation(
        provider="aws",
        service=None,
        sync_token=123456789,
        country_iso_code=u"US")
    assert ipresolver.resolve_ip("1.2.3.4") == ResolvedLocation(
        provider="internet",
        service=u"US",
        sync_token=123456789,
        country_iso_code=u"US")
    assert ipresolver.resolve_ip("127.0.0.1") == ResolvedLocation(
        provider="internet",
        service=None,
        sync_token=123456789,
        country_iso_code=None)
Пример #2
0
def test_resolved(aws_ip_range_data, test_ip_range_cache, test_aws_ip, app):
    ipresolver = IPResolver(app)
    ipresolver.amazon_ranges = test_ip_range_cache['all_amazon']
    ipresolver.sync_token = test_ip_range_cache['sync_token']

    assert ipresolver.resolve_ip(test_aws_ip) == ResolvedLocation(
        provider='aws',
        service=None,
        sync_token=123456789,
        country_iso_code=None)
    assert ipresolver.resolve_ip('10.0.0.2') == ResolvedLocation(
        provider='aws',
        service=None,
        sync_token=123456789,
        country_iso_code=None)
    assert ipresolver.resolve_ip('6.0.0.2') == ResolvedLocation(
        provider='aws',
        service=None,
        sync_token=123456789,
        country_iso_code=u'US')
    assert ipresolver.resolve_ip('1.2.3.4') == ResolvedLocation(
        provider='internet',
        service=u'US',
        sync_token=123456789,
        country_iso_code=u'US')
    assert ipresolver.resolve_ip('127.0.0.1') == ResolvedLocation(
        provider='internet',
        service=None,
        sync_token=123456789,
        country_iso_code=None)