Loading django/contrib/gis/tests/gis_migrations/migrations/0001_initial.py +2 −2 Original line number Diff line number Diff line Loading @@ -22,7 +22,7 @@ class Migration(migrations.Migration): name='Household', fields=[ ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)), ('neighborhood', models.ForeignKey(to='gis.Neighborhood', to_field='id', null=True)), ('neighborhood', models.ForeignKey(to='gis_migrations.Neighborhood', to_field='id', null=True)), ('address', models.CharField(max_length=100)), ('zip_code', models.IntegerField(null=True, blank=True)), ('geom', django.contrib.gis.db.models.fields.PointField(srid=4326, geography=True)), Loading @@ -44,7 +44,7 @@ class Migration(migrations.Migration): migrations.AddField( model_name='household', name='family', field=models.ForeignKey(blank=True, to='gis.Family', null=True), field=models.ForeignKey(blank=True, to='gis_migrations.Family', null=True), preserve_default=True, ), ] django/contrib/gis/tests/gis_migrations/test_commands.py +10 −15 Original line number Diff line number Diff line Loading @@ -12,7 +12,7 @@ class MigrateTests(TransactionTestCase): """ Tests running the migrate command in Geodjango. """ available_apps = ["django.contrib.gis"] available_apps = ["django.contrib.gis.tests.gis_migrations"] def get_table_description(self, table): with connection.cursor() as cursor: Loading @@ -26,7 +26,6 @@ class MigrateTests(TransactionTestCase): with connection.cursor() as cursor: self.assertNotIn(table, connection.introspection.table_names(cursor)) @override_settings(MIGRATION_MODULES={"gis": "django.contrib.gis.tests.gis_migrations.migrations"}) def test_migrate_gis(self): """ Tests basic usage of the migrate command when a model uses Geodjango Loading @@ -38,22 +37,16 @@ class MigrateTests(TransactionTestCase): failure on geometry_columns. Regression for ticket #23030: https://code.djangoproject.com/ticket/23030 """ # Make sure no tables are created self.assertTableNotExists("migrations_neighborhood") self.assertTableNotExists("migrations_household") self.assertTableNotExists("migrations_family") # Run the migrations to 0001 only call_command("migrate", "gis", "0001", verbosity=0) # Make sure the right tables exist self.assertTableExists("gis_neighborhood") self.assertTableExists("gis_household") self.assertTableExists("gis_family") self.assertTableExists("gis_migrations_neighborhood") self.assertTableExists("gis_migrations_household") self.assertTableExists("gis_migrations_family") # Unmigrate everything call_command("migrate", "gis", "zero", verbosity=0) call_command("migrate", "gis_migrations", "zero", verbosity=0) # Make sure it's all gone self.assertTableNotExists("gis_neighborhood") self.assertTableNotExists("gis_household") self.assertTableNotExists("gis_family") self.assertTableNotExists("gis_migrations_neighborhood") self.assertTableNotExists("gis_migrations_household") self.assertTableNotExists("gis_migrations_family") # Even geometry columns metadata try: GeoColumn = connection.ops.geometry_columns() Loading @@ -66,3 +59,5 @@ class MigrateTests(TransactionTestCase): **{'%s__in' % GeoColumn.table_name_col(): ["gis_neighborhood", "gis_household"]} ).count(), 0) # Revert the "unmigration" call_command("migrate", "gis_migrations", verbosity=0) Loading
django/contrib/gis/tests/gis_migrations/migrations/0001_initial.py +2 −2 Original line number Diff line number Diff line Loading @@ -22,7 +22,7 @@ class Migration(migrations.Migration): name='Household', fields=[ ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)), ('neighborhood', models.ForeignKey(to='gis.Neighborhood', to_field='id', null=True)), ('neighborhood', models.ForeignKey(to='gis_migrations.Neighborhood', to_field='id', null=True)), ('address', models.CharField(max_length=100)), ('zip_code', models.IntegerField(null=True, blank=True)), ('geom', django.contrib.gis.db.models.fields.PointField(srid=4326, geography=True)), Loading @@ -44,7 +44,7 @@ class Migration(migrations.Migration): migrations.AddField( model_name='household', name='family', field=models.ForeignKey(blank=True, to='gis.Family', null=True), field=models.ForeignKey(blank=True, to='gis_migrations.Family', null=True), preserve_default=True, ), ]
django/contrib/gis/tests/gis_migrations/test_commands.py +10 −15 Original line number Diff line number Diff line Loading @@ -12,7 +12,7 @@ class MigrateTests(TransactionTestCase): """ Tests running the migrate command in Geodjango. """ available_apps = ["django.contrib.gis"] available_apps = ["django.contrib.gis.tests.gis_migrations"] def get_table_description(self, table): with connection.cursor() as cursor: Loading @@ -26,7 +26,6 @@ class MigrateTests(TransactionTestCase): with connection.cursor() as cursor: self.assertNotIn(table, connection.introspection.table_names(cursor)) @override_settings(MIGRATION_MODULES={"gis": "django.contrib.gis.tests.gis_migrations.migrations"}) def test_migrate_gis(self): """ Tests basic usage of the migrate command when a model uses Geodjango Loading @@ -38,22 +37,16 @@ class MigrateTests(TransactionTestCase): failure on geometry_columns. Regression for ticket #23030: https://code.djangoproject.com/ticket/23030 """ # Make sure no tables are created self.assertTableNotExists("migrations_neighborhood") self.assertTableNotExists("migrations_household") self.assertTableNotExists("migrations_family") # Run the migrations to 0001 only call_command("migrate", "gis", "0001", verbosity=0) # Make sure the right tables exist self.assertTableExists("gis_neighborhood") self.assertTableExists("gis_household") self.assertTableExists("gis_family") self.assertTableExists("gis_migrations_neighborhood") self.assertTableExists("gis_migrations_household") self.assertTableExists("gis_migrations_family") # Unmigrate everything call_command("migrate", "gis", "zero", verbosity=0) call_command("migrate", "gis_migrations", "zero", verbosity=0) # Make sure it's all gone self.assertTableNotExists("gis_neighborhood") self.assertTableNotExists("gis_household") self.assertTableNotExists("gis_family") self.assertTableNotExists("gis_migrations_neighborhood") self.assertTableNotExists("gis_migrations_household") self.assertTableNotExists("gis_migrations_family") # Even geometry columns metadata try: GeoColumn = connection.ops.geometry_columns() Loading @@ -66,3 +59,5 @@ class MigrateTests(TransactionTestCase): **{'%s__in' % GeoColumn.table_name_col(): ["gis_neighborhood", "gis_household"]} ).count(), 0) # Revert the "unmigration" call_command("migrate", "gis_migrations", verbosity=0)