summaryrefslogtreecommitdiff
path: root/tests/test_offline_environment.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2015-02-03 11:40:40 -0500
committerMike Bayer <mike_mp@zzzcomputing.com>2015-02-03 11:51:13 -0500
commit0955d44f4b93ff520d07253373bb6cb9b25220b5 (patch)
treea7ebbca6ade9d19963e2c18ac00d7e9676454101 /tests/test_offline_environment.py
parent267063c1b804b34174ab1fc388ccc616655631fd (diff)
downloadalembic-0955d44f4b93ff520d07253373bb6cb9b25220b5.tar.gz
- move resolution of "starting rev" for --sql mode into
get_current_heads() directly; therefore we don't need to do this in alembic.command, which we were doing for stamp but not downgrade/upgrade. The slight change here is that the context.get_starting_revision_argument() method will return an abbreviated starting rev as abbreviated in all cases, including the stamp command, where we previously were converting a stamp argument first, but not for the upgrade or downgrade commands. - Fixed bug where using a partial revision identifier as the "starting revision" in ``--sql`` mode in a downgrade operation would fail to resolve properly. fixes #269
Diffstat (limited to 'tests/test_offline_environment.py')
-rw-r--r--tests/test_offline_environment.py34
1 files changed, 34 insertions, 0 deletions
diff --git a/tests/test_offline_environment.py b/tests/test_offline_environment.py
index 684e350..02e592f 100644
--- a/tests/test_offline_environment.py
+++ b/tests/test_offline_environment.py
@@ -80,6 +80,7 @@ assert context.get_revision_argument() == '%s'
command.stamp(self.cfg, b, sql=True)
command.downgrade(self.cfg, "%s:%s" % (c, b), sql=True)
+
def test_destination_rev_post_context(self):
env_file_fixture("""
context.configure(dialect_name='sqlite')
@@ -175,3 +176,36 @@ assert not context.requires_connection()
command.upgrade(self.cfg, "%s:%s" % (a, d.revision), sql=True)
assert not re.match(r".*-- .*and multiline", buf.getvalue(), re.S | re.M)
+
+ def test_starting_rev_pre_context_abbreviated(self):
+ env_file_fixture("""
+assert context.get_starting_revision_argument() == '%s'
+""" % b[0:4])
+ command.upgrade(self.cfg, "%s:%s" % (b[0:4], c), sql=True)
+ command.stamp(self.cfg, "%s:%s" % (b[0:4], c), sql=True)
+ command.downgrade(self.cfg, "%s:%s" % (b[0:4], a), sql=True)
+
+ def test_destination_rev_pre_context_abbreviated(self):
+ env_file_fixture("""
+assert context.get_revision_argument() == '%s'
+""" % b[0:4])
+ command.upgrade(self.cfg, "%s:%s" % (a, b[0:4]), sql=True)
+ command.stamp(self.cfg, b[0:4], sql=True)
+ command.downgrade(self.cfg, "%s:%s" % (c, b[0:4]), sql=True)
+
+ def test_starting_rev_context_runs_abbreviated(self):
+ env_file_fixture("""
+context.configure(dialect_name='sqlite')
+context.run_migrations()
+""")
+ command.upgrade(self.cfg, "%s:%s" % (b[0:4], c), sql=True)
+ command.downgrade(self.cfg, "%s:%s" % (b[0:4], a), sql=True)
+
+ def test_destination_rev_context_runs_abbreviated(self):
+ env_file_fixture("""
+context.configure(dialect_name='sqlite')
+context.run_migrations()
+""")
+ command.upgrade(self.cfg, "%s:%s" % (a, b[0:4]), sql=True)
+ command.stamp(self.cfg, b[0:4], sql=True)
+ command.downgrade(self.cfg, "%s:%s" % (c, b[0:4]), sql=True)