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
3db66b1d
Kaydet (Commit)
3db66b1d
authored
Eyl 03, 2013
tarafından
Tim Graham
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Updated syncdb -> migrate in tests.
üst
8f7f8bf6
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
46 additions
and
57 deletions
+46
-57
tests.py
tests/fixtures/tests.py
+1
-1
tests.py
tests/fixtures_model_package/tests.py
+3
-3
tests.py
tests/initial_sql_regress/tests.py
+1
-1
models.py
tests/m2m_regress/models.py
+1
-1
__init__.py
tests/migrate_signals/__init__.py
+0
-0
models.py
tests/migrate_signals/models.py
+0
-0
tests.py
tests/migrate_signals/tests.py
+25
-25
tests.py
tests/multiple_database/tests.py
+8
-8
tests.py
tests/proxy_model_inheritance/tests.py
+3
-3
models.py
tests/schema/models.py
+1
-1
tests.py
tests/swappable_models/tests.py
+2
-2
models.py
tests/syncdb_signals/models.py
+0
-11
models.py
tests/tablespaces/models.py
+1
-1
No files found.
tests/fixtures/tests.py
Dosyayı görüntüle @
3db66b1d
...
...
@@ -48,7 +48,7 @@ class DumpDataAssertMixin(object):
class
FixtureLoadingTests
(
DumpDataAssertMixin
,
TestCase
):
def
test_initial_data
(
self
):
#
syncdb
introduces 1 initial data object from initial_data.json.
#
migrate
introduces 1 initial data object from initial_data.json.
self
.
assertQuerysetEqual
(
Book
.
objects
.
all
(),
[
'<Book: Achieving self-awareness of Python programs>'
])
...
...
tests/fixtures_model_package/tests.py
Dosyayı görüntüle @
3db66b1d
...
...
@@ -30,12 +30,12 @@ class TestNoInitialDataLoading(TransactionTestCase):
available_apps
=
[
'fixtures_model_package'
]
def
test_
syncdb
(
self
):
def
test_
migrate
(
self
):
with
transaction
.
atomic
():
Book
.
objects
.
all
()
.
delete
()
management
.
call_command
(
'
syncdb
'
,
'
migrate
'
,
verbosity
=
0
,
load_initial_data
=
False
)
...
...
@@ -64,7 +64,7 @@ class TestNoInitialDataLoading(TransactionTestCase):
class
FixtureTestCase
(
TestCase
):
def
test_initial_data
(
self
):
"Fixtures can load initial data into models defined in packages"
#
syncdb
introduces 1 initial data object from initial_data.json
#
migrate
introduces 1 initial data object from initial_data.json
self
.
assertQuerysetEqual
(
Book
.
objects
.
all
(),
[
'Achieving self-awareness of Python programs'
...
...
tests/initial_sql_regress/tests.py
Dosyayı görüntüle @
3db66b1d
...
...
@@ -24,7 +24,7 @@ class InitialSQLTests(TestCase):
def
test_custom_sql
(
self
):
"""
Simulate the custom SQL loading by
syncdb
.
Simulate the custom SQL loading by
migrate
.
"""
connection
=
connections
[
DEFAULT_DB_ALIAS
]
custom_sql
=
custom_sql_for_model
(
Simple
,
no_style
(),
connection
)
...
...
tests/m2m_regress/models.py
Dosyayı görüntüle @
3db66b1d
...
...
@@ -57,7 +57,7 @@ class Worksheet(models.Model):
# Regression for #11226 -- A model with the same name that another one to
# which it has a m2m relation. This shouldn't cause a name clash between
# the automatically created m2m intermediary table FK field names when
# running
syncdb
# running
migrate
class
User
(
models
.
Model
):
name
=
models
.
CharField
(
max_length
=
30
)
friends
=
models
.
ManyToManyField
(
auth
.
User
)
...
...
tests/
syncdb
_signals/__init__.py
→
tests/
migrate
_signals/__init__.py
Dosyayı görüntüle @
3db66b1d
File moved
tests/migrate_signals/models.py
0 → 100644
Dosyayı görüntüle @
3db66b1d
tests/
syncdb
_signals/tests.py
→
tests/
migrate
_signals/tests.py
Dosyayı görüntüle @
3db66b1d
...
...
@@ -6,13 +6,13 @@ from django.utils import six
from
.
import
models
PRE_
SYNCDB
_ARGS
=
[
'app'
,
'create_models'
,
'verbosity'
,
'interactive'
,
'db'
]
SYNCDB
_DATABASE
=
'default'
SYNCDB
_VERBOSITY
=
1
SYNCDB
_INTERACTIVE
=
False
PRE_
MIGRATE
_ARGS
=
[
'app'
,
'create_models'
,
'verbosity'
,
'interactive'
,
'db'
]
MIGRATE
_DATABASE
=
'default'
MIGRATE
_VERBOSITY
=
1
MIGRATE
_INTERACTIVE
=
False
class
Pre
Syncdb
Receiver
(
object
):
class
Pre
Migrate
Receiver
(
object
):
def
__init__
(
self
):
self
.
call_counter
=
0
self
.
call_args
=
None
...
...
@@ -24,7 +24,7 @@ class PreSyncdbReceiver(object):
class
OneTimeReceiver
(
object
):
"""
Special receiver for handle the fact that test runner calls
syncdb
for
Special receiver for handle the fact that test runner calls
migrate
for
several databases and several times for some of them.
"""
...
...
@@ -33,13 +33,13 @@ class OneTimeReceiver(object):
self
.
call_args
=
None
def
__call__
(
self
,
signal
,
sender
,
**
kwargs
):
# Although test runner calls
syncdb
for several databases,
# Although test runner calls
migrate
for several databases,
# testing for only one of them is quite sufficient.
if
kwargs
[
'db'
]
==
SYNCDB
_DATABASE
:
if
kwargs
[
'db'
]
==
MIGRATE
_DATABASE
:
self
.
call_counter
=
self
.
call_counter
+
1
self
.
call_args
=
kwargs
# we need to test only one call of
syncdb
signals
.
pre_
syncdb
.
disconnect
(
pre_syncdb
_receiver
,
sender
=
models
)
# we need to test only one call of
migrate
signals
.
pre_
migrate
.
disconnect
(
pre_migrate
_receiver
,
sender
=
models
)
# We connect receiver here and not in unit test code because we need to
...
...
@@ -48,32 +48,32 @@ class OneTimeReceiver(object):
#
# 1. Test runner imports this module.
# 2. We connect receiver.
# 3. Test runner calls
syncdb
for create default database.
# 3. Test runner calls
migrate
for create default database.
# 4. Test runner execute our unit test code.
pre_
syncdb
_receiver
=
OneTimeReceiver
()
signals
.
pre_
syncdb
.
connect
(
pre_syncdb
_receiver
,
sender
=
models
)
pre_
migrate
_receiver
=
OneTimeReceiver
()
signals
.
pre_
migrate
.
connect
(
pre_migrate
_receiver
,
sender
=
models
)
class
Syncdb
SignalTests
(
TestCase
):
class
Migrate
SignalTests
(
TestCase
):
available_apps
=
[
'
syncdb
_signals'
,
'
migrate
_signals'
,
]
def
test_pre_
syncdb
_call_time
(
self
):
self
.
assertEqual
(
pre_
syncdb
_receiver
.
call_counter
,
1
)
def
test_pre_
migrate
_call_time
(
self
):
self
.
assertEqual
(
pre_
migrate
_receiver
.
call_counter
,
1
)
def
test_pre_
syncdb
_args
(
self
):
r
=
Pre
Syncdb
Receiver
()
signals
.
pre_
syncdb
.
connect
(
r
,
sender
=
models
)
management
.
call_command
(
'
syncdb'
,
database
=
SYNCDB
_DATABASE
,
verbosity
=
SYNCDB_VERBOSITY
,
interactive
=
SYNCDB
_INTERACTIVE
,
def
test_pre_
migrate
_args
(
self
):
r
=
Pre
Migrate
Receiver
()
signals
.
pre_
migrate
.
connect
(
r
,
sender
=
models
)
management
.
call_command
(
'
migrate'
,
database
=
MIGRATE
_DATABASE
,
verbosity
=
MIGRATE_VERBOSITY
,
interactive
=
MIGRATE
_INTERACTIVE
,
load_initial_data
=
False
,
stdout
=
six
.
StringIO
())
args
=
r
.
call_args
self
.
assertEqual
(
r
.
call_counter
,
1
)
self
.
assertEqual
(
set
(
args
),
set
(
PRE_
SYNCDB
_ARGS
))
self
.
assertEqual
(
set
(
args
),
set
(
PRE_
MIGRATE
_ARGS
))
self
.
assertEqual
(
args
[
'app'
],
models
)
self
.
assertEqual
(
args
[
'verbosity'
],
SYNCDB
_VERBOSITY
)
self
.
assertEqual
(
args
[
'interactive'
],
SYNCDB
_INTERACTIVE
)
self
.
assertEqual
(
args
[
'verbosity'
],
MIGRATE
_VERBOSITY
)
self
.
assertEqual
(
args
[
'interactive'
],
MIGRATE
_INTERACTIVE
)
self
.
assertEqual
(
args
[
'db'
],
'default'
)
tests/multiple_database/tests.py
Dosyayı görüntüle @
3db66b1d
...
...
@@ -1019,7 +1019,7 @@ class RouterTestCase(TestCase):
self
.
assertEqual
(
Book
.
objects
.
db_manager
(
'default'
)
.
db
,
'default'
)
self
.
assertEqual
(
Book
.
objects
.
db_manager
(
'default'
)
.
all
()
.
db
,
'default'
)
def
test_
syncdb
_selection
(
self
):
def
test_
migrate
_selection
(
self
):
"Synchronization behavior is predictable"
self
.
assertTrue
(
router
.
allow_migrate
(
'default'
,
User
))
...
...
@@ -1921,7 +1921,7 @@ class SyncOnlyDefaultDatabaseRouter(object):
return
db
==
DEFAULT_DB_ALIAS
class
SyncDB
TestCase
(
TestCase
):
class
Migrate
TestCase
(
TestCase
):
available_apps
=
[
'multiple_database'
,
...
...
@@ -1930,27 +1930,27 @@ class SyncDBTestCase(TestCase):
]
multi_db
=
True
def
test_
syncdb
_to_other_database
(
self
):
"""Regression test for #16039:
syncdb
with --database option."""
def
test_
migrate
_to_other_database
(
self
):
"""Regression test for #16039:
migrate
with --database option."""
cts
=
ContentType
.
objects
.
using
(
'other'
)
.
filter
(
app_label
=
'multiple_database'
)
count
=
cts
.
count
()
self
.
assertGreater
(
count
,
0
)
cts
.
delete
()
management
.
call_command
(
'
syncdb
'
,
verbosity
=
0
,
interactive
=
False
,
management
.
call_command
(
'
migrate
'
,
verbosity
=
0
,
interactive
=
False
,
load_initial_data
=
False
,
database
=
'other'
)
self
.
assertEqual
(
cts
.
count
(),
count
)
def
test_
syncdb
_to_other_database_with_router
(
self
):
"""Regression test for #16039:
syncdb
with --database option."""
def
test_
migrate
_to_other_database_with_router
(
self
):
"""Regression test for #16039:
migrate
with --database option."""
cts
=
ContentType
.
objects
.
using
(
'other'
)
.
filter
(
app_label
=
'multiple_database'
)
cts
.
delete
()
try
:
old_routers
=
router
.
routers
router
.
routers
=
[
SyncOnlyDefaultDatabaseRouter
()]
management
.
call_command
(
'
syncdb
'
,
verbosity
=
0
,
interactive
=
False
,
management
.
call_command
(
'
migrate
'
,
verbosity
=
0
,
interactive
=
False
,
load_initial_data
=
False
,
database
=
'other'
)
finally
:
router
.
routers
=
old_routers
...
...
tests/proxy_model_inheritance/tests.py
Dosyayı görüntüle @
3db66b1d
...
...
@@ -17,9 +17,9 @@ from .models import (ConcreteModel, ConcreteModelSubclass,
@override_settings
(
INSTALLED_APPS
=
(
'app1'
,
'app2'
))
class
ProxyModelInheritanceTests
(
TransactionTestCase
):
"""
Proxy model inheritance across apps can result in
syncdb
not creating the table
Proxy model inheritance across apps can result in
migrate
not creating the table
for the proxied model (as described in #12286). This test creates two dummy
apps and calls
syncdb
, then verifies that the table has been created.
apps and calls
migrate
, then verifies that the table has been created.
"""
available_apps
=
[]
...
...
@@ -42,7 +42,7 @@ class ProxyModelInheritanceTests(TransactionTestCase):
def
test_table_exists
(
self
):
try
:
cache
.
set_available_apps
(
settings
.
INSTALLED_APPS
)
call_command
(
'
syncdb
'
,
verbosity
=
0
)
call_command
(
'
migrate
'
,
verbosity
=
0
)
finally
:
cache
.
unset_available_apps
()
from
.app1.models
import
ProxyModel
...
...
tests/schema/models.py
Dosyayı görüntüle @
3db66b1d
...
...
@@ -3,7 +3,7 @@ from django.db.models.loading import BaseAppCache
# Because we want to test creation and deletion of these as separate things,
# these models are all inserted into a separate AppCache so the main test
# runner doesn't
syncdb
them.
# runner doesn't
migrate
them.
new_app_cache
=
BaseAppCache
()
...
...
tests/swappable_models/tests.py
Dosyayı görüntüle @
3db66b1d
...
...
@@ -38,9 +38,9 @@ class SwappableModelTests(TestCase):
Permission
.
objects
.
filter
(
content_type__app_label
=
'swappable_models'
)
.
delete
()
ContentType
.
objects
.
filter
(
app_label
=
'swappable_models'
)
.
delete
()
# Re-run
syncdb
. This will re-build the permissions and content types.
# Re-run
migrate
. This will re-build the permissions and content types.
new_io
=
StringIO
()
management
.
call_command
(
'
syncdb
'
,
load_initial_data
=
False
,
interactive
=
False
,
stdout
=
new_io
)
management
.
call_command
(
'
migrate
'
,
load_initial_data
=
False
,
interactive
=
False
,
stdout
=
new_io
)
# Check that content types and permissions exist for the swapped model,
# but not for the swappable model.
...
...
tests/syncdb_signals/models.py
deleted
100644 → 0
Dosyayı görüntüle @
8f7f8bf6
# from django.db import models
# class Author(models.Model):
# name = models.CharField(max_length=100)
# class Meta:
# ordering = ['name']
# def __unicode__(self):
# return self.name
tests/tablespaces/models.py
Dosyayı görüntüle @
3db66b1d
...
...
@@ -4,7 +4,7 @@ from django.db import models
# to create the tables for models where db_tablespace is set. To avoid this
# problem, we mark the models as unmanaged, and temporarily revert them to
# managed during each test. We also set them to use the same tables as the
# "reference" models to avoid errors when other tests run '
syncdb
'
# "reference" models to avoid errors when other tests run '
migrate
'
# (proxy_models_inheritance does).
class
ScientistRef
(
models
.
Model
):
...
...
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