-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollback django version to 1.11 since django migration testcase does not yet work with django 2 See issue: plumdog/django_migration_testcase#38
- Loading branch information
1 parent
c168e35
commit c70ecf9
Showing
5 changed files
with
58 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
Django==2.0.1 | ||
# Django==2.0.1 | ||
Django==1.11 | ||
factory-boy==2.8.1 | ||
Faker==0.8.8 | ||
|
||
|
18 changes: 18 additions & 0 deletions
18
testing_migrations/migrations/0002_awesome_model_unique_name.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Generated by Django 2.0.1 on 2018-01-12 01:45 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('testing_migrations', '0001_initial'), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterField( | ||
model_name='awesomemodel', | ||
name='name', | ||
field=models.CharField(max_length=100, unique=True), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import factory | ||
from django.db import IntegrityError | ||
from django_migration_testcase import MigrationTest | ||
from django_migration_testcase.base import idempotent_transaction | ||
|
||
|
||
class Test0002AwesomeModelUniqueName(MigrationTest): | ||
app_name = 'testing_migrations' | ||
before = '0001_initial' | ||
after = '0002_awesome_model_unique_name' | ||
|
||
def setUp(self): | ||
super().setUp() | ||
|
||
class AwesomeModelFactory(factory.DjangoModelFactory): | ||
name = factory.Faker('pystr') | ||
|
||
class Meta: | ||
model = self.get_model_before('testing_migrations.AwesomeModel') | ||
|
||
self.awesome_model_factory = AwesomeModelFactory | ||
|
||
@idempotent_transaction | ||
def test_migration(self): | ||
self.awesome_model_factory(name="foo") | ||
self.awesome_model_factory(name="foo") | ||
with self.assertRaisesMessage(IntegrityError, "UNIQUE constraint failed: testing_migrations_awesomemodel.name"): | ||
self.run_migration() | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters