mirror of
https://github.com/django/django.git
synced 2024-12-29 04:26:28 +00:00
[1.8.x] Refs #22962 -- Made test case use non-conflicting table names
Backport of b06935a486
from master
This commit is contained in:
parent
4c948c7c9d
commit
45d93baf51
@ -12,27 +12,7 @@ class Migration(migrations.Migration):
|
|||||||
|
|
||||||
operations = [
|
operations = [
|
||||||
migrations.CreateModel(
|
migrations.CreateModel(
|
||||||
name='CharArrayModel',
|
name='IntegerArrayDefaultModel',
|
||||||
fields=[
|
|
||||||
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
|
|
||||||
('field', django.contrib.postgres.fields.ArrayField(models.CharField(max_length=10), size=None)),
|
|
||||||
],
|
|
||||||
options={
|
|
||||||
},
|
|
||||||
bases=(models.Model,),
|
|
||||||
),
|
|
||||||
migrations.CreateModel(
|
|
||||||
name='DateTimeArrayModel',
|
|
||||||
fields=[
|
|
||||||
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
|
|
||||||
('field', django.contrib.postgres.fields.ArrayField(models.DateTimeField(), size=None)),
|
|
||||||
],
|
|
||||||
options={
|
|
||||||
},
|
|
||||||
bases=(models.Model,),
|
|
||||||
),
|
|
||||||
migrations.CreateModel(
|
|
||||||
name='IntegerArrayModel',
|
|
||||||
fields=[
|
fields=[
|
||||||
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
|
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
|
||||||
('field', django.contrib.postgres.fields.ArrayField(models.IntegerField(), size=None)),
|
('field', django.contrib.postgres.fields.ArrayField(models.IntegerField(), size=None)),
|
||||||
@ -41,24 +21,4 @@ class Migration(migrations.Migration):
|
|||||||
},
|
},
|
||||||
bases=(models.Model,),
|
bases=(models.Model,),
|
||||||
),
|
),
|
||||||
migrations.CreateModel(
|
|
||||||
name='NestedIntegerArrayModel',
|
|
||||||
fields=[
|
|
||||||
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
|
|
||||||
('field', django.contrib.postgres.fields.ArrayField(django.contrib.postgres.fields.ArrayField(models.IntegerField(), size=None), size=None)),
|
|
||||||
],
|
|
||||||
options={
|
|
||||||
},
|
|
||||||
bases=(models.Model,),
|
|
||||||
),
|
|
||||||
migrations.CreateModel(
|
|
||||||
name='NullableIntegerArrayModel',
|
|
||||||
fields=[
|
|
||||||
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
|
|
||||||
('field', django.contrib.postgres.fields.ArrayField(models.IntegerField(), size=None, null=True, blank=True)),
|
|
||||||
],
|
|
||||||
options={
|
|
||||||
},
|
|
||||||
bases=(models.Model,),
|
|
||||||
),
|
|
||||||
]
|
]
|
||||||
|
@ -13,7 +13,7 @@ class Migration(migrations.Migration):
|
|||||||
|
|
||||||
operations = [
|
operations = [
|
||||||
migrations.AddField(
|
migrations.AddField(
|
||||||
model_name='integerarraymodel',
|
model_name='integerarraydefaultmodel',
|
||||||
name='field_2',
|
name='field_2',
|
||||||
field=django.contrib.postgres.fields.ArrayField(models.IntegerField(), default=[], size=None),
|
field=django.contrib.postgres.fields.ArrayField(models.IntegerField(), default=[], size=None),
|
||||||
preserve_default=False,
|
preserve_default=False,
|
||||||
|
@ -9,7 +9,7 @@ from django.contrib.postgres.forms import SimpleArrayField, SplitArrayField
|
|||||||
from django.core import exceptions, serializers
|
from django.core import exceptions, serializers
|
||||||
from django.core.management import call_command
|
from django.core.management import call_command
|
||||||
from django.db import IntegrityError, connection, models
|
from django.db import IntegrityError, connection, models
|
||||||
from django.test import TestCase, override_settings
|
from django.test import TestCase, TransactionTestCase, override_settings
|
||||||
from django.utils import timezone
|
from django.utils import timezone
|
||||||
|
|
||||||
from .models import (
|
from .models import (
|
||||||
@ -243,7 +243,9 @@ class TestChecks(TestCase):
|
|||||||
self.assertEqual(errors[0].id, 'postgres.E002')
|
self.assertEqual(errors[0].id, 'postgres.E002')
|
||||||
|
|
||||||
|
|
||||||
class TestMigrations(TestCase):
|
class TestMigrations(TransactionTestCase):
|
||||||
|
|
||||||
|
available_apps = ['postgres_tests']
|
||||||
|
|
||||||
def test_deconstruct(self):
|
def test_deconstruct(self):
|
||||||
field = ArrayField(models.IntegerField())
|
field = ArrayField(models.IntegerField())
|
||||||
@ -278,7 +280,15 @@ class TestMigrations(TestCase):
|
|||||||
})
|
})
|
||||||
def test_adding_field_with_default(self):
|
def test_adding_field_with_default(self):
|
||||||
# See #22962
|
# See #22962
|
||||||
|
table_name = 'postgres_tests_integerarraydefaultmodel'
|
||||||
|
with connection.cursor() as cursor:
|
||||||
|
self.assertNotIn(table_name, connection.introspection.table_names(cursor))
|
||||||
call_command('migrate', 'postgres_tests', verbosity=0)
|
call_command('migrate', 'postgres_tests', verbosity=0)
|
||||||
|
with connection.cursor() as cursor:
|
||||||
|
self.assertIn(table_name, connection.introspection.table_names(cursor))
|
||||||
|
call_command('migrate', 'postgres_tests', 'zero', verbosity=0)
|
||||||
|
with connection.cursor() as cursor:
|
||||||
|
self.assertNotIn(table_name, connection.introspection.table_names(cursor))
|
||||||
|
|
||||||
|
|
||||||
@unittest.skipUnless(connection.vendor == 'postgresql', 'PostgreSQL required')
|
@unittest.skipUnless(connection.vendor == 'postgresql', 'PostgreSQL required')
|
||||||
|
Loading…
Reference in New Issue
Block a user