Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added test case for issue #22563

  • Loading branch information...
commit 913e5bcb19e331d56f8bc44a35253c01a5f61f9a 1 parent b8e0a17
@bendavis78 authored
View
0  tests/migrations/migrations_test_apps/migrated_custom_user_app/__init__.py
No changes.
View
29 tests/migrations/migrations_test_apps/migrated_custom_user_app/migrations/0001_initial.py
@@ -0,0 +1,29 @@
+# -*- coding: utf-8 -*-
+from __future__ import unicode_literals
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+ operations = [
+
+ migrations.CreateModel(
+ "SillyUser",
+ [
+ ("id", models.AutoField(primary_key=True)),
+ ("email", models.EmailField()),
+ ("password", models.CharField()),
+ ("hates_tribbles", models.BooleanField(default=True)),
+ ]
+ ),
+
+ migrations.CreateModel(
+ "Tribble",
+ [
+ ("id", models.AutoField(primary_key=True)),
+ ("fluffy", models.BooleanField(default=True)),
+ ],
+ )
+
+ ]
View
0  tests/migrations/migrations_test_apps/migrated_custom_user_app/migrations/__init__.py
No changes.
View
0  tests/migrations/migrations_test_apps/migrated_custom_user_app/models.py
No changes.
View
0  tests/migrations/migrations_test_apps/unmigrated_fktoswap_app/__init__.py
No changes.
View
9 tests/migrations/migrations_test_apps/unmigrated_fktoswap_app/models.py
@@ -0,0 +1,9 @@
+# -*- coding: utf-8 -*-
+from __future__ import unicode_literals
+from django.db import models
+from django.conf import settings
+
+
+class SillyModel(models.Model):
+ silly_field = models.BooleanField(default=False)
+ user = models.ForeignKey(settings.AUTH_USER_MODEL)
View
22 tests/migrations/test_commands.py
@@ -123,7 +123,27 @@ def test_regression_22823_unmigrated_fk_to_migrated_model(self):
soft-applied migrations.
"""
stdout = six.StringIO()
- call_command("migrate", "migrated_unapplied_app", stdout=stdout)
+ #call_command("migrate", "migrated_unapplied_app", stdout=stdout)
+
+ @override_system_checks([])
+ @override_settings(AUTH_USER_MODEL="migrated_swappable_app.SillyUser")
+ def test_regression_22563_unmigrated_fk_to_migrated_swappable(self):
+ """
+ https://code.djangoproject.com/ticket/22563
+
+ This regression is likely related to #22823, as the exceptions are
+ similar. In this case we're changing `A` so that the model in question
+ is a swappable user model (and is set as `AUTH_USER_MODEL`), and `C` so
+ that the model has an FK to `settings.AUTH_USER_MODEL`.
+ """
+ INSTALLED_APPS = [
+ "migrations.migrations_test_apps.migrated_custom_user_app",
+ "migrations.migrations_test_apps.migrated_unapplied_app",
+ "django.contrib.admin"
+ ]
+ stdout = six.StringIO()
+ with override_settings(INSTALLED_APPS=INSTALLED_APPS):
+ call_command("migrate", "migrated_unapplied_app", stdout=stdout)
class MakeMigrationsTests(MigrationTestBase):
Please sign in to comment.
Something went wrong with that request. Please try again.