summaryrefslogtreecommitdiff
path: root/tests/test_offline_environment.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2011-11-14 17:39:17 -0500
committerMike Bayer <mike_mp@zzzcomputing.com>2011-11-14 17:39:17 -0500
commitf576169d362694139193dc29e7d2ba9f57323809 (patch)
tree37ed106ae7048ce37a8eaaa148a87e3835a0a8a5 /tests/test_offline_environment.py
parent57df5838feaf11ee4168a6e26ca6f3a128eccde6 (diff)
downloadalembic-f576169d362694139193dc29e7d2ba9f57323809.tar.gz
- make start/end arguments available to environments
- more environment functions - clean up start:end system - docs
Diffstat (limited to 'tests/test_offline_environment.py')
-rw-r--r--tests/test_offline_environment.py72
1 files changed, 72 insertions, 0 deletions
diff --git a/tests/test_offline_environment.py b/tests/test_offline_environment.py
new file mode 100644
index 0000000..c8847d5
--- /dev/null
+++ b/tests/test_offline_environment.py
@@ -0,0 +1,72 @@
+from tests import clear_staging_env, staging_env, \
+ _no_sql_testing_config, sqlite_db, eq_, ne_, \
+ capture_context_buffer, three_rev_fixture, _env_file_fixture
+from alembic import command, util
+
+def setup():
+ global cfg, env
+ env = staging_env()
+ cfg = _no_sql_testing_config()
+
+ global a, b, c
+ a, b, c = three_rev_fixture(cfg)
+
+def teardown():
+ clear_staging_env()
+
+def test_not_requires_connection():
+ _env_file_fixture("""
+assert not context.requires_connection()
+""")
+ command.upgrade(cfg, a, sql=True)
+ command.downgrade(cfg, a, sql=True)
+
+def test_requires_connection():
+ _env_file_fixture("""
+assert context.requires_connection()
+""")
+ command.upgrade(cfg, a)
+ command.downgrade(cfg, a)
+
+
+def test_starting_rev():
+ _env_file_fixture("""
+context.configure(dialect_name='sqlite', starting_rev='x')
+assert context.get_starting_revision_argument() == 'x'
+""")
+ command.upgrade(cfg, a, sql=True)
+ command.downgrade(cfg, a, sql=True)
+
+
+def test_destination_rev():
+ _env_file_fixture("""
+context.configure(dialect_name='sqlite')
+assert context.get_revision_argument() == '%s'
+""" % b)
+ command.upgrade(cfg, b, sql=True)
+ command.downgrade(cfg, b, sql=True)
+
+
+def test_head_rev():
+ _env_file_fixture("""
+context.configure(dialect_name='sqlite')
+assert context.get_head_revision() == '%s'
+""" % c)
+ command.upgrade(cfg, b, sql=True)
+ command.downgrade(cfg, b, sql=True)
+
+def test_tag_cmd_arg():
+ _env_file_fixture("""
+context.configure(dialect_name='sqlite')
+assert context.get_tag_argument() == 'hi'
+""")
+ command.upgrade(cfg, b, sql=True, tag='hi')
+ command.downgrade(cfg, b, sql=True, tag='hi')
+
+def test_tag_cfg_arg():
+ _env_file_fixture("""
+context.configure(dialect_name='sqlite', tag='there')
+assert context.get_tag_argument() == 'there'
+""")
+ command.upgrade(cfg, b, sql=True, tag='hi')
+ command.downgrade(cfg, b, sql=True, tag='hi')