mirror of
https://github.com/django/django.git
synced 2025-08-04 10:59:45 +00:00
Refs #33476 -- Reformatted code with Black.
This commit is contained in:
parent
f68fa8b45d
commit
9c19aff7c7
1992 changed files with 139577 additions and 96284 deletions
|
@ -10,35 +10,36 @@ class SwappableModelTests(TestCase):
|
|||
|
||||
# Limit memory usage when calling 'migrate'.
|
||||
available_apps = [
|
||||
'swappable_models',
|
||||
'django.contrib.auth',
|
||||
'django.contrib.contenttypes',
|
||||
"swappable_models",
|
||||
"django.contrib.auth",
|
||||
"django.contrib.contenttypes",
|
||||
]
|
||||
|
||||
@override_settings(TEST_ARTICLE_MODEL='swappable_models.AlternateArticle')
|
||||
@override_settings(TEST_ARTICLE_MODEL="swappable_models.AlternateArticle")
|
||||
def test_generated_data(self):
|
||||
"Permissions and content types are not created for a swapped model"
|
||||
|
||||
# Delete all permissions and content_types
|
||||
Permission.objects.filter(content_type__app_label='swappable_models').delete()
|
||||
ContentType.objects.filter(app_label='swappable_models').delete()
|
||||
Permission.objects.filter(content_type__app_label="swappable_models").delete()
|
||||
ContentType.objects.filter(app_label="swappable_models").delete()
|
||||
|
||||
# Re-run migrate. This will re-build the permissions and content types.
|
||||
management.call_command('migrate', interactive=False, verbosity=0)
|
||||
management.call_command("migrate", interactive=False, verbosity=0)
|
||||
|
||||
# Content types and permissions exist for the swapped model,
|
||||
# but not for the swappable model.
|
||||
apps_models = [(p.content_type.app_label, p.content_type.model)
|
||||
for p in Permission.objects.all()]
|
||||
self.assertIn(('swappable_models', 'alternatearticle'), apps_models)
|
||||
self.assertNotIn(('swappable_models', 'article'), apps_models)
|
||||
apps_models = [
|
||||
(p.content_type.app_label, p.content_type.model)
|
||||
for p in Permission.objects.all()
|
||||
]
|
||||
self.assertIn(("swappable_models", "alternatearticle"), apps_models)
|
||||
self.assertNotIn(("swappable_models", "article"), apps_models)
|
||||
|
||||
apps_models = [(ct.app_label, ct.model)
|
||||
for ct in ContentType.objects.all()]
|
||||
self.assertIn(('swappable_models', 'alternatearticle'), apps_models)
|
||||
self.assertNotIn(('swappable_models', 'article'), apps_models)
|
||||
apps_models = [(ct.app_label, ct.model) for ct in ContentType.objects.all()]
|
||||
self.assertIn(("swappable_models", "alternatearticle"), apps_models)
|
||||
self.assertNotIn(("swappable_models", "article"), apps_models)
|
||||
|
||||
@override_settings(TEST_ARTICLE_MODEL='swappable_models.article')
|
||||
@override_settings(TEST_ARTICLE_MODEL="swappable_models.article")
|
||||
def test_case_insensitive(self):
|
||||
"Model names are case insensitive. Model swapping honors this."
|
||||
Article.objects.all()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue