@@ -14,6 +14,12 @@ def testinvaliddatabase():
1414 except ValueError as e :
1515 assert "The database file does not seem to exist." == str (e )
1616
17+ def testfunctionexist ():
18+ database = IP2Location .IP2Location (ipv4database )
19+ functions_list = ['open' , 'close' , 'get_all' , 'get_country_short' , 'get_country_long' , 'get_region' , 'get_city' , 'get_latitude' , 'get_longitude' , 'get_isp' , 'get_domain' , 'get_zipcode' , 'get_timezone' , 'get_netspeed' , 'get_idd_code' , 'get_area_code' , 'get_weather_code' , 'get_weather_name' , 'get_mcc' , 'get_mnc' , 'get_mobile_brand' , 'get_elevation' , 'get_usage_type' ]
20+ for x in range (len (functions_list )):
21+ assert hasattr (database , functions_list [x ]) == True , "Function did not exist."
22+
1723def testipv4countrycode ():
1824 database = IP2Location .IP2Location (ipv4database )
1925 rec = database .get_all ("8.8.8.8" )
@@ -24,10 +30,105 @@ def testipv4countryname():
2430 rec = database .get_all ("8.8.8.8" )
2531 assert rec .country_long == "United States of America" , "Test failed because country name not same."
2632
27- def testipv4unsupportedfield ():
33+ def testgetcountryshort ():
2834 database = IP2Location .IP2Location (ipv4database )
29- rec = database .get_all ("8.8.8.8" )
30- assert rec .city == None , "Test failed because city name not same."
35+ rec = database .get_country_short ("8.8.8.8" )
36+ assert rec == "US" , "Test failed because country code not same."
37+
38+ def testgetcountrylong ():
39+ database = IP2Location .IP2Location (ipv4database )
40+ rec = database .get_country_long ("8.8.8.8" )
41+ assert rec == "United States of America" , "Test failed because country name not same."
42+
43+ def testgetregion ():
44+ database = IP2Location .IP2Location (ipv4database )
45+ rec = database .get_region ("8.8.8.8" )
46+ assert rec == None
47+
48+ def testgetcity ():
49+ database = IP2Location .IP2Location (ipv4database )
50+ rec = database .get_city ("8.8.8.8" )
51+ assert rec == None
52+
53+ def testgetlatitude ():
54+ database = IP2Location .IP2Location (ipv4database )
55+ rec = database .get_latitude ("8.8.8.8" )
56+ assert rec == None
57+
58+ def testgetlongitude ():
59+ database = IP2Location .IP2Location (ipv4database )
60+ rec = database .get_longitude ("8.8.8.8" )
61+ assert rec == None
62+
63+ def testgetisp ():
64+ database = IP2Location .IP2Location (ipv4database )
65+ rec = database .get_isp ("8.8.8.8" )
66+ assert rec == None
67+
68+ def testgetdomain ():
69+ database = IP2Location .IP2Location (ipv4database )
70+ rec = database .get_domain ("8.8.8.8" )
71+ assert rec == None
72+
73+ def testgetzipcode ():
74+ database = IP2Location .IP2Location (ipv4database )
75+ rec = database .get_zipcode ("8.8.8.8" )
76+ assert rec == None
77+
78+ def testgettimezone ():
79+ database = IP2Location .IP2Location (ipv4database )
80+ rec = database .get_timezone ("8.8.8.8" )
81+ assert rec == None
82+
83+ def testgetnetspeed ():
84+ database = IP2Location .IP2Location (ipv4database )
85+ rec = database .get_netspeed ("8.8.8.8" )
86+ assert rec == None
87+
88+ def testgetiddcode ():
89+ database = IP2Location .IP2Location (ipv4database )
90+ rec = database .get_idd_code ("8.8.8.8" )
91+ assert rec == None
92+
93+ def testgetareacode ():
94+ database = IP2Location .IP2Location (ipv4database )
95+ rec = database .get_area_code ("8.8.8.8" )
96+ assert rec == None
97+
98+ def testgetweathercode ():
99+ database = IP2Location .IP2Location (ipv4database )
100+ rec = database .get_weather_code ("8.8.8.8" )
101+ assert rec == None
102+
103+ def testgetweathername ():
104+ database = IP2Location .IP2Location (ipv4database )
105+ rec = database .get_weather_name ("8.8.8.8" )
106+ assert rec == None
107+
108+ def testgetmcc ():
109+ database = IP2Location .IP2Location (ipv4database )
110+ rec = database .get_mcc ("8.8.8.8" )
111+ assert rec == None
112+
113+ def testgetmnc ():
114+ database = IP2Location .IP2Location (ipv4database )
115+ rec = database .get_mnc ("8.8.8.8" )
116+ assert rec == None
117+
118+ def testgetmobilebrand ():
119+ database = IP2Location .IP2Location (ipv4database )
120+ rec = database .get_mobile_brand ("8.8.8.8" )
121+ assert rec == None
122+
123+ def testgetelevation ():
124+ database = IP2Location .IP2Location (ipv4database )
125+ rec = database .get_elevation ("8.8.8.8" )
126+ assert rec == None
127+
128+ def testgetusagetype ():
129+ database = IP2Location .IP2Location (ipv4database )
130+ rec = database .get_usage_type ("8.8.8.8" )
131+ assert rec == None
31132
32133def testipv6countrycode ():
33134 database = IP2Location .IP2Location (ipv6database )
0 commit comments