File: test_errors.py

package info (click to toggle)
python-geoip 1.3.2-6
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 344 kB
  • sloc: ansic: 753; python: 248; makefile: 5
file content (54 lines) | stat: -rw-r--r-- 1,663 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import GeoIP
from nose.tools import assert_equal


def test_errors():
    # The intent of these tests is to make sure there are no segfaults.
    # Most of the lookups are invalid. Unfortunately the API rarely throws
    # exceptions.
    gi = GeoIP.open("tests/data/GeoIP.dat", GeoIP.GEOIP_STANDARD)

    assert_equal(gi.org_by_addr('1.1.1.1'), None)

    assert_equal(gi.country_code_by_name('1.1.1.1'), None)

    assert_equal(gi.country_name_by_name('1.1.1.1'), None)

    assert_equal(gi.country_code_by_addr('1.1.1.1'), None)

    assert_equal(gi.country_name_by_addr('1.1.1.1'), None)

    assert_equal(gi.name_by_addr('1.1.1.1'), None)

    assert_equal(gi.name_by_name('1.1.1.1'), None)

    assert_equal(gi.org_by_addr('1.1.1.1'), None)

    assert_equal(gi.org_by_name('1.1.1.1'), None)

    assert_equal(gi.region_by_addr('1.1.1.1'), None)

    assert_equal(gi.region_by_name('1.1.1.1'), None)
    assert_equal(gi.record_by_addr('1.1.1.1'), None)

    assert_equal(gi.record_by_name('1.1.1.1'), None)

    assert_equal(gi.range_by_ip('1.1.1.1'), ('0.0.0.0', '12.87.117.255'))

    assert_equal(gi.last_netmask(), 5)

    assert_equal(gi.country_code_by_name_v6('1.1.1.1'), None)

    assert_equal(gi.country_name_by_name_v6('1.1.1.1'), None)

    assert_equal(gi.country_code_by_addr_v6('1.1.1.1'), None)

    assert_equal(gi.country_name_by_addr_v6('1.1.1.1'), None)

    assert_equal(gi.enable_teredo(-100), 1)
    assert_equal(gi.teredo(), 0)
    assert_equal(gi.id_by_addr('1.1.1.1'), 0)
    assert_equal(gi.id_by_name('1.1.1.1'), 0)
    assert_equal(gi.record_by_addr_v6('1.1.1.1'), None)

    assert_equal(gi.record_by_name_v6('1.1.1.1'), None)