summaryrefslogtreecommitdiff
path: root/tests/test_command.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2015-07-30 13:43:05 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2015-07-30 13:43:05 -0400
commitd4da2e156c7eec4d9ac5744ec39b263a801e9523 (patch)
tree4e8ed6469247453b6204137b7d77147e77273e04 /tests/test_command.py
parentab4691fa5c98336a7b1d4085cfa2602d352c1b1a (diff)
parentef7183e5358f2bdb7368c468b672ccc49647a2dd (diff)
downloadalembic-d4da2e156c7eec4d9ac5744ec39b263a801e9523.tar.gz
Merge branch 'edit-latest' of https://bitbucket.org/exhuma/alembic into pr46
Diffstat (limited to 'tests/test_command.py')
-rw-r--r--tests/test_command.py34
1 files changed, 33 insertions, 1 deletions
diff --git a/tests/test_command.py b/tests/test_command.py
index 9f8428d..aaeefbc 100644
--- a/tests/test_command.py
+++ b/tests/test_command.py
@@ -5,7 +5,7 @@ from alembic.testing.fixtures import TestBase, capture_context_buffer
from alembic.testing.env import staging_env, _sqlite_testing_config, \
three_rev_fixture, clear_staging_env, _no_sql_testing_config, \
_sqlite_file_db, write_script, env_file_fixture
-from alembic.testing import eq_, assert_raises_message
+from alembic.testing import eq_, assert_raises_message, mock
from alembic import util
@@ -420,3 +420,35 @@ down_revision = '%s'
self.bind.scalar("select version_num from alembic_version"),
self.a
)
+
+
+class EditTest(TestBase):
+
+ @classmethod
+ def setup_class(cls):
+ cls.env = staging_env()
+ cls.cfg = _sqlite_testing_config()
+ cls.a, cls.b, cls.c = three_rev_fixture(cls.cfg)
+
+ @classmethod
+ def teardown_class(cls):
+ clear_staging_env()
+
+ def test_edit_latest(self):
+ expected_call_arg = '%s/scripts/versions/%s_revision_c.py' % (
+ EditTest.cfg.config_args['here'],
+ EditTest.c
+ )
+
+ with mock.patch('alembic.command.editor.edit') as edit:
+ command.edit(self.cfg)
+ edit.assert_called_with(expected_call_arg)
+
+ def test_edit_with_missing_editor(self):
+ with mock.patch('alembic.command.editor.edit') as edit:
+ edit.side_effect = OSError('file not found')
+ assert_raises_message(
+ util.CommandError,
+ 'file not found',
+ command.edit,
+ self.cfg)