Example #1
0
 def test_migration_call_no_fake(self):
     # This test superficially looks like it tests the --no-fake switch,
     # but it doesn't fully succeed, because the Django managemement
     # API can't duplicate the behavior of command line boolean switches.
     # The --no-fake switch bug (#171) can't be tested via the internal
     # API.  In fact, any test case for a boolean switch has to
     # execute a shell command.  That opens a can of worms, because
     # to perform a migration in a shell command, we would have to replace
     # TransactionTestCase with TestCase, which would require substantial
     # changes to this test class.  This is an awful lot of work for one
     # trivial bug fix.
     from avocado.core import backup
     from south import migration
     management.call_command('avocado', 'migration', no_fake=True,
                             quiet=True)
     migrations = _get_migrations()
     self.assertEqual(migrations, [])
     migration_dir = os.path.join(TEST_APP_DIR, 'migrations')
     self.assertTrue(os.path.exists(os.path.join(migration_dir,
                                    '0002_avocado_metadata_migration.py')))
     os.remove(os.path.join(migration_dir,
                            '0002_avocado_metadata_migration.py'))
     os.remove(os.path.join(backup.get_fixture_dir(),
                            '0002_avocado_metadata.json'))
     migration.Migrations._clear_cache()
Example #2
0
 def test_migration_call_no_fake(self):
     # This test superficially looks like it tests the --no-fake switch,
     # but it doesn't fully succeed, because the Django managemement
     # API can't duplicate the behavior of command line boolean switches.
     # The --no-fake switch bug (#171) can't be tested via the internal
     # API.  In fact, any test case for a boolean switch has to
     # execute a shell command.  That opens a can of worms, because
     # to perform a migration in a shell command, we would have to replace
     # TransactionTestCase with TestCase, which would require substantial
     # changes to this test class.  This is an awful lot of work for one
     # trivial bug fix.
     from avocado.core import backup
     from south import migration
     management.call_command('avocado',
                             'migration',
                             no_fake=True,
                             quiet=True)
     migrations = _get_migrations()
     self.assertEqual(migrations, [])
     migration_dir = os.path.join(TEST_APP_DIR, 'migrations')
     self.assertTrue(
         os.path.exists(
             os.path.join(migration_dir,
                          '0002_avocado_metadata_migration.py')))
     os.remove(
         os.path.join(migration_dir, '0002_avocado_metadata_migration.py'))
     os.remove(
         os.path.join(backup.get_fixture_dir(),
                      '0002_avocado_metadata.json'))
     migration.Migrations._clear_cache()
Example #3
0
    def test_migration_call(self):
        from avocado.core import backup

        management.call_command("avocado", "migration")
        migration_dir = os.path.join(os.path.dirname(__file__), "migrations")
        self.assertTrue(os.path.exists(os.path.join(migration_dir, "0002_avocado_metadata_migration.py")))
        os.remove(os.path.join(migration_dir, "0002_avocado_metadata_migration.py"))
        os.remove(os.path.join(backup.get_fixture_dir(), "0002_avocado_metadata.json"))
Example #4
0
    def handle(self, migration_suffix=METADATA_MIGRATION_SUFFIX, fixture_suffix=METADATA_FIXTURE_SUFFIX, **options):
        database = options.get('database')
        verbosity = options.get('verbosity')
        backup_path = options.get('backup_path')
        no_fake = options.get('no_fake')

        try:
            fixture_dir = backup.get_fixture_dir()
        except ImproperlyConfigured, e:
            raise CommandError(e.message)
Example #5
0
    def handle(self,
               migration_suffix=METADATA_MIGRATION_SUFFIX,
               fixture_suffix=METADATA_FIXTURE_SUFFIX,
               **options):
        database = options.get('database')
        verbosity = options.get('verbosity')
        backup_path = options.get('backup_path')
        no_fake = options.get('no_fake')

        try:
            fixture_dir = backup.get_fixture_dir()
        except ImproperlyConfigured, e:
            raise CommandError(e.message)
Example #6
0
 def test_migration_call(self):
     from avocado.core import backup
     from south import migration
     management.call_command('avocado', 'migration', quiet=True)
     migration_dir = os.path.join(TEST_APP_DIR, 'migrations')
     self.assertTrue(os.path.exists(os.path.join(migration_dir,
                                    '0002_avocado_metadata_migration.py')))
     os.remove(os.path.join(migration_dir,
                            '0002_avocado_metadata_migration.py'))
     os.remove(os.path.join(backup.get_fixture_dir(),
                            '0002_avocado_metadata.json'))
     # TransactionTestCase rolls back the database after each test case,
     # but South does not know this, courtesy of caching in
     # migration.Migrations.
     migration.Migrations._clear_cache()
Example #7
0
 def test_migration_call(self):
     from avocado.core import backup
     from south import migration
     management.call_command('avocado', 'migration', quiet=True)
     migration_dir = os.path.join(TEST_APP_DIR, 'migrations')
     self.assertTrue(
         os.path.exists(
             os.path.join(migration_dir,
                          '0002_avocado_metadata_migration.py')))
     os.remove(
         os.path.join(migration_dir, '0002_avocado_metadata_migration.py'))
     os.remove(
         os.path.join(backup.get_fixture_dir(),
                      '0002_avocado_metadata.json'))
     # TransactionTestCase rolls back the database after each test case,
     # but South does not know this, courtesy of caching in
     # migration.Migrations.
     migration.Migrations._clear_cache()
Example #8
0
 def test_next_fixture_name(self):
     from avocado.core import backup
     from avocado.conf import settings
     filename = backup.next_fixture_name(settings.METADATA_FIXTURE_SUFFIX,
                                         backup.get_fixture_dir())
     self.assertEqual(filename, '0002_avocado_metadata')
Example #9
0
 def test_fixture_filenames(self):
     from avocado.core import backup
     filenames = backup._fixture_filenames(backup.get_fixture_dir())
     self.assertEqual(filenames, ['0001_avocado_metadata.json'])
Example #10
0
 def test_fixture_dir(self):
     from avocado.core import backup
     self.assertEqual(backup.get_fixture_dir(),
                      os.path.join(TEST_APP_DIR, 'fixtures'))
Example #11
0
 def test_next_fixture_name(self):
     from avocado.core import backup
     from avocado.conf import settings
     filename = backup.next_fixture_name(settings.METADATA_FIXTURE_SUFFIX,
                                         backup.get_fixture_dir())
     self.assertEqual(filename, '0002_avocado_metadata')
Example #12
0
 def test_fixture_filenames(self):
     from avocado.core import backup
     filenames = backup._fixture_filenames(backup.get_fixture_dir())
     self.assertEqual(filenames, ['0001_avocado_metadata.json'])
Example #13
0
 def test_fixture_dir(self):
     from avocado.core import backup
     self.assertEqual(backup.get_fixture_dir(),
                      os.path.join(TEST_APP_DIR, 'fixtures'))
Example #14
0
    def test_fixture_dir(self):
        from avocado.core import backup

        self.assertEqual(backup.get_fixture_dir(), os.path.join(os.path.dirname(__file__), "fixtures"))