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
ab90c470
Kaydet (Commit)
ab90c470
authored
Nis 21, 2014
tarafından
Claude Paroz
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixed table cleanup in GIS migration tests
üst
1667e736
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
14 deletions
+17
-14
test_operations.py
django/contrib/gis/tests/gis_migrations/test_operations.py
+14
-11
test_operations.py
tests/migrations/test_operations.py
+3
-3
No files found.
django/contrib/gis/tests/gis_migrations/test_operations.py
Dosyayı görüntüle @
ab90c470
...
@@ -6,6 +6,7 @@ from django.contrib.gis.tests.utils import HAS_SPATIAL_DB
...
@@ -6,6 +6,7 @@ from django.contrib.gis.tests.utils import HAS_SPATIAL_DB
from
django.db
import
connection
,
migrations
,
models
from
django.db
import
connection
,
migrations
,
models
from
django.db.migrations.migration
import
Migration
from
django.db.migrations.migration
import
Migration
from
django.db.migrations.state
import
ProjectState
from
django.db.migrations.state
import
ProjectState
from
django.db.utils
import
DatabaseError
from
django.test
import
TransactionTestCase
from
django.test
import
TransactionTestCase
if
HAS_SPATIAL_DB
:
if
HAS_SPATIAL_DB
:
...
@@ -21,6 +22,19 @@ if HAS_SPATIAL_DB:
...
@@ -21,6 +22,19 @@ if HAS_SPATIAL_DB:
class
OperationTests
(
TransactionTestCase
):
class
OperationTests
(
TransactionTestCase
):
available_apps
=
[
"django.contrib.gis.tests.gis_migrations"
]
available_apps
=
[
"django.contrib.gis.tests.gis_migrations"
]
def
tearDown
(
self
):
# Delete table after testing
with
connection
.
cursor
()
as
cursor
:
try
:
cursor
.
execute
(
"DROP TABLE
%
s"
%
connection
.
ops
.
quote_name
(
"gis_neighborhood"
))
except
DatabaseError
:
pass
else
:
if
HAS_GEOMETRY_COLUMNS
:
cursor
.
execute
(
"DELETE FROM geometry_columns WHERE
%
s =
%%
s"
%
(
GeometryColumns
.
table_name_col
(),),
[
"gis_neighborhood"
])
super
(
OperationTests
,
self
)
.
tearDown
()
def
get_table_description
(
self
,
table
):
def
get_table_description
(
self
,
table
):
with
connection
.
cursor
()
as
cursor
:
with
connection
.
cursor
()
as
cursor
:
return
connection
.
introspection
.
get_table_description
(
cursor
,
table
)
return
connection
.
introspection
.
get_table_description
(
cursor
,
table
)
...
@@ -38,17 +52,6 @@ class OperationTests(TransactionTestCase):
...
@@ -38,17 +52,6 @@ class OperationTests(TransactionTestCase):
return
migration
.
apply
(
project_state
,
editor
)
return
migration
.
apply
(
project_state
,
editor
)
def
set_up_test_model
(
self
):
def
set_up_test_model
(
self
):
# Delete the tables if they already exist
with
connection
.
cursor
()
as
cursor
:
try
:
cursor
.
execute
(
"DROP TABLE
%
s"
%
connection
.
ops
.
quote_name
(
"gis_neighborhood"
))
except
:
pass
else
:
if
HAS_GEOMETRY_COLUMNS
:
cursor
.
execute
(
"DELETE FROM geometry_columns WHERE
%
s =
%%
s"
%
(
GeometryColumns
.
table_name_col
(),),
[
"gis_neighborhood"
])
operations
=
[
migrations
.
CreateModel
(
operations
=
[
migrations
.
CreateModel
(
"Neighborhood"
,
"Neighborhood"
,
[
[
...
...
tests/migrations/test_operations.py
Dosyayı görüntüle @
ab90c470
...
@@ -5,7 +5,7 @@ from django.db.migrations.migration import Migration
...
@@ -5,7 +5,7 @@ from django.db.migrations.migration import Migration
from
django.db.migrations.state
import
ProjectState
from
django.db.migrations.state
import
ProjectState
from
django.db.models.fields
import
NOT_PROVIDED
from
django.db.models.fields
import
NOT_PROVIDED
from
django.db.transaction
import
atomic
from
django.db.transaction
import
atomic
from
django.db.utils
import
IntegrityError
from
django.db.utils
import
IntegrityError
,
DatabaseError
from
.test_base
import
MigrationTestBase
from
.test_base
import
MigrationTestBase
...
@@ -37,11 +37,11 @@ class OperationTests(MigrationTestBase):
...
@@ -37,11 +37,11 @@ class OperationTests(MigrationTestBase):
with
connection
.
cursor
()
as
cursor
:
with
connection
.
cursor
()
as
cursor
:
try
:
try
:
cursor
.
execute
(
"DROP TABLE
%
s_pony"
%
app_label
)
cursor
.
execute
(
"DROP TABLE
%
s_pony"
%
app_label
)
except
:
except
DatabaseError
:
pass
pass
try
:
try
:
cursor
.
execute
(
"DROP TABLE
%
s_stable"
%
app_label
)
cursor
.
execute
(
"DROP TABLE
%
s_stable"
%
app_label
)
except
:
except
DatabaseError
:
pass
pass
# Make the "current" state
# Make the "current" state
operations
=
[
migrations
.
CreateModel
(
operations
=
[
migrations
.
CreateModel
(
...
...
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