From cb617235aa132b913801c932f7fd04d98f2f17c4 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Timo=20Weberru=C3=9F?= <timo.weberruss@student.kit.edu>
Date: Tue, 21 Jan 2025 17:50:36 +0100
Subject: [PATCH 1/4] Fix hierarchy nested config setting

---
 armarx_setup/core/config.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/armarx_setup/core/config.py b/armarx_setup/core/config.py
index e6cf24b3a..e6b483aab 100644
--- a/armarx_setup/core/config.py
+++ b/armarx_setup/core/config.py
@@ -624,7 +624,7 @@ class AxiiConfig:
             cfg.set(cfg_name, value, parse=parse)
         else:
             nested_cfg.set(nested_name, value, parse=parse)
-            cfg.set(cfg_name, cfg, parse=False)
+            cfg.set(cfg_name, nested_cfg, parse=False)
 
     def unset(self, name: str, is_global: bool = True):
         """Unset a variable."""
-- 
GitLab


From e845d9589c2121f09ad244ad3f3106bdc0b65596 Mon Sep 17 00:00:00 2001
From: Christian Dreher <c.dreher@kit.edu>
Date: Tue, 21 Jan 2025 19:18:59 +0100
Subject: [PATCH 2/4] fix: Move test workspace fixture to higher-level import

---
 tests/e2e/__init__.py            | 38 ++++++++++++++++++++++++++++++++
 tests/e2e/test_axii_workspace.py | 27 +----------------------
 2 files changed, 39 insertions(+), 26 deletions(-)

diff --git a/tests/e2e/__init__.py b/tests/e2e/__init__.py
index 8b9be92dc..561bc1200 100644
--- a/tests/e2e/__init__.py
+++ b/tests/e2e/__init__.py
@@ -1,4 +1,42 @@
+import os
+import pytest
+
+from armarx_setup.core.config import axii_config
+from armarx_setup.core.util.commands import run
+from armarx_setup.core.workspace import Workspace
+
+
 cmd_args = {
     "capture_output": True,
     "quiet": True
 }
+
+
+@pytest.fixture()
+def test_workspace():
+    """
+    Fixture to create a workspace, supply it as "test_workspace", and destroy it afterwards.
+    """
+
+    workspace_name = "test_workspace"
+    workspace_path = os.path.join("/tmp", workspace_name)
+
+    run(f"axii workspace create {workspace_path} {workspace_name}", **cmd_args)
+    axii_config.load_known_workspaces()
+
+    workspace = Workspace.load_workspace_by_path(workspace_path)
+
+    # Simulate activating workspace.
+    os.environ["ARMARX_WORKSPACE"] = workspace_path
+
+    yield workspace
+
+    run(f"axii workspace purge {workspace_name} --yes")
+
+    # Simulate deactivating workspace.
+    del os.environ["ARMARX_WORKSPACE"]
+
+
+
+
+
diff --git a/tests/e2e/test_axii_workspace.py b/tests/e2e/test_axii_workspace.py
index 79e9502b8..aa3d963bb 100644
--- a/tests/e2e/test_axii_workspace.py
+++ b/tests/e2e/test_axii_workspace.py
@@ -10,32 +10,7 @@ from armarx_setup.core.config import axii_config
 from armarx_setup.core.util.commands import run
 from armarx_setup.core.workspace import Workspace
 
-from tests.e2e import cmd_args
-
-
-@pytest.fixture()
-def test_workspace():
-    """
-    Fixture to create a workspace, supply it as "test_workspace", and destroy it afterwards.
-    """
-
-    workspace_name = "test_workspace"
-    workspace_path = os.path.join("/tmp", workspace_name)
-
-    run(f"axii workspace create {workspace_path} {workspace_name}", **cmd_args)
-    axii_config.load_known_workspaces()
-
-    workspace = Workspace.load_workspace_by_path(workspace_path)
-
-    # Simulate activating workspace.
-    os.environ["ARMARX_WORKSPACE"] = workspace_path
-
-    yield workspace
-
-    run(f"axii workspace purge {workspace_name} --yes")
-
-    # Simulate deactivating workspace.
-    del os.environ["ARMARX_WORKSPACE"]
+from tests.e2e import cmd_args, test_workspace
 
 
 def test_workspace_create_and_purge():
-- 
GitLab


From e0e279e178cf59ef5b45a036b41fd51cb23ce8ff Mon Sep 17 00:00:00 2001
From: Christian Dreher <c.dreher@kit.edu>
Date: Tue, 21 Jan 2025 19:19:53 +0100
Subject: [PATCH 3/4] feat: Add e2e test for global config variables

---
 tests/e2e/test_axii_config.py | 66 +++++++++++++++++++++++++++++++++++
 1 file changed, 66 insertions(+)
 create mode 100644 tests/e2e/test_axii_config.py

diff --git a/tests/e2e/test_axii_config.py b/tests/e2e/test_axii_config.py
new file mode 100644
index 000000000..c16eb1632
--- /dev/null
+++ b/tests/e2e/test_axii_config.py
@@ -0,0 +1,66 @@
+"""
+Tests `axii config` functionalities.
+"""
+
+import os
+import pytest
+
+from armarx_setup.core import error
+from armarx_setup.core.config import axii_config
+from armarx_setup.core.util.commands import run
+from armarx_setup.core.workspace import Workspace
+
+from tests.e2e import cmd_args, test_workspace
+
+
+variable_name = "e2e_test_var"
+nested_variable_name = "e2e.test_var"
+variable_value = "true"
+
+
+def test_get_nonexistent_global_config_var():
+    """
+    Test getting non-existent global config variable.
+    """
+
+    try:
+        run(f"axii config --global {variable_name}", **cmd_args)
+    except error.CommandFailed as e:
+        stdout = e.stdout
+        return_code = e.return_code
+    else:
+        stdout = ""
+        return_code = 0
+
+    assert return_code == 1, "Return code should be 1."
+    assert f"No such config variable '{variable_name}'." in stdout
+
+
+def test_set_global_config_var():
+    """
+    Test setting global config variable.
+    """
+
+    stdout = run(f"axii config --global {variable_name} {variable_value}", **cmd_args)
+
+    assert stdout == f"Set '{variable_name}' (global) to {variable_value}."
+
+
+def test_get_global_config_var():
+    """
+    Test getting global config variable.
+    """
+
+    stdout = run(f"axii config --global {variable_name}", **cmd_args)
+
+    assert stdout == "true"
+
+
+def test_unset_global_config_var():
+    """
+    Test unsetting global config variable.
+    """
+
+    stdout = run(f"axii config --global --unset {variable_name}", **cmd_args)
+
+    assert stdout == f"Unset '{variable_name}' (global)."
-- 
GitLab


From 3ee24e73b163cf95e476373d0e169f1c2d7bf483 Mon Sep 17 00:00:00 2001
From: Christian Dreher <c.dreher@kit.edu>
Date: Tue, 21 Jan 2025 19:21:00 +0100
Subject: [PATCH 4/4] fix: Remove unused variable name

---
 tests/e2e/test_axii_config.py | 1 -
 1 file changed, 1 deletion(-)

diff --git a/tests/e2e/test_axii_config.py b/tests/e2e/test_axii_config.py
index c16eb1632..9e9796ddc 100644
--- a/tests/e2e/test_axii_config.py
+++ b/tests/e2e/test_axii_config.py
@@ -14,7 +14,6 @@ from tests.e2e import cmd_args, test_workspace
 
 
 variable_name = "e2e_test_var"
-nested_variable_name = "e2e.test_var"
 variable_value = "true"
 
 
-- 
GitLab