| Conditions | 2 |
| Total Lines | 25 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 2 | ||
| Bugs | 0 | Features | 0 |
| 1 | from django.db import connection, migrations |
||
| 22 | def get_fake_model(name='TestModel', fields=None): |
||
| 23 | """Creates a fake model to use during unit tests.""" |
||
| 24 | |||
| 25 | model = define_fake_model(name, fields) |
||
| 26 | |||
| 27 | class TestProject: |
||
| 28 | |||
| 29 | def clone(self, *_args, **_kwargs): |
||
| 30 | return self |
||
| 31 | |||
| 32 | @property |
||
| 33 | def apps(self): |
||
| 34 | return self |
||
| 35 | |||
| 36 | class TestMigration(migrations.Migration): |
||
| 37 | operations = [HStoreExtension()] |
||
| 38 | |||
| 39 | with connection.schema_editor() as schema_editor: |
||
| 40 | migration_executor = MigrationExecutor(schema_editor.connection) |
||
| 41 | migration_executor.apply_migration( |
||
| 42 | TestProject(), TestMigration('eh', 'localized_fields')) |
||
| 43 | |||
| 44 | schema_editor.create_model(model) |
||
| 45 | |||
| 46 | return model |
||
| 47 |