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
88f1e3d9
Kaydet (Commit)
88f1e3d9
authored
Mar 25, 2014
tarafından
Rémy Sanchez
Kaydeden (comit)
Claude Paroz
Mar 29, 2014
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Unit testing Postgis version check
Refs #22334.
üst
f30e6590
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
74 additions
and
0 deletions
+74
-0
tests.py
django/contrib/gis/tests/tests.py
+74
-0
No files found.
django/contrib/gis/tests/tests.py
0 → 100644
Dosyayı görüntüle @
88f1e3d9
import
unittest
from
django.contrib.gis.db.backends.postgis.operations
import
PostGISOperations
from
django.core.exceptions
import
ImproperlyConfigured
from
django.db
import
ProgrammingError
class
FakeConnection
(
object
):
def
__init__
(
self
):
self
.
settings_dict
=
{
'NAME'
:
'test'
,
}
class
FakePostGISOperations
(
PostGISOperations
):
def
__init__
(
self
,
version
=
None
):
self
.
version
=
version
self
.
connection
=
FakeConnection
()
def
_get_postgis_func
(
self
,
func
):
if
func
==
'postgis_lib_version'
:
if
self
.
version
is
None
:
raise
ProgrammingError
else
:
return
self
.
version
else
:
raise
NotImplementedError
(
'This function was not expected to be called'
)
class
TestPostgisVersionCheck
(
unittest
.
TestCase
):
"""
Tests that the postgis version check parses correctly the version numbers
"""
def
test_get_version
(
self
):
expect
=
'1.0.0'
ops
=
FakePostGISOperations
(
expect
)
actual
=
ops
.
postgis_lib_version
()
self
.
assertEqual
(
expect
,
actual
)
def
test_version_classic_tuple
(
self
):
expect
=
(
'1.2.3'
,
1
,
2
,
3
)
ops
=
FakePostGISOperations
(
expect
[
0
])
actual
=
ops
.
postgis_version_tuple
()
self
.
assertEqual
(
expect
,
actual
)
def
test_version_dev_tuple
(
self
):
expect
=
(
'1.2.3dev'
,
1
,
2
,
3
)
ops
=
FakePostGISOperations
(
expect
[
0
])
actual
=
ops
.
postgis_version_tuple
()
self
.
assertEqual
(
expect
,
actual
)
def
test_valid_version_numbers
(
self
):
versions
=
[
(
'1.3.0'
,
1
,
3
,
0
),
(
'2.1.1'
,
2
,
1
,
1
),
(
'2.2.0dev'
,
2
,
2
,
0
),
]
for
version
in
versions
:
ops
=
FakePostGISOperations
(
version
[
0
])
actual
=
ops
.
spatial_version
self
.
assertEqual
(
version
[
1
:],
actual
)
def
test_invalid_version_numbers
(
self
):
versions
=
[
'nope'
,
'123'
]
for
version
in
versions
:
ops
=
FakePostGISOperations
(
version
)
self
.
assertRaises
(
Exception
,
lambda
:
ops
.
spatial_version
)
def
test_no_version_number
(
self
):
ops
=
FakePostGISOperations
()
self
.
assertRaises
(
ImproperlyConfigured
,
lambda
:
ops
.
spatial_version
)
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