

def _test_database_sync_revision(self, separate_branches=True):
    with mock.patch.object(cli, 'update_head_files') 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,
        }]
        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)

dataset/ETHPy150Open openstack/neutron/neutron/tests/unit/db/test_migration.py TestCli._test_database_sync_revision/original