本文整理汇总了Python中alembic.script.revision.RevisionMap.get_revision方法的典型用法代码示例。如果您正苦于以下问题:Python RevisionMap.get_revision方法的具体用法?Python RevisionMap.get_revision怎么用?Python RevisionMap.get_revision使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类alembic.script.revision.RevisionMap
的用法示例。
在下文中一共展示了RevisionMap.get_revision方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_invalid_datatype
# 需要导入模块: from alembic.script.revision import RevisionMap [as 别名]
# 或者: from alembic.script.revision.RevisionMap import get_revision [as 别名]
def test_invalid_datatype(self):
map_ = RevisionMap(
lambda: [
Revision("a", ()),
Revision("b", ("a",)),
Revision("c", ("b",)),
]
)
assert_raises_message(
RevisionError,
"revision identifier b'12345' is not a string; "
"ensure database driver settings are correct",
map_.get_revisions, b'12345'
)
assert_raises_message(
RevisionError,
"revision identifier b'12345' is not a string; "
"ensure database driver settings are correct",
map_.get_revision, b'12345'
)
assert_raises_message(
RevisionError,
r"revision identifier \(b'12345',\) is not a string; "
"ensure database driver settings are correct",
map_.get_revision, (b'12345', )
)
map_.get_revision(("a", ))
map_.get_revision("a")
示例2: test_filter_for_lineage_labeled_head_across_merge
# 需要导入模块: from alembic.script.revision import RevisionMap [as 别名]
# 或者: from alembic.script.revision.RevisionMap import get_revision [as 别名]
def test_filter_for_lineage_labeled_head_across_merge(self):
def fn():
return [
Revision("a", ()),
Revision("b", ("a",)),
Revision("c1", ("b",), branch_labels="c1branch"),
Revision("c2", ("b",)),
Revision("d", ("c1", "c2")),
]
map_ = RevisionMap(fn)
c1 = map_.get_revision("c1")
c2 = map_.get_revision("c2")
d = map_.get_revision("d")
eq_(map_.filter_for_lineage([c1, c2, d], "[email protected]"), [c1, c2, d])
示例3: test_filter_for_lineage_labeled_head_across_merge
# 需要导入模块: from alembic.script.revision import RevisionMap [as 别名]
# 或者: from alembic.script.revision.RevisionMap import get_revision [as 别名]
def test_filter_for_lineage_labeled_head_across_merge(self):
fn = lambda: [
Revision('a', ()),
Revision('b', ('a', )),
Revision('c1', ('b', ), branch_labels='c1branch'),
Revision('c2', ('b', )),
Revision('d', ('c1', 'c2')),
]
map_ = RevisionMap(fn)
c1 = map_.get_revision('c1')
c2 = map_.get_revision('c2')
d = map_.get_revision('d')
eq_(
map_.filter_for_lineage([c1, c2, d], "[email protected]"),
[c1, c2, d]
)
示例4: test_get_revision_base_single
# 需要导入模块: from alembic.script.revision import RevisionMap [as 别名]
# 或者: from alembic.script.revision.RevisionMap import get_revision [as 别名]
def test_get_revision_base_single(self):
map_ = RevisionMap(
lambda: [
Revision('a', ()),
Revision('b', ('a',)),
Revision('c', ('b',)),
]
)
eq_(map_.get_revision('base'), None)
示例5: test_get_revision_head_single
# 需要导入模块: from alembic.script.revision import RevisionMap [as 别名]
# 或者: from alembic.script.revision.RevisionMap import get_revision [as 别名]
def test_get_revision_head_single(self):
map_ = RevisionMap(
lambda: [
Revision('a', ()),
Revision('b', ('a',)),
Revision('c', ('b',)),
]
)
eq_(map_.get_revision('head'), map_._revision_map['c'])
示例6: BranchTravellingTest
# 需要导入模块: from alembic.script.revision import RevisionMap [as 别名]
# 或者: from alembic.script.revision.RevisionMap import get_revision [as 别名]
#.........这里部分代码省略.........
] # noqa
)
def test_two_branches_end_behind_branch(self):
self._assert_iteration(
"merge", "a2",
['merge',
'e2b1', 'db1', 'cb1', 'b1', # e2b1 branch
'e2b2', 'db2', 'cb2', 'b2', # e2b2 branch
'a3', # both terminate at a3
'a2'
] # noqa
)
def test_three_branches_to_root(self):
# in this case, both "a3" and "db1" are stop points
self._assert_iteration(
["merge", "fe1b1"], "a1",
['merge',
'e2b1', # e2b1 branch
'e2b2', 'db2', 'cb2', 'b2', # e2b2 branch
'fe1b1', 'e1b1', # fe1b1 branch
'db1', # fe1b1 and e2b1 branches terminate at db1
'cb1', 'b1', # e2b1 branch continued....might be nicer
# if this was before the e2b2 branch...
'a3', # e2b1 and e2b2 branches terminate at a3
'a2', 'a1' # finish out
] # noqa
)
def test_three_branches_end_multiple_bases(self):
# in this case, both "a3" and "db1" are stop points
self._assert_iteration(
["merge", "fe1b1"], ["cb1", "cb2"],
[
'merge',
'e2b1',
'e2b2', 'db2', 'cb2',
'fe1b1', 'e1b1',
'db1',
'cb1'
]
)
def test_three_branches_end_multiple_bases_exclusive(self):
self._assert_iteration(
["merge", "fe1b1"], ["cb1", "cb2"],
[
'merge',
'e2b1',
'e2b2', 'db2',
'fe1b1', 'e1b1',
'db1',
],
inclusive=False
)
def test_detect_invalid_head_selection(self):
# db1 is an ancestor of fe1b1
assert_raises_message(
RevisionError,
"Requested revision fe1b1 overlaps "
"with other requested revisions",
list,
self.map._iterate_revisions(["db1", "b2", "fe1b1"], ())
)
def test_three_branches_end_multiple_bases_exclusive_blank(self):
self._assert_iteration(
["e2b1", "b2", "fe1b1"], (),
[
'e2b1',
'b2',
'fe1b1', 'e1b1',
'db1', 'cb1', 'b1', 'a3', 'a2', 'a1'
],
inclusive=False
)
def test_iterate_to_symbolic_base(self):
self._assert_iteration(
["fe1b1"], "base",
['fe1b1', 'e1b1', 'db1', 'cb1', 'b1', 'a3', 'a2', 'a1'],
inclusive=False
)
def test_ancestor_nodes(self):
merge = self.map.get_revision("merge")
eq_(
set(
rev.revision
for rev in self.map._get_ancestor_nodes([merge], check=True)
),
set(['a1', 'e2b2', 'e2b1', 'cb2', 'merge',
'a3', 'a2', 'b1', 'b2', 'db1', 'db2', 'cb1'])
)
示例7: LabeledBranchTest
# 需要导入模块: from alembic.script.revision import RevisionMap [as 别名]
# 或者: from alembic.script.revision.RevisionMap import get_revision [as 别名]
class LabeledBranchTest(DownIterateTest):
def test_dupe_branch_collection(self):
fn = lambda: [
Revision('a', ()),
Revision('b', ('a',)),
Revision('c', ('b',), branch_labels=['xy1']),
Revision('d', ()),
Revision('e', ('d',), branch_labels=['xy1']),
Revision('f', ('e',))
]
assert_raises_message(
RevisionError,
r"Branch name 'xy1' in revision (?:e|c) already "
"used by revision (?:e|c)",
getattr, RevisionMap(fn), "_revision_map"
)
def test_filter_for_lineage_labeled_head_across_merge(self):
fn = lambda: [
Revision('a', ()),
Revision('b', ('a', )),
Revision('c1', ('b', ), branch_labels='c1branch'),
Revision('c2', ('b', )),
Revision('d', ('c1', 'c2')),
]
map_ = RevisionMap(fn)
c1 = map_.get_revision('c1')
c2 = map_.get_revision('c2')
d = map_.get_revision('d')
eq_(
map_.filter_for_lineage([c1, c2, d], "[email protected]"),
[c1, c2, d]
)
def test_filter_for_lineage_heads(self):
eq_(
self.map.filter_for_lineage(
[self.map.get_revision("f")],
"heads"
),
[self.map.get_revision("f")]
)
def setUp(self):
self.map = RevisionMap(lambda: [
Revision('a', (), branch_labels='abranch'),
Revision('b', ('a',)),
Revision('somelongername', ('b',)),
Revision('c', ('somelongername',)),
Revision('d', ()),
Revision('e', ('d',), branch_labels=['ebranch']),
Revision('someothername', ('e',)),
Revision('f', ('someothername',)),
])
def test_get_base_revisions_labeled(self):
eq_(
self.map._get_base_revisions("[email protected]"),
['a']
)
def test_get_current_named_rev(self):
eq_(
self.map.get_revision("[email protected]"),
self.map.get_revision("f")
)
def test_get_base_revisions(self):
eq_(
self.map._get_base_revisions("base"),
['a', 'd']
)
def test_iterate_head_to_named_base(self):
self._assert_iteration(
"heads", "[email protected]",
['f', 'someothername', 'e', 'd']
)
self._assert_iteration(
"heads", "[email protected]",
['c', 'somelongername', 'b', 'a']
)
def test_iterate_named_head_to_base(self):
self._assert_iteration(
"[email protected]", "base",
['f', 'someothername', 'e', 'd']
)
self._assert_iteration(
"[email protected]", "base",
['c', 'somelongername', 'b', 'a']
)
def test_iterate_named_head_to_heads(self):
self._assert_iteration(
"heads", "[email protected]",
['f'],
#.........这里部分代码省略.........