Beispiel #1
0
    def test_migration_removed(self, mock_auto_manage_db, mock_parse_args, mock_init,
                               mock_getLogger):
        e = models.MigrationRemovedError('0002', '1.2.0', '1.1.0', 'foo')
        mock_auto_manage_db.side_effect = e

        ret = manage.main()
        self.assertEqual(ret, os.EX_SOFTWARE)
Beispiel #2
0
    def test_migration_removed(self, mock_get_packages, mock_getLogger):
        """
        ensure that if a migration raises the MigrationRemovedError, it bubbles up.
        """
        mock_package = MagicMock()
        mock_package.current_version = 6
        mock_package.latest_available_version = 7
        mock_package.name = 'foo'
        mock_migration = MagicMock()
        mock_migration.version = 7
        mock_package.unapplied_migrations = [mock_migration]
        e = models.MigrationRemovedError('0006', '1.2.0', '1.1.0', 'foo')
        mock_package.apply_migration.side_effect = e
        mock_get_packages.return_value = [mock_package]
        options = MagicMock()
        options.dry_run = False

        with self.assertRaises(models.MigrationRemovedError) as assertion:
            manage.migrate_database(options)

        self.assertTrue(assertion.exception is e)