Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
pygeoip
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenEdx
pygeoip
Commits
a255821a
Commit
a255821a
authored
Aug 22, 2013
by
William Tisäter
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Increase test coverage
parent
aa3f4ce4
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
19 additions
and
8 deletions
+19
-8
tests/test.py
+8
-7
tests/test_country.py
+7
-1
tests/test_memory.py
+4
-0
No files found.
tests/test.py
View file @
a255821a
...
...
@@ -8,9 +8,9 @@ from pygeoip import const
from
tests.config
import
COUNTRY_DB_PATH
,
CORRUPT_DB_PATH
class
TestGenerals
(
unittest
.
TestCase
):
def
testContructing
(
self
):
gi
=
pygeoip
.
GeoIP
(
filename
=
COUNTRY_DB_PATH
)
self
.
assertEqual
(
gi
.
_type
,
'STANDARD'
)
def
setUp
(
self
):
self
.
gi
=
pygeoip
.
GeoIP
(
filename
=
COUNTRY_DB_PATH
)
self
.
assertEqual
(
self
.
gi
.
_type
,
'STANDARD'
)
def
testConstLengths
(
self
):
assert
len
(
const
.
COUNTRY_CODES
)
==
len
(
const
.
COUNTRY_CODES3
)
...
...
@@ -24,10 +24,11 @@ class TestGenerals(unittest.TestCase):
@raises
(
socket
.
gaierror
)
def
testFailedLookup
(
self
):
gi
=
pygeoip
.
GeoIP
(
filename
=
COUNTRY_DB_PATH
)
gi
.
country_code_by_name
(
'google'
)
self
.
gi
.
country_code_by_name
(
'google'
)
@raises
(
socket
.
error
)
def
testInvalidAddress
(
self
):
gi
=
pygeoip
.
GeoIP
(
filename
=
COUNTRY_DB_PATH
)
gi
.
country_code_by_addr
(
'google.com'
)
self
.
gi
.
country_code_by_addr
(
'google.com'
)
def
testGetEmptyRecord
(
self
):
self
.
gi
.
_get_record
(
0
)
tests/test_country.py
View file @
a255821a
# -*- coding: utf-8 -*-
import
socket
import
unittest
from
nose.tools
import
raises
...
...
@@ -43,7 +44,7 @@ class TestGeoIPCountryFunctions(unittest.TestCase):
us_code
=
self
.
gi
.
country_code_by_addr
(
self
.
us_ip
)
gb_code
=
self
.
gi
.
country_code_by_addr
(
self
.
gb_ip
)
ie6_code
=
self
.
gi6
.
country_code_by_addr
(
self
.
ie6_ip
)
self
.
assertEqual
(
us_code
,
self
.
us_code
)
self
.
assertEqual
(
gb_code
,
self
.
gb_code
)
self
.
assertEqual
(
ie6_code
,
self
.
ie_code
)
...
...
@@ -66,6 +67,11 @@ class TestGeoIPCountryFunctions(unittest.TestCase):
self
.
assertEqual
(
gb_name
,
self
.
gb_name
)
self
.
assertEqual
(
ie6_name
,
self
.
ie_name
)
@raises
(
socket
.
gaierror
)
def
testFailedIPv6Lookup
(
self
):
data
=
self
.
gi6
.
country_code_by_name
(
'google'
)
raise
ValueError
(
data
)
@raises
(
pygeoip
.
GeoIPError
)
def
testOpen4With6
(
self
):
data
=
self
.
gi
.
country_code_by_addr
(
self
.
ie6_ip
)
...
...
tests/test_memory.py
View file @
a255821a
...
...
@@ -5,7 +5,11 @@ import pygeoip
from
pygeoip
import
const
from
tests.config
import
COUNTRY_DB_PATH
class
TestMemoryCache
(
unittest
.
TestCase
):
def
testMemoryCache
(
self
):
gi
=
pygeoip
.
GeoIP
(
COUNTRY_DB_PATH
,
flags
=
const
.
MEMORY_CACHE
,
cache
=
False
)
self
.
assertEqual
(
gi
.
_type
,
'MEMORY_CACHE'
)
code
=
gi
.
country_code_by_name
(
'dn.se'
)
self
.
assertEqual
(
code
,
'SE'
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment