Feature 10962 Refactoring of osmclient commands
[osm/osmclient.git] / osmclient / scripts / tests / tests_vim.py
index 32b229e..903fca7 100644 (file)
 #     limitations under the License.
 
 
-import unittest
 import json
+import unittest
 from unittest.mock import Mock, patch, mock_open
 from click.testing import CliRunner
-from osmclient.scripts import osm
+from osmclient.cli_commands import vim
 
 
-@patch("osmclient.scripts.osm.check_client_version")
+@patch("osmclient.cli_commands.utils.check_client_version")
 @patch("osmclient.scripts.osm.client.Client")
-@patch("osmclient.scripts.osm.create_config")
+@patch("osmclient.cli_commands.utils.create_config")
 class TestVim(unittest.TestCase):
     def setUp(self):
         self.runner = CliRunner()
@@ -38,11 +38,10 @@ class TestVim(unittest.TestCase):
         mock_create_config.return_value = {"ca_cert": "/home/ubuntu/.ssh/id_rsa.pub"}
         vim_config = mock_create_config.return_value
         with patch("builtins.open", mock_open(read_data="test")):
-
             self.runner.invoke(
-                osm.cli_osm,
-                [
-                    "vim-create",
+                vim.vim_create,
+                obj=self.ctx_obj,
+                args=[
                     "--name",
                     "vim1",
                     "--user",
@@ -89,11 +88,10 @@ class TestVim(unittest.TestCase):
         mock_create_config.return_value = {}
 
         with patch("builtins.open", mock_open(read_data="test")):
-
             self.runner.invoke(
-                osm.cli_osm,
-                [
-                    "vim-create",
+                vim.vim_create,
+                obj=self.ctx_obj,
+                args=[
                     "--name",
                     "vim1",
                     "--user",
@@ -137,11 +135,10 @@ class TestVim(unittest.TestCase):
         mock_create_config.return_value = {}
 
         with patch("builtins.open", mock_open(read_data="test")):
-
             self.runner.invoke(
-                osm.cli_osm,
-                [
-                    "vim-create",
+                vim.vim_create,
+                obj=self.ctx_obj,
+                args=[
                     "--name",
                     "vim1",
                     "--user",
@@ -189,11 +186,10 @@ class TestVim(unittest.TestCase):
         mock_create_config.return_value = {"ca_cert": "/home/ubuntu/.ssh/id_rsa.pub"}
         vim_config = mock_create_config.return_value
         with patch("builtins.open", mock_open(read_data="test")):
-
             self.runner.invoke(
-                osm.cli_osm,
-                [
-                    "vim-update",
+                vim.vim_update,
+                obj=self.ctx_obj,
+                args=[
                     "vim1",
                     "--config",
                     json.dumps({"ca_cert": "/home/ubuntu/.ssh/id_rsa.pub"}),
@@ -222,11 +218,10 @@ class TestVim(unittest.TestCase):
         mock_client.return_value = self.ctx_obj
 
         with patch("builtins.open", mock_open(read_data="test")):
-
             self.runner.invoke(
-                osm.cli_osm,
-                [
-                    "vim-update",
+                vim.vim_update,
+                obj=self.ctx_obj,
+                args=[
                     "vim1",
                     "--password",
                     "passwd",
@@ -256,11 +251,10 @@ class TestVim(unittest.TestCase):
         mock_create_config.return_value = {}
 
         with patch("builtins.open", mock_open(read_data="test")):
-
             self.runner.invoke(
-                osm.cli_osm,
-                [
-                    "vim-update",
+                vim.vim_update,
+                obj=self.ctx_obj,
+                args=[
                     "vim1",
                     "--sdn_controller",
                     "controller",