Merge "Support alembic 0.8.9 in test_autogen_process_directives"
This commit is contained in:
commit
24b5a3b73e
|
@ -15,6 +15,7 @@
|
||||||
|
|
||||||
import copy
|
import copy
|
||||||
import os
|
import os
|
||||||
|
import re
|
||||||
import sys
|
import sys
|
||||||
import textwrap
|
import textwrap
|
||||||
|
|
||||||
|
@ -27,6 +28,7 @@ import mock
|
||||||
from oslo_utils import fileutils
|
from oslo_utils import fileutils
|
||||||
import pkg_resources
|
import pkg_resources
|
||||||
import sqlalchemy as sa
|
import sqlalchemy as sa
|
||||||
|
from testtools import matchers
|
||||||
|
|
||||||
from neutron.db import migration
|
from neutron.db import migration
|
||||||
from neutron.db.migration import autogen
|
from neutron.db.migration import autogen
|
||||||
|
@ -674,8 +676,13 @@ class TestCli(base.BaseTestCase):
|
||||||
self.assertTrue(expand.downgrade_ops.is_empty())
|
self.assertTrue(expand.downgrade_ops.is_empty())
|
||||||
self.assertTrue(contract.downgrade_ops.is_empty())
|
self.assertTrue(contract.downgrade_ops.is_empty())
|
||||||
|
|
||||||
self.assertEqual(
|
def _get_regex(s):
|
||||||
textwrap.dedent("""\
|
s = textwrap.dedent(s)
|
||||||
|
s = re.escape(s)
|
||||||
|
# alembic 0.8.9 added additional leading '# ' before comments
|
||||||
|
return s.replace('\\#\\#\\#\\ ', '(# )?### ')
|
||||||
|
|
||||||
|
expected_regex = ("""\
|
||||||
### commands auto generated by Alembic - please adjust! ###
|
### commands auto generated by Alembic - please adjust! ###
|
||||||
op.create_table('organization',
|
op.create_table('organization',
|
||||||
sa.Column('id', sa.Integer(), nullable=False),
|
sa.Column('id', sa.Integer(), nullable=False),
|
||||||
|
@ -686,17 +693,19 @@ class TestCli(base.BaseTestCase):
|
||||||
"""sa.Column('organization_id', sa.Integer(), nullable=True))
|
"""sa.Column('organization_id', sa.Integer(), nullable=True))
|
||||||
op.create_foreign_key('org_fk', 'user', """
|
op.create_foreign_key('org_fk', 'user', """
|
||||||
"""'organization', ['organization_id'], ['id'])
|
"""'organization', ['organization_id'], ['id'])
|
||||||
### end Alembic commands ###"""),
|
### end Alembic commands ###""")
|
||||||
alembic_ag_api.render_python_code(expand.upgrade_ops)
|
self.assertThat(
|
||||||
)
|
alembic_ag_api.render_python_code(expand.upgrade_ops),
|
||||||
self.assertEqual(
|
matchers.MatchesRegex(_get_regex(expected_regex)))
|
||||||
textwrap.dedent("""\
|
|
||||||
|
expected_regex = ("""\
|
||||||
### commands auto generated by Alembic - please adjust! ###
|
### commands auto generated by Alembic - please adjust! ###
|
||||||
op.drop_constraint('user', 'uq_user_org', type_=None)
|
op.drop_constraint('user', 'uq_user_org', type_=None)
|
||||||
op.drop_column('user', 'organization_name')
|
op.drop_column('user', 'organization_name')
|
||||||
### end Alembic commands ###"""),
|
### end Alembic commands ###""")
|
||||||
alembic_ag_api.render_python_code(contract.upgrade_ops)
|
self.assertThat(
|
||||||
)
|
alembic_ag_api.render_python_code(contract.upgrade_ops),
|
||||||
|
matchers.MatchesRegex(_get_regex(expected_regex)))
|
||||||
|
|
||||||
@mock.patch('alembic.script.ScriptDirectory.walk_revisions')
|
@mock.patch('alembic.script.ScriptDirectory.walk_revisions')
|
||||||
def test__find_milestone_revisions_one_branch(self, walk_mock):
|
def test__find_milestone_revisions_one_branch(self, walk_mock):
|
||||||
|
|
Loading…
Reference in New Issue