summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2012-01-30 12:31:08 -0500
committerMike Bayer <mike_mp@zzzcomputing.com>2012-01-30 12:31:08 -0500
commit68d380135c752e9bb1054ee0126269b9d64f6ebe (patch)
tree7223a8b0dc4a2d5f0d1fd7550f21a3ed107f1a5a /tests
parent69c7c2bf0b387df7b4e68bb8bccb331688df2beb (diff)
downloadalembic-68d380135c752e9bb1054ee0126269b9d64f6ebe.tar.gz
- add test coverage for standalone MigrationContext / Operations
- ensure MigrationContext.configure can be used with a single connection argument
Diffstat (limited to 'tests')
-rw-r--r--tests/__init__.py7
-rw-r--r--tests/test_config.py16
2 files changed, 21 insertions, 2 deletions
diff --git a/tests/__init__.py b/tests/__init__.py
index bb06ae7..e8baba8 100644
--- a/tests/__init__.py
+++ b/tests/__init__.py
@@ -35,6 +35,13 @@ def sqlite_db():
dir_ = os.path.join(staging_directory, 'scripts')
return create_engine('sqlite:///%s/foo.db' % dir_)
+def capture_db():
+ buf = []
+ def dump(sql, *multiparams, **params):
+ buf.append(str(sql.compile(dialect=engine.dialect)))
+ engine = create_engine("postgresql://", strategy="mock", executor=dump)
+ return engine, buf
+
_engs = {}
def db_for_dialect(name):
if name in _engs:
diff --git a/tests/test_config.py b/tests/test_config.py
index fb54e8a..f0bd167 100644
--- a/tests/test_config.py
+++ b/tests/test_config.py
@@ -1,5 +1,7 @@
from alembic import config
-from tests import eq_
+from alembic.migration import MigrationContext
+from alembic.operations import Operations
+from tests import eq_, capture_db
def test_config_no_file_main_option():
cfg = config.Config()
@@ -15,4 +17,14 @@ def test_config_no_file_section_option():
eq_(cfg.get_section_option("foo", "url"), "postgresql://foo/bar")
cfg.set_section_option("foo", "echo", "True")
- eq_(cfg.get_section_option("foo", "echo"), "True") \ No newline at end of file
+ eq_(cfg.get_section_option("foo", "echo"), "True")
+
+
+def test_standalone_op():
+ eng, buf = capture_db()
+
+ env = MigrationContext.configure(eng)
+ op = Operations(env)
+
+ op.alter_column("t", "c", nullable=True)
+ eq_(buf, ['ALTER TABLE t ALTER COLUMN c DROP NOT NULL'])