コード例 #1
0
ファイル: test_migration.py プロジェクト: Raghunanda/neutron
    def _test_database_sync_revision(self, separate_branches=True):
        with mock.patch.object(cli, 'update_heads_file') as update:
            fake_config = FakeConfig()
            if separate_branches:
                expected_kwargs = [
                    {'message': 'message', 'sql': False, 'autogenerate': True,
                     'version_path':
                         cli._get_version_branch_path(fake_config, branch),
                     'head': cli._get_branch_head(branch)}
                    for branch in cli.MIGRATION_BRANCHES]
            else:
                expected_kwargs = [{
                    'message': 'message', 'sql': False, 'autogenerate': True,
                }]
            self._main_test_helper(
                ['prog', 'revision', '--autogenerate', '-m', 'message'],
                'revision',
                (), expected_kwargs
            )
            update.assert_called_once_with(mock.ANY)
            update.reset_mock()

            for kwarg in expected_kwargs:
                kwarg['autogenerate'] = False
                kwarg['sql'] = True

            self._main_test_helper(
                ['prog', 'revision', '--sql', '-m', 'message'],
                'revision',
                (), expected_kwargs
            )
            update.assert_called_once_with(mock.ANY)
コード例 #2
0
    def _test_database_sync_revision(self, separate_branches=True):
        with mock.patch.object(cli, 'update_heads_file') as update,\
                mock.patch.object(cli, '_use_separate_migration_branches',
                                  return_value=separate_branches):
            if separate_branches:
                mock.patch('os.path.exists').start()
                expected_kwargs = [
                    {'message': 'message', 'sql': False, 'autogenerate': True,
                     'version_path':
                         cli._get_version_branch_path(config, branch),
                     'head': cli._get_branch_head(branch)}
                    for config in self.configs
                    for branch in cli.MIGRATION_BRANCHES]
            else:
                expected_kwargs = [{
                    'message': 'message', 'sql': False, 'autogenerate': True,
                }]
            self._main_test_helper(
                ['prog', 'revision', '--autogenerate', '-m', 'message'],
                'revision',
                (), expected_kwargs
            )
            self.assertEqual(len(self.projects), update.call_count)
            update.reset_mock()

            for kwarg in expected_kwargs:
                kwarg['autogenerate'] = False
                kwarg['sql'] = True

            self._main_test_helper(
                ['prog', 'revision', '--sql', '-m', 'message'],
                'revision',
                (), expected_kwargs
            )
            self.assertEqual(len(self.projects), update.call_count)
コード例 #3
0
ファイル: test_migration.py プロジェクト: smokony/neutron
    def _test_database_sync_revision(self, separate_branches=True):
        with mock.patch.object(cli, 'update_heads_file') as update,\
                mock.patch.object(cli, '_use_separate_migration_branches',
                                  return_value=separate_branches):
            if separate_branches:
                mock.patch('os.path.exists').start()
                expected_kwargs = [
                    {'message': 'message', 'sql': False, 'autogenerate': True,
                     'version_path':
                         cli._get_version_branch_path(config, branch),
                     'head': cli._get_branch_head(branch)}
                    for config in self.configs
                    for branch in cli.MIGRATION_BRANCHES]
            else:
                expected_kwargs = [{
                    'message': 'message', 'sql': False, 'autogenerate': True,
                }]
            self._main_test_helper(
                ['prog', 'revision', '--autogenerate', '-m', 'message'],
                'revision',
                expected_kwargs
            )
            self.assertEqual(len(self.projects), update.call_count)
            update.reset_mock()

            for kwarg in expected_kwargs:
                kwarg['autogenerate'] = False
                kwarg['sql'] = True

            self._main_test_helper(
                ['prog', 'revision', '--sql', '-m', 'message'],
                'revision',
                expected_kwargs
            )
            self.assertEqual(len(self.projects), update.call_count)
コード例 #4
0
ファイル: test_migration.py プロジェクト: sheepcat/neutron
    def _test_database_sync_revision(self, separate_branches=True):
        with mock.patch.object(cli, "update_heads_file") as update:

            class FakeConfig(object):
                service = ""

            fake_config = FakeConfig()
            if separate_branches:
                expected_kwargs = [
                    {
                        "message": "message",
                        "sql": False,
                        "autogenerate": True,
                        "version_path": cli._get_version_branch_path(fake_config, branch),
                        "head": cli._get_branch_head(branch),
                    }
                    for branch in cli.MIGRATION_BRANCHES
                ]
            else:
                expected_kwargs = [{"message": "message", "sql": False, "autogenerate": True}]
            self._main_test_helper(
                ["prog", "revision", "--autogenerate", "-m", "message"], "revision", (), expected_kwargs
            )
            update.assert_called_once_with(mock.ANY)
            update.reset_mock()

            for kwarg in expected_kwargs:
                kwarg["autogenerate"] = False
                kwarg["sql"] = True

            self._main_test_helper(["prog", "revision", "--sql", "-m", "message"], "revision", (), expected_kwargs)
            update.assert_called_once_with(mock.ANY)
コード例 #5
0
ファイル: test_migration.py プロジェクト: wenhuizhang/neutron
    def _test_database_sync_revision(self, separate_branches=True):
        with mock.patch.object(cli, 'update_heads_file') as update:
            class FakeConfig(object):
                service = ''

            fake_config = FakeConfig()
            if separate_branches:
                expected_kwargs = [
                    {'message': 'message', 'sql': False, 'autogenerate': True,
                     'version_path':
                         cli._get_version_branch_path(fake_config, branch),
                     'head': cli._get_branch_head(branch)}
                    for branch in cli.MIGRATION_BRANCHES]
            else:
                expected_kwargs = [{
                    'message': 'message', 'sql': False, 'autogenerate': True,
                }]
            self._main_test_helper(
                ['prog', 'revision', '--autogenerate', '-m', 'message'],
                'revision',
                (), expected_kwargs
            )
            update.assert_called_once_with(mock.ANY)
            update.reset_mock()

            for kwarg in expected_kwargs:
                kwarg['autogenerate'] = False
                kwarg['sql'] = True

            self._main_test_helper(
                ['prog', 'revision', '--sql', '-m', 'message'],
                'revision',
                (), expected_kwargs
            )
            update.assert_called_once_with(mock.ANY)
コード例 #6
0
ファイル: test_migration.py プロジェクト: rktidwell/neutron
    def _test_database_sync_revision(self, revs):
        with mock.patch.object(cli, 'update_head_files') as update,\
                mock.patch('alembic.script.ScriptDirectory.from_config') as fc:
            fc.return_value.get_revisions.side_effect = revs
            mock.patch('os.path.exists').start()
            expected_kwargs = [{
                'message': 'message', 'sql': False, 'autogenerate': True,
            }]
            self._main_test_helper(
                ['prog', 'revision', '--autogenerate', '-m', 'message'],
                'revision',
                expected_kwargs
            )
            self.assertEqual(len(self.projects), update.call_count)
            update.reset_mock()

            expected_kwargs = [{
                'message': 'message',
                'sql': True,
                'autogenerate': False,
                'head': cli._get_branch_head(self.configs[0], branch)
            } for branch in cli.MIGRATION_BRANCHES]
            for kwarg in expected_kwargs:
                kwarg['autogenerate'] = False
                kwarg['sql'] = True

            self._main_test_helper(
                ['prog', 'revision', '--sql', '-m', 'message'],
                'revision',
                expected_kwargs
            )
            self.assertEqual(len(self.projects), update.call_count)
            update.reset_mock()

            expected_kwargs = [{
                'message': 'message',
                'sql': False,
                'autogenerate': False,
                'head': 'expand@head'
            }]
            self._main_test_helper(
                ['prog', 'revision', '-m', 'message', '--expand'],
                'revision',
                expected_kwargs
            )
            self.assertEqual(len(self.projects), update.call_count)
            update.reset_mock()

            for kwarg in expected_kwargs:
                kwarg['head'] = 'contract@head'

            self._main_test_helper(
                ['prog', 'revision', '-m', 'message', '--contract'],
                'revision',
                expected_kwargs
            )
            self.assertEqual(len(self.projects), update.call_count)
コード例 #7
0
ファイル: test_migration.py プロジェクト: igordcard/neutron
    def _test_database_sync_revision(self, separate_branches=True):
        with mock.patch.object(cli, 'update_head_files') as update:
            if separate_branches:
                mock.patch('os.path.exists').start()
            expected_kwargs = [{
                'message': 'message', 'sql': False, 'autogenerate': True,
            }]
            self._main_test_helper(
                ['prog', 'revision', '--autogenerate', '-m', 'message'],
                'revision',
                expected_kwargs
            )
            self.assertEqual(len(self.projects), update.call_count)
            update.reset_mock()

            expected_kwargs = [{
                'message': 'message',
                'sql': True,
                'autogenerate': False,
                'head': cli._get_branch_head(branch)
            } for branch in cli.MIGRATION_BRANCHES]
            for kwarg in expected_kwargs:
                kwarg['autogenerate'] = False
                kwarg['sql'] = True

            self._main_test_helper(
                ['prog', 'revision', '--sql', '-m', 'message'],
                'revision',
                expected_kwargs
            )
            self.assertEqual(len(self.projects), update.call_count)
            update.reset_mock()

            expected_kwargs = [{
                'message': 'message',
                'sql': False,
                'autogenerate': False,
                'head': 'expand@head'
            }]
            self._main_test_helper(
                ['prog', 'revision', '-m', 'message', '--expand'],
                'revision',
                expected_kwargs
            )
            self.assertEqual(len(self.projects), update.call_count)
            update.reset_mock()

            for kwarg in expected_kwargs:
                kwarg['head'] = 'contract@head'

            self._main_test_helper(
                ['prog', 'revision', '-m', 'message', '--contract'],
                'revision',
                expected_kwargs
            )
            self.assertEqual(len(self.projects), update.call_count)
コード例 #8
0
    def _test_database_sync_revision(self, separate_branches=True):
        with mock.patch.object(cli, 'update_head_files') as update:
            if separate_branches:
                mock.patch('os.path.exists').start()
            expected_kwargs = [{
                'message': 'message', 'sql': False, 'autogenerate': True,
            }]
            self._main_test_helper(
                ['prog', 'revision', '--autogenerate', '-m', 'message'],
                'revision',
                expected_kwargs
            )
            self.assertEqual(len(self.projects), update.call_count)
            update.reset_mock()

            expected_kwargs = [{
                'message': 'message',
                'sql': True,
                'autogenerate': False,
                'head': cli._get_branch_head(branch)
            } for branch in cli.MIGRATION_BRANCHES]
            for kwarg in expected_kwargs:
                kwarg['autogenerate'] = False
                kwarg['sql'] = True

            self._main_test_helper(
                ['prog', 'revision', '--sql', '-m', 'message'],
                'revision',
                expected_kwargs
            )
            self.assertEqual(len(self.projects), update.call_count)
            update.reset_mock()

            expected_kwargs = [{
                'message': 'message',
                'sql': False,
                'autogenerate': False,
                'head': 'expand@head'
            }]
            self._main_test_helper(
                ['prog', 'revision', '-m', 'message', '--expand'],
                'revision',
                expected_kwargs
            )
            self.assertEqual(len(self.projects), update.call_count)
            update.reset_mock()

            for kwarg in expected_kwargs:
                kwarg['head'] = 'contract@head'

            self._main_test_helper(
                ['prog', 'revision', '-m', 'message', '--contract'],
                'revision',
                expected_kwargs
            )
            self.assertEqual(len(self.projects), update.call_count)