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
c4e18bb1
Kaydet (Commit)
c4e18bb1
authored
Şub 01, 2017
tarafından
Tim Graham
Kaydeden (comit)
GitHub
Şub 01, 2017
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Refs #27683 -- Split up MySQL isolation level tests.
üst
8838d4dd
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
41 additions
and
23 deletions
+41
-23
test_mysql.py
tests/backends/test_mysql.py
+41
-23
No files found.
tests/backends/test_mysql.py
Dosyayı görüntüle @
c4e18bb1
import
unittest
from
contextlib
import
contextmanager
from
django.core.exceptions
import
ImproperlyConfigured
from
django.db
import
connection
from
django.test
import
TestCase
,
override_settings
@contextmanager
def
get_connection
():
new_connection
=
connection
.
copy
()
yield
new_connection
new_connection
.
close
()
@override_settings
(
DEBUG
=
True
)
@unittest.skipUnless
(
connection
.
vendor
==
'mysql'
,
'MySQL specific test.'
)
class
MySQLTests
(
TestCase
):
read_committed
=
'read committed'
repeatable_read
=
'repeatable read'
isolation_values
=
{
level
:
level
.
replace
(
' '
,
'-'
)
.
upper
()
for
level
in
(
read_committed
,
repeatable_read
)
}
@classmethod
def
setUpClass
(
cls
):
super
()
.
setUpClass
()
configured_isolation_level
=
connection
.
isolation_level
or
cls
.
isolation_values
[
cls
.
repeatable_read
]
cls
.
configured_isolation_level
=
configured_isolation_level
.
upper
()
cls
.
other_isolation_level
=
(
cls
.
read_committed
if
configured_isolation_level
!=
cls
.
isolation_values
[
cls
.
read_committed
]
else
cls
.
repeatable_read
)
@staticmethod
def
get_isolation_level
(
connection
):
with
connection
.
cursor
()
as
cursor
:
...
...
@@ -25,32 +51,24 @@ class MySQLTests(TestCase):
self
.
assertNotIn
(
query
,
last_query
)
def
test_connect_isolation_level
(
self
):
read_committed
=
'read committed'
repeatable_read
=
'repeatable read'
isolation_values
=
{
level
:
level
.
replace
(
' '
,
'-'
)
.
upper
()
for
level
in
(
read_committed
,
repeatable_read
)
}
configured_level
=
connection
.
isolation_level
or
isolation_values
[
repeatable_read
]
configured_level
=
configured_level
.
upper
()
other_level
=
read_committed
if
configured_level
!=
isolation_values
[
read_committed
]
else
repeatable_read
self
.
assertEqual
(
self
.
get_isolation_level
(
connection
),
configured_level
)
self
.
assertEqual
(
self
.
get_isolation_level
(
connection
),
self
.
configured_isolation_level
)
new_connection
=
connection
.
copy
()
new_connection
.
settings_dict
[
'OPTIONS'
][
'isolation_level'
]
=
other_level
try
:
self
.
assertEqual
(
self
.
get_isolation_level
(
new_connection
),
isolation_values
[
other_level
])
finally
:
new_connection
.
close
()
def
test_setting_isolation_level
(
self
):
with
get_connection
()
as
new_connection
:
new_connection
.
settings_dict
[
'OPTIONS'
][
'isolation_level'
]
=
self
.
other_isolation_level
self
.
assertEqual
(
self
.
get_isolation_level
(
new_connection
),
self
.
isolation_values
[
self
.
other_isolation_level
]
)
def
test_uppercase_isolation_level
(
self
):
# Upper case values are also accepted in 'isolation_level'.
new_connection
=
connection
.
copy
()
new_connection
.
settings_dict
[
'OPTIONS'
][
'isolation_level'
]
=
other
_level
.
upper
()
try
:
self
.
assertEqual
(
self
.
get_isolation_level
(
new_connection
),
isolation_values
[
other_level
])
finally
:
new_connection
.
close
(
)
with
get_connection
()
as
new_connection
:
new_connection
.
settings_dict
[
'OPTIONS'
][
'isolation_level'
]
=
self
.
other_isolation
_level
.
upper
()
self
.
assertEqual
(
self
.
get_isolation_level
(
new_connection
),
self
.
isolation_values
[
self
.
other_isolation_level
]
)
def
test_isolation_level_validation
(
self
):
new_connection
=
connection
.
copy
()
...
...
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