Fix bug 2176 to update properly VCA without modifying the name 57/14257/2
authorgarciadeblas <gerardo.garciadeblas@telefonica.com>
Tue, 12 Mar 2024 15:59:46 +0000 (16:59 +0100)
committergarciadeblas <gerardo.garciadeblas@telefonica.com>
Fri, 22 Mar 2024 08:04:43 +0000 (09:04 +0100)
Change-Id: I4e7a571e7da73790f981f1262bdcfd4ba89510e4
Signed-off-by: garciadeblas <gerardo.garciadeblas@telefonica.com>
osmclient/cli_commands/vca.py
osmclient/scripts/tests/tests_vca.py

index f60f98f..fc33962 100755 (executable)
@@ -133,6 +133,7 @@ def load_file(file_path: str) -> Dict:
 @click.option(
     "--endpoints", help="Comma-separated list of IP or hostnames of the Juju controller"
 )
+@click.option("--newname", help="New name for the VCA")
 @click.option("--user", help="Username with admin priviledges")
 @click.option("--secret", help="Password of the specified username")
 @click.option("--cacert", help="CA certificate")
@@ -161,6 +162,7 @@ def load_file(file_path: str) -> Dict:
 def vca_update(
     ctx,
     name,
+    newname,
     endpoints,
     user,
     secret,
@@ -179,7 +181,8 @@ def vca_update(
     logger.debug("")
     utils.check_client_version(ctx.obj, ctx.command.name)
     vca = {}
-    vca["name"] = name
+    if newname:
+        vca["name"] = newname
     if endpoints:
         vca["endpoints"] = endpoints.split(",")
     if user:
index f1ebb5f..7bfc1c8 100644 (file)
@@ -172,7 +172,7 @@ class TestVca(unittest.TestCase):
             args=["name"],
         )
         mock_check_client_version.assert_called()
-        self.ctx_obj.vca.update.assert_called_with("name", {"name": "name"})
+        self.ctx_obj.vca.update.assert_called_with("name", {})
         mock_pretty_table.assert_not_called()
         self.table.add_row.assert_not_called()
         mock_print.assert_not_called()
@@ -191,6 +191,8 @@ class TestVca(unittest.TestCase):
             obj=self.ctx_obj,
             args=[
                 "name",
+                "--newname",
+                "newname",
                 "--endpoints",
                 "1.2.3.4:17070",
                 "--user",
@@ -217,7 +219,7 @@ class TestVca(unittest.TestCase):
         self.ctx_obj.vca.update.assert_called_with(
             "name",
             {
-                "name": "name",
+                "name": "newname",
                 "endpoints": ["1.2.3.4:17070"],
                 "user": "user",
                 "secret": "secret",