Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
D
django
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
django
Commits
d171843f
Kaydet (Commit)
d171843f
authored
Mar 03, 2018
tarafından
Alex Stovbur
Kaydeden (comit)
Tim Graham
Mar 05, 2018
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixed #28981 -- Added an exception if GeoIP database can't be loaded from the path.
üst
84398897
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
2 deletions
+11
-2
base.py
django/contrib/gis/geoip2/base.py
+3
-0
test_geoip2.py
tests/gis_tests/test_geoip2.py
+8
-2
No files found.
django/contrib/gis/geoip2/base.py
Dosyayı görüntüle @
d171843f
...
...
@@ -92,6 +92,9 @@ class GeoIP2:
if
os
.
path
.
isfile
(
city_db
):
self
.
_city
=
geoip2
.
database
.
Reader
(
city_db
,
mode
=
cache
)
self
.
_city_file
=
city_db
if
not
self
.
_reader
:
raise
GeoIP2Exception
(
'Could not load a database from
%
s.'
%
path
)
elif
os
.
path
.
isfile
(
path
):
# Otherwise, some detective work will be needed to figure out
# whether the given database path is for the GeoIP country or city
...
...
tests/gis_tests/test_geoip2.py
Dosyayı görüntüle @
d171843f
import
os
import
unittest
from
unittest
import
mock
,
skipUnless
from
django.conf
import
settings
from
django.contrib.gis.geoip2
import
HAS_GEOIP2
from
django.contrib.gis.geos
import
GEOSGeometry
from
django.test
import
SimpleTestCase
if
HAS_GEOIP2
:
from
django.contrib.gis.geoip2
import
GeoIP2
,
GeoIP2Exception
...
...
@@ -18,7 +18,7 @@ if HAS_GEOIP2:
HAS_GEOIP2
and
getattr
(
settings
,
"GEOIP_PATH"
,
None
),
"GeoIP is required along with the GEOIP_PATH setting."
)
class
GeoIPTest
(
unittest
.
TestCase
):
class
GeoIPTest
(
Simple
TestCase
):
addr
=
'128.249.1.1'
fqdn
=
'tmc.edu'
...
...
@@ -53,6 +53,12 @@ class GeoIPTest(unittest.TestCase):
with
self
.
assertRaises
(
e
):
GeoIP2
(
bad
,
0
)
def
test_no_database_file
(
self
):
invalid_path
=
os
.
path
.
join
(
os
.
path
.
dirname
(
__file__
),
'data'
)
msg
=
'Could not load a database from
%
s.'
%
invalid_path
with
self
.
assertRaisesMessage
(
GeoIP2Exception
,
msg
):
GeoIP2
(
invalid_path
)
def
test02_bad_query
(
self
):
"GeoIP query parameter checking."
cntry_g
=
GeoIP2
(
city
=
'<foo>'
)
...
...
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