mirror of https://github.com/django/django.git
Fixed various tests on MySQL with MyISAM storage engine.
This commit is contained in:
parent
331a460f8f
commit
8e89dfe1c2
|
@ -1440,19 +1440,18 @@ class ListFiltersTests(TestCase):
|
||||||
|
|
||||||
filterspec = changelist.get_filters(request)[0][-1]
|
filterspec = changelist.get_filters(request)[0][-1]
|
||||||
self.assertEqual(filterspec.title, "department")
|
self.assertEqual(filterspec.title, "department")
|
||||||
choices = list(filterspec.choices(changelist))
|
choices = [
|
||||||
|
(choice["display"], choice["selected"], choice["query_string"])
|
||||||
self.assertEqual(choices[0]["display"], "All")
|
for choice in filterspec.choices(changelist)
|
||||||
self.assertIs(choices[0]["selected"], True)
|
]
|
||||||
self.assertEqual(choices[0]["query_string"], "?")
|
self.assertCountEqual(
|
||||||
|
choices,
|
||||||
self.assertEqual(choices[1]["display"], "Development")
|
[
|
||||||
self.assertIs(choices[1]["selected"], False)
|
("All", True, "?"),
|
||||||
self.assertEqual(choices[1]["query_string"], "?department__code__exact=DEV")
|
("Development", False, "?department__code__exact=DEV"),
|
||||||
|
("Design", False, "?department__code__exact=DSN"),
|
||||||
self.assertEqual(choices[2]["display"], "Design")
|
],
|
||||||
self.assertIs(choices[2]["selected"], False)
|
)
|
||||||
self.assertEqual(choices[2]["query_string"], "?department__code__exact=DSN")
|
|
||||||
|
|
||||||
# Filter by Department=='Development' --------------------------------
|
# Filter by Department=='Development' --------------------------------
|
||||||
|
|
||||||
|
@ -1466,19 +1465,18 @@ class ListFiltersTests(TestCase):
|
||||||
|
|
||||||
filterspec = changelist.get_filters(request)[0][-1]
|
filterspec = changelist.get_filters(request)[0][-1]
|
||||||
self.assertEqual(filterspec.title, "department")
|
self.assertEqual(filterspec.title, "department")
|
||||||
choices = list(filterspec.choices(changelist))
|
choices = [
|
||||||
|
(choice["display"], choice["selected"], choice["query_string"])
|
||||||
self.assertEqual(choices[0]["display"], "All")
|
for choice in filterspec.choices(changelist)
|
||||||
self.assertIs(choices[0]["selected"], False)
|
]
|
||||||
self.assertEqual(choices[0]["query_string"], "?")
|
self.assertCountEqual(
|
||||||
|
choices,
|
||||||
self.assertEqual(choices[1]["display"], "Development")
|
[
|
||||||
self.assertIs(choices[1]["selected"], True)
|
("All", False, "?"),
|
||||||
self.assertEqual(choices[1]["query_string"], "?department__code__exact=DEV")
|
("Development", True, "?department__code__exact=DEV"),
|
||||||
|
("Design", False, "?department__code__exact=DSN"),
|
||||||
self.assertEqual(choices[2]["display"], "Design")
|
],
|
||||||
self.assertIs(choices[2]["selected"], False)
|
)
|
||||||
self.assertEqual(choices[2]["query_string"], "?department__code__exact=DSN")
|
|
||||||
|
|
||||||
def test_lookup_with_dynamic_value(self):
|
def test_lookup_with_dynamic_value(self):
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -16,6 +16,9 @@ class Router:
|
||||||
|
|
||||||
db_for_write = db_for_read
|
db_for_write = db_for_read
|
||||||
|
|
||||||
|
def allow_relation(self, obj1, obj2, **hints):
|
||||||
|
return True
|
||||||
|
|
||||||
|
|
||||||
site = admin.AdminSite(name="test_adminsite")
|
site = admin.AdminSite(name="test_adminsite")
|
||||||
site.register(Book)
|
site.register(Book)
|
||||||
|
|
|
@ -15,6 +15,9 @@ class Router:
|
||||||
|
|
||||||
db_for_write = db_for_read
|
db_for_write = db_for_read
|
||||||
|
|
||||||
|
def allow_relation(self, obj1, obj2, **hints):
|
||||||
|
return True
|
||||||
|
|
||||||
|
|
||||||
site = admin.AdminSite(name="test_adminsite")
|
site = admin.AdminSite(name="test_adminsite")
|
||||||
site.register(User, admin_class=UserAdmin)
|
site.register(User, admin_class=UserAdmin)
|
||||||
|
|
|
@ -694,8 +694,12 @@ class FkConstraintsTests(TransactionTestCase):
|
||||||
a.reporter_id = 30
|
a.reporter_id = 30
|
||||||
with connection.constraint_checks_disabled():
|
with connection.constraint_checks_disabled():
|
||||||
a.save()
|
a.save()
|
||||||
with self.assertRaises(IntegrityError):
|
try:
|
||||||
connection.check_constraints(table_names=[Article._meta.db_table])
|
connection.check_constraints(table_names=[Article._meta.db_table])
|
||||||
|
except IntegrityError:
|
||||||
|
pass
|
||||||
|
else:
|
||||||
|
self.skipTest("This backend does not support integrity checks.")
|
||||||
transaction.set_rollback(True)
|
transaction.set_rollback(True)
|
||||||
|
|
||||||
def test_check_constraints_sql_keywords(self):
|
def test_check_constraints_sql_keywords(self):
|
||||||
|
@ -705,8 +709,12 @@ class FkConstraintsTests(TransactionTestCase):
|
||||||
obj.reporter_id = 30
|
obj.reporter_id = 30
|
||||||
with connection.constraint_checks_disabled():
|
with connection.constraint_checks_disabled():
|
||||||
obj.save()
|
obj.save()
|
||||||
with self.assertRaises(IntegrityError):
|
try:
|
||||||
connection.check_constraints(table_names=["order"])
|
connection.check_constraints(table_names=["order"])
|
||||||
|
except IntegrityError:
|
||||||
|
pass
|
||||||
|
else:
|
||||||
|
self.skipTest("This backend does not support integrity checks.")
|
||||||
transaction.set_rollback(True)
|
transaction.set_rollback(True)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -288,6 +288,9 @@ class TestRouter:
|
||||||
def db_for_write(self, model, **hints):
|
def db_for_write(self, model, **hints):
|
||||||
return "default"
|
return "default"
|
||||||
|
|
||||||
|
def allow_relation(self, obj1, obj2, **hints):
|
||||||
|
return True
|
||||||
|
|
||||||
|
|
||||||
@override_settings(DATABASE_ROUTERS=[TestRouter()])
|
@override_settings(DATABASE_ROUTERS=[TestRouter()])
|
||||||
class ContentTypesMultidbTests(TestCase):
|
class ContentTypesMultidbTests(TestCase):
|
||||||
|
|
|
@ -21,6 +21,9 @@ class Category(models.Model):
|
||||||
slug = models.SlugField(max_length=20)
|
slug = models.SlugField(max_length=20)
|
||||||
url = models.CharField("The URL", max_length=40)
|
url = models.CharField("The URL", max_length=40)
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
ordering = ("pk",)
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return self.name
|
return self.name
|
||||||
|
|
||||||
|
|
|
@ -310,7 +310,7 @@ class RawQueryTests(TestCase):
|
||||||
("book_count", 1),
|
("book_count", 1),
|
||||||
("book_count", 0),
|
("book_count", 0),
|
||||||
)
|
)
|
||||||
authors = Author.objects.all()
|
authors = Author.objects.order_by("pk")
|
||||||
self.assertSuccessfulRawQuery(Author, query, authors, expected_annotations)
|
self.assertSuccessfulRawQuery(Author, query, authors, expected_annotations)
|
||||||
|
|
||||||
def test_white_space_query(self):
|
def test_white_space_query(self):
|
||||||
|
|
|
@ -78,11 +78,13 @@ def natural_key_test(self, format):
|
||||||
|
|
||||||
# Deserialize and test.
|
# Deserialize and test.
|
||||||
books = list(serializers.deserialize(format, string_data))
|
books = list(serializers.deserialize(format, string_data))
|
||||||
self.assertEqual(len(books), 2)
|
self.assertCountEqual(
|
||||||
self.assertEqual(books[0].object.title, book1["title"])
|
[(book.object.title, book.object.pk) for book in books],
|
||||||
self.assertEqual(books[0].object.pk, adrian.pk)
|
[
|
||||||
self.assertEqual(books[1].object.title, book2["title"])
|
(book1["title"], adrian.pk),
|
||||||
self.assertIsNone(books[1].object.pk)
|
(book2["title"], None),
|
||||||
|
],
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def natural_pk_mti_test(self, format):
|
def natural_pk_mti_test(self, format):
|
||||||
|
|
Loading…
Reference in New Issue