示例#1
0
    def test_migration_path(self):
        test_apps = [
            'migrations.migrations_test_apps.normal',
            'migrations.migrations_test_apps.with_package_model',
        ]

        base_dir = os.path.dirname(os.path.dirname(__file__))

        for app in test_apps:
            with self.modify_settings(INSTALLED_APPS={'append': app}):
                migration = migrations.Migration('0001_initial', app.split('.')[-1])
                expected_path = os.path.join(base_dir, *(app.split('.') + ['migrations', '0001_initial.py']))
                writer = MigrationWriter(migration)
                self.assertEqual(writer.path, expected_path)
示例#2
0
    def test_migration_path(self):
        test_apps = [
            "migrations.migrations_test_apps.normal",
            "migrations.migrations_test_apps.with_package_model",
            "migrations.migrations_test_apps.without_init_file",
        ]

        base_dir = os.path.dirname(os.path.dirname(__file__))

        for app in test_apps:
            with self.modify_settings(INSTALLED_APPS={"append": app}):
                migration = migrations.Migration("0001_initial", app.split(".")[-1])
                expected_path = os.path.join(
                    base_dir, *(app.split(".") + ["migrations", "0001_initial.py"])
                )
                writer = MigrationWriter(migration)
                self.assertEqual(writer.path, expected_path)
示例#3
0
    def test_migration_path(self):
        test_apps = [
            'migrations.migrations_test_apps.normal',
            'migrations.migrations_test_apps.with_package_model',
            'migrations.migrations_test_apps.without_init_file',
        ]

        base_dir = os.path.dirname(os.path.dirname(__file__))

        for app in test_apps:
            with self.modify_settings(INSTALLED_APPS={'append': app}):
                migration = migrations.Migration('0001_initial', app.split('.')[-1])
                expected_path = os.path.join(base_dir, *(app.split('.') + ['migrations', '0001_initial.py']))
                writer = MigrationWriter(migration)
                # Silence warning on Python 2: Not importing directory
                # 'tests/migrations/migrations_test_apps/without_init_file/migrations':
                # missing __init__.py
                with warnings.catch_warnings():
                    warnings.filterwarnings("ignore", category=ImportWarning)
                    self.assertEqual(writer.path, expected_path)
示例#4
0
    def test_migration_path(self):
        _old_app_store = copy.deepcopy(cache.app_store)

        test_apps = [
            'migrations.migrations_test_apps.normal',
            'migrations.migrations_test_apps.with_package_model',
        ]

        base_dir = os.path.dirname(os.path.dirname(__file__))

        try:
            with override_settings(INSTALLED_APPS=test_apps):
                for app in test_apps:
                    cache.load_app(app)
                    migration = migrations.Migration('0001_initial',
                                                     app.split('.')[-1])
                    expected_path = os.path.join(
                        base_dir,
                        *(app.split('.') + ['migrations', '0001_initial.py']))
                    writer = MigrationWriter(migration)
                    self.assertEqual(writer.path, expected_path)
        finally:
            cache.app_store = _old_app_store
示例#5
0
 def migration(self):
     m = migrations.Migration('0001_initial', self.config.label)
     m.operations = self.ops()
     m.dependencies = self.dependencies()
     return m
示例#6
0
 def apply_operations(self, app_label, project_state, operations):
     migration = migrations.Migration('name', app_label)
     migration.operations = operations
     with connection.schema_editor() as editor:
         return migration.apply(project_state, editor)
示例#7
0
文件: robot.py 项目: sheriefvt/SHARE
 def migration(self):
     m = migrations.Migration('0002_favicon', self.config.label)
     m.operations = self.ops()
     m.dependencies = self.dependencies()
     return m