]> git.ipfire.org Git - thirdparty/sqlalchemy/alembic.git/commitdiff
Add test for initializing migrations folder when folder exists and is not empty
authorAviskar KC <aviskarkc10@gmail.com>
Fri, 14 Jun 2019 11:42:28 +0000 (17:27 +0545)
committerAviskar KC <aviskarkc10@gmail.com>
Fri, 14 Jun 2019 11:42:28 +0000 (17:27 +0545)
tests/test_command.py

index ff80bbf1b6be98fb12902ea2762e524a6b61eb12..b4dd0bb2bcf2766b92f409d7b10a0d87cfcb6872 100644 (file)
@@ -798,3 +798,15 @@ class CommandLineTest(TestBase):
                             # not too long
                             assert len(help_text) < 80
         assert not commands, "Commands without help text: %s" % commands
+    
+    @mock.patch("alembic.command.os.listdir", return_value = ['file1', 'file2'])
+    @mock.patch("alembic.command.os.access", return_value = False)
+    def test_init_file_exists_and_is_not_empty(self, mocked_listdir, mocked_access):
+        directory = 'alembic'
+        assert_raises_message(
+            util.CommandError,
+            "Directory %s already exists and is not empty" % directory,
+            command.init,
+            self.cfg,
+            directory = directory
+        )