summaryrefslogtreecommitdiffstats
path: root/ansible_collections/kubernetes/core/tests/unit
diff options
context:
space:
mode:
Diffstat (limited to 'ansible_collections/kubernetes/core/tests/unit')
-rw-r--r--ansible_collections/kubernetes/core/tests/unit/action/test_remove_omit.py1
-rw-r--r--ansible_collections/kubernetes/core/tests/unit/conftest.py5
-rw-r--r--ansible_collections/kubernetes/core/tests/unit/module_utils/test_apply.py2
-rw-r--r--ansible_collections/kubernetes/core/tests/unit/module_utils/test_client.py8
-rw-r--r--ansible_collections/kubernetes/core/tests/unit/module_utils/test_core.py13
-rw-r--r--ansible_collections/kubernetes/core/tests/unit/module_utils/test_discoverer.py12
-rw-r--r--ansible_collections/kubernetes/core/tests/unit/module_utils/test_helm.py95
-rw-r--r--ansible_collections/kubernetes/core/tests/unit/module_utils/test_runner.py5
-rw-r--r--ansible_collections/kubernetes/core/tests/unit/module_utils/test_service.py4
-rw-r--r--ansible_collections/kubernetes/core/tests/unit/module_utils/test_waiter.py9
-rw-r--r--ansible_collections/kubernetes/core/tests/unit/modules/test_helm_template_module.py3
-rw-r--r--ansible_collections/kubernetes/core/tests/unit/modules/test_module_helm.py45
12 files changed, 90 insertions, 112 deletions
diff --git a/ansible_collections/kubernetes/core/tests/unit/action/test_remove_omit.py b/ansible_collections/kubernetes/core/tests/unit/action/test_remove_omit.py
index 3432c19f9..e8206a440 100644
--- a/ansible_collections/kubernetes/core/tests/unit/action/test_remove_omit.py
+++ b/ansible_collections/kubernetes/core/tests/unit/action/test_remove_omit.py
@@ -7,6 +7,7 @@ from __future__ import absolute_import, division, print_function
__metaclass__ = type
from datetime import datetime
+
from ansible_collections.kubernetes.core.plugins.action.k8s_info import RemoveOmit
diff --git a/ansible_collections/kubernetes/core/tests/unit/conftest.py b/ansible_collections/kubernetes/core/tests/unit/conftest.py
index 20615adb0..63eca8b57 100644
--- a/ansible_collections/kubernetes/core/tests/unit/conftest.py
+++ b/ansible_collections/kubernetes/core/tests/unit/conftest.py
@@ -6,12 +6,11 @@ import json
import sys
from io import BytesIO
-import pytest
-
import ansible.module_utils.basic
-from ansible.module_utils.six import string_types
+import pytest
from ansible.module_utils._text import to_bytes
from ansible.module_utils.common._collections_compat import MutableMapping
+from ansible.module_utils.six import string_types
@pytest.fixture
diff --git a/ansible_collections/kubernetes/core/tests/unit/module_utils/test_apply.py b/ansible_collections/kubernetes/core/tests/unit/module_utils/test_apply.py
index 07986007b..3dd116108 100644
--- a/ansible_collections/kubernetes/core/tests/unit/module_utils/test_apply.py
+++ b/ansible_collections/kubernetes/core/tests/unit/module_utils/test_apply.py
@@ -18,8 +18,8 @@ from __future__ import absolute_import, division, print_function
__metaclass__ = type
from ansible_collections.kubernetes.core.plugins.module_utils.apply import (
- merge,
apply_patch,
+ merge,
)
tests = [
diff --git a/ansible_collections/kubernetes/core/tests/unit/module_utils/test_client.py b/ansible_collections/kubernetes/core/tests/unit/module_utils/test_client.py
index bba03589e..d3fec2299 100644
--- a/ansible_collections/kubernetes/core/tests/unit/module_utils/test_client.py
+++ b/ansible_collections/kubernetes/core/tests/unit/module_utils/test_client.py
@@ -1,14 +1,14 @@
-import os
import base64
+import os
import tempfile
-import yaml
-import mock
-from mock import MagicMock
+import mock
+import yaml
from ansible_collections.kubernetes.core.plugins.module_utils.k8s.client import (
_create_auth_spec,
_create_configuration,
)
+from mock import MagicMock
TEST_HOST = "test-host"
TEST_SSL_HOST = "https://test-host"
diff --git a/ansible_collections/kubernetes/core/tests/unit/module_utils/test_core.py b/ansible_collections/kubernetes/core/tests/unit/module_utils/test_core.py
index 189f1f950..a49ea12cc 100644
--- a/ansible_collections/kubernetes/core/tests/unit/module_utils/test_core.py
+++ b/ansible_collections/kubernetes/core/tests/unit/module_utils/test_core.py
@@ -6,12 +6,11 @@ import json
import kubernetes
import pytest
-
from ansible_collections.kubernetes.core.plugins.module_utils.k8s.core import (
AnsibleK8SModule,
)
-MINIMAL_K8S_VERSION = "12.0.0"
+MINIMAL_K8S_VERSION = "24.2.0"
UNSUPPORTED_K8S_VERSION = "11.0.0"
@@ -50,9 +49,9 @@ def test_warn_on_k8s_version(monkeypatch, stdin, capfd):
dependencies = [
- ["18.20.0", "12.0.1", False],
- ["18.20.0", "18.20.0", True],
- ["12.0.1", "18.20.0", True],
+ ["28.20.0", "24.2.1", False],
+ ["28.20.0", "28.20.0", True],
+ ["24.2.1", "28.20.0", True],
]
@@ -68,7 +67,7 @@ def test_has_at_least(monkeypatch, stdin, desired, actual, result, capfd):
dependencies = [
- ["kubernetes", "18.20.0", "(kubernetes>=18.20.0)"],
+ ["kubernetes", "28.20.0", "(kubernetes>=28.20.0)"],
["foobar", "1.0.0", "(foobar>=1.0.0)"],
["foobar", None, "(foobar)"],
]
@@ -80,7 +79,7 @@ dependencies = [
def test_requires_fails_with_message(
monkeypatch, stdin, dependency, version, msg, capfd
):
- monkeypatch.setattr(kubernetes, "__version__", "12.0.0")
+ monkeypatch.setattr(kubernetes, "__version__", "24.2.0")
module = AnsibleK8SModule(argument_spec={})
with pytest.raises(SystemExit):
module.requires(dependency, version)
diff --git a/ansible_collections/kubernetes/core/tests/unit/module_utils/test_discoverer.py b/ansible_collections/kubernetes/core/tests/unit/module_utils/test_discoverer.py
index b23a7a9aa..618b0cb08 100644
--- a/ansible_collections/kubernetes/core/tests/unit/module_utils/test_discoverer.py
+++ b/ansible_collections/kubernetes/core/tests/unit/module_utils/test_discoverer.py
@@ -14,19 +14,17 @@
import pytest
-
-from kubernetes.client import ApiClient
-from kubernetes.dynamic import Resource
-
-from ansible_collections.kubernetes.core.plugins.module_utils.k8sdynamicclient import (
- K8SDynamicClient,
-)
from ansible_collections.kubernetes.core.plugins.module_utils.client.discovery import (
LazyDiscoverer,
)
from ansible_collections.kubernetes.core.plugins.module_utils.client.resource import (
ResourceList,
)
+from ansible_collections.kubernetes.core.plugins.module_utils.k8sdynamicclient import (
+ K8SDynamicClient,
+)
+from kubernetes.client import ApiClient
+from kubernetes.dynamic import Resource
@pytest.fixture(scope="module")
diff --git a/ansible_collections/kubernetes/core/tests/unit/module_utils/test_helm.py b/ansible_collections/kubernetes/core/tests/unit/module_utils/test_helm.py
index de2c1569d..5db0a017c 100644
--- a/ansible_collections/kubernetes/core/tests/unit/module_utils/test_helm.py
+++ b/ansible_collections/kubernetes/core/tests/unit/module_utils/test_helm.py
@@ -7,22 +7,21 @@ from __future__ import absolute_import, division, print_function
__metaclass__ = type
import os.path
-import yaml
+import random
+import string
import tempfile
-import pytest
-
+from unittest.mock import MagicMock
+import pytest
+import yaml
from ansible_collections.kubernetes.core.plugins.module_utils.helm import (
AnsibleHelmModule,
write_temp_kubeconfig,
)
-from unittest.mock import MagicMock
-import random
-import string
@pytest.fixture()
-def ansible_helm_module():
+def _ansible_helm_module():
module = MagicMock()
module.params = {
"api_key": None,
@@ -114,7 +113,6 @@ def test_write_temp_kubeconfig_with_kubeconfig():
def test_module_get_helm_binary_from_params():
-
helm_binary_path = MagicMock()
helm_sys_binary_path = MagicMock()
@@ -129,7 +127,6 @@ def test_module_get_helm_binary_from_params():
def test_module_get_helm_binary_from_system():
-
helm_sys_binary_path = MagicMock()
module = MagicMock()
module.params = {}
@@ -139,31 +136,29 @@ def test_module_get_helm_binary_from_system():
assert helm_module.get_helm_binary() == helm_sys_binary_path
-def test_module_get_helm_plugin_list(ansible_helm_module):
-
- ansible_helm_module.run_helm_command = MagicMock()
- ansible_helm_module.run_helm_command.return_value = (0, "output", "error")
+def test_module_get_helm_plugin_list(_ansible_helm_module):
+ _ansible_helm_module.run_helm_command = MagicMock()
+ _ansible_helm_module.run_helm_command.return_value = (0, "output", "error")
- rc, out, err, command = ansible_helm_module.get_helm_plugin_list()
+ rc, out, err, command = _ansible_helm_module.get_helm_plugin_list()
assert (rc, out, err) == (0, "output", "error")
assert command == "some/path/to/helm/executable plugin list"
- ansible_helm_module.get_helm_binary.assert_called_once()
- ansible_helm_module.run_helm_command.assert_called_once_with(
+ _ansible_helm_module.get_helm_binary.assert_called_once()
+ _ansible_helm_module.run_helm_command.assert_called_once_with(
"some/path/to/helm/executable plugin list"
)
-def test_module_get_helm_plugin_list_failure(ansible_helm_module):
-
- ansible_helm_module.run_helm_command = MagicMock()
- ansible_helm_module.run_helm_command.return_value = (-1, "output", "error")
+def test_module_get_helm_plugin_list_failure(_ansible_helm_module):
+ _ansible_helm_module.run_helm_command = MagicMock()
+ _ansible_helm_module.run_helm_command.return_value = (-1, "output", "error")
with pytest.raises(SystemExit):
- ansible_helm_module.get_helm_plugin_list()
+ _ansible_helm_module.get_helm_plugin_list()
- ansible_helm_module.fail_json.assert_called_once_with(
+ _ansible_helm_module.fail_json.assert_called_once_with(
msg="Failed to get Helm plugin info",
command="some/path/to/helm/executable plugin list",
stdout="output",
@@ -174,8 +169,7 @@ def test_module_get_helm_plugin_list_failure(ansible_helm_module):
@pytest.mark.parametrize("no_values", [True, False])
@pytest.mark.parametrize("get_all", [True, False])
-def test_module_get_values(ansible_helm_module, no_values, get_all):
-
+def test_module_get_values(_ansible_helm_module, no_values, get_all):
expected = {"test": "units"}
output = "---\ntest: units\n"
@@ -183,19 +177,19 @@ def test_module_get_values(ansible_helm_module, no_values, get_all):
expected = {}
output = "null"
- ansible_helm_module.run_helm_command = MagicMock()
- ansible_helm_module.run_helm_command.return_value = (0, output, "error")
+ _ansible_helm_module.run_helm_command = MagicMock()
+ _ansible_helm_module.run_helm_command.return_value = (0, output, "error")
release_name = "".join(
random.choice(string.ascii_letters + string.digits) for x in range(10)
)
- result = ansible_helm_module.get_values(release_name, get_all=get_all)
+ result = _ansible_helm_module.get_values(release_name, get_all=get_all)
- ansible_helm_module.get_helm_binary.assert_called_once()
+ _ansible_helm_module.get_helm_binary.assert_called_once()
command = f"some/path/to/helm/executable get values --output=yaml {release_name}"
if get_all:
command += " -a"
- ansible_helm_module.run_helm_command.assert_called_once_with(command)
+ _ansible_helm_module.run_helm_command.assert_called_once_with(command)
assert result == expected
@@ -210,21 +204,19 @@ def test_module_get_values(ansible_helm_module, no_values, get_all):
('Client: &version.Version{SemVer:"v3.12.3"', None),
],
)
-def test_module_get_helm_version(ansible_helm_module, output, expected):
-
- ansible_helm_module.run_command = MagicMock()
- ansible_helm_module.run_command.return_value = (0, output, "error")
+def test_module_get_helm_version(_ansible_helm_module, output, expected):
+ _ansible_helm_module.run_command = MagicMock()
+ _ansible_helm_module.run_command.return_value = (0, output, "error")
- result = ansible_helm_module.get_helm_version()
+ result = _ansible_helm_module.get_helm_version()
- ansible_helm_module.get_helm_binary.assert_called_once()
+ _ansible_helm_module.get_helm_binary.assert_called_once()
command = "some/path/to/helm/executable version"
- ansible_helm_module.run_command.assert_called_once_with(command)
+ _ansible_helm_module.run_command.assert_called_once_with(command)
assert result == expected
-def test_module_run_helm_command(ansible_helm_module):
-
+def test_module_run_helm_command(_ansible_helm_module):
error = "".join(
random.choice(string.ascii_letters + string.digits) for x in range(10)
)
@@ -232,27 +224,26 @@ def test_module_run_helm_command(ansible_helm_module):
random.choice(string.ascii_letters + string.digits) for x in range(10)
)
- ansible_helm_module.run_command.return_value = (0, output, error)
+ _ansible_helm_module.run_command.return_value = (0, output, error)
- ansible_helm_module._prepare_helm_environment = MagicMock()
+ _ansible_helm_module._prepare_helm_environment = MagicMock()
env_update = {x: random.choice(string.ascii_letters) for x in range(10)}
- ansible_helm_module._prepare_helm_environment.return_value = env_update
+ _ansible_helm_module._prepare_helm_environment.return_value = env_update
command = "".join(
random.choice(string.ascii_letters + string.digits) for x in range(10)
)
- rc, out, err = ansible_helm_module.run_helm_command(command)
+ rc, out, err = _ansible_helm_module.run_helm_command(command)
assert (rc, out, err) == (0, output, error)
- ansible_helm_module.run_command.assert_called_once_with(
+ _ansible_helm_module.run_command.assert_called_once_with(
command, environ_update=env_update
)
@pytest.mark.parametrize("fails_on_error", [True, False])
-def test_module_run_helm_command_failure(ansible_helm_module, fails_on_error):
-
+def test_module_run_helm_command_failure(_ansible_helm_module, fails_on_error):
error = "".join(
random.choice(string.ascii_letters + string.digits) for x in range(10)
)
@@ -260,9 +251,9 @@ def test_module_run_helm_command_failure(ansible_helm_module, fails_on_error):
random.choice(string.ascii_letters + string.digits) for x in range(10)
)
return_code = random.randint(1, 10)
- ansible_helm_module.run_command.return_value = (return_code, output, error)
+ _ansible_helm_module.run_command.return_value = (return_code, output, error)
- ansible_helm_module._prepare_environment = MagicMock()
+ _ansible_helm_module._prepare_environment = MagicMock()
command = "".join(
random.choice(string.ascii_letters + string.digits) for x in range(10)
@@ -270,10 +261,10 @@ def test_module_run_helm_command_failure(ansible_helm_module, fails_on_error):
if fails_on_error:
with pytest.raises(SystemExit):
- rc, out, err = ansible_helm_module.run_helm_command(
+ rc, out, err = _ansible_helm_module.run_helm_command(
command, fails_on_error=fails_on_error
)
- ansible_helm_module.fail_json.assert_called_with(
+ _ansible_helm_module.fail_json.assert_called_with(
msg="Failure when executing Helm command. Exited {0}.\nstdout: {1}\nstderr: {2}".format(
return_code, output, error
),
@@ -282,7 +273,7 @@ def test_module_run_helm_command_failure(ansible_helm_module, fails_on_error):
command=command,
)
else:
- rc, out, err = ansible_helm_module.run_helm_command(
+ rc, out, err = _ansible_helm_module.run_helm_command(
command, fails_on_error=fails_on_error
)
assert (rc, out, err) == (return_code, output, error)
@@ -311,7 +302,6 @@ def test_module_run_helm_command_failure(ansible_helm_module, fails_on_error):
],
)
def test_module_prepare_helm_environment(params, env_update, kubeconfig):
-
module = MagicMock()
module.params = params
@@ -355,7 +345,6 @@ def test_module_prepare_helm_environment(params, env_update, kubeconfig):
def test_module_prepare_helm_environment_with_validate_certs(
helm_version, is_env_var_set
):
-
module = MagicMock()
module.params = {"validate_certs": False}
@@ -387,7 +376,6 @@ def test_module_prepare_helm_environment_with_validate_certs(
],
)
def test_module_prepare_helm_environment_with_ca_cert(helm_version, is_env_var_set):
-
ca_cert = "".join(
random.choice(string.ascii_letters + string.digits) for i in range(50)
)
@@ -441,7 +429,6 @@ def test_module_prepare_helm_environment_with_ca_cert(helm_version, is_env_var_s
],
)
def test_module_get_helm_set_values_args(set_values, expected):
-
module = MagicMock()
module.params = {}
module.fail_json.side_effect = SystemExit(1)
diff --git a/ansible_collections/kubernetes/core/tests/unit/module_utils/test_runner.py b/ansible_collections/kubernetes/core/tests/unit/module_utils/test_runner.py
index 45c6f29aa..a0555c411 100644
--- a/ansible_collections/kubernetes/core/tests/unit/module_utils/test_runner.py
+++ b/ansible_collections/kubernetes/core/tests/unit/module_utils/test_runner.py
@@ -1,12 +1,11 @@
-import pytest
from copy import deepcopy
from unittest.mock import Mock
-from kubernetes.dynamic.resource import ResourceInstance
-
+import pytest
from ansible_collections.kubernetes.core.plugins.module_utils.k8s.runner import (
perform_action,
)
+from kubernetes.dynamic.resource import ResourceInstance
definition = {
"apiVersion": "v1",
diff --git a/ansible_collections/kubernetes/core/tests/unit/module_utils/test_service.py b/ansible_collections/kubernetes/core/tests/unit/module_utils/test_service.py
index a1822de61..980336176 100644
--- a/ansible_collections/kubernetes/core/tests/unit/module_utils/test_service.py
+++ b/ansible_collections/kubernetes/core/tests/unit/module_utils/test_service.py
@@ -1,14 +1,12 @@
from unittest.mock import Mock
import pytest
-from kubernetes.dynamic.resource import ResourceInstance, Resource
-
from ansible_collections.kubernetes.core.plugins.module_utils.k8s.service import (
K8sService,
diff_objects,
)
-
from kubernetes.dynamic.exceptions import NotFoundError
+from kubernetes.dynamic.resource import Resource, ResourceInstance
pod_definition = {
"apiVersion": "v1",
diff --git a/ansible_collections/kubernetes/core/tests/unit/module_utils/test_waiter.py b/ansible_collections/kubernetes/core/tests/unit/module_utils/test_waiter.py
index b5ce10a51..e63019ec7 100644
--- a/ansible_collections/kubernetes/core/tests/unit/module_utils/test_waiter.py
+++ b/ansible_collections/kubernetes/core/tests/unit/module_utils/test_waiter.py
@@ -5,20 +5,19 @@ from unittest.mock import Mock
import pytest
import yaml
-from kubernetes.dynamic.resource import ResourceInstance
-from kubernetes.dynamic.exceptions import NotFoundError
-
from ansible_collections.kubernetes.core.plugins.module_utils.k8s.waiter import (
+ DummyWaiter,
+ Waiter,
clock,
custom_condition,
deployment_ready,
- DummyWaiter,
exists,
get_waiter,
pod_ready,
resource_absent,
- Waiter,
)
+from kubernetes.dynamic.exceptions import NotFoundError
+from kubernetes.dynamic.resource import ResourceInstance
def resources(filepath):
diff --git a/ansible_collections/kubernetes/core/tests/unit/modules/test_helm_template_module.py b/ansible_collections/kubernetes/core/tests/unit/modules/test_helm_template_module.py
index 9fd98e4c8..0ff6ad016 100644
--- a/ansible_collections/kubernetes/core/tests/unit/modules/test_helm_template_module.py
+++ b/ansible_collections/kubernetes/core/tests/unit/modules/test_helm_template_module.py
@@ -7,14 +7,13 @@ from __future__ import absolute_import, division, print_function
__metaclass__ = type
import unittest
-
from unittest.mock import patch
from ansible.module_utils import basic
from ansible_collections.kubernetes.core.plugins.modules import helm_template
from ansible_collections.kubernetes.core.tests.unit.utils.ansible_module_mock import (
- AnsibleFailJson,
AnsibleExitJson,
+ AnsibleFailJson,
exit_json,
fail_json,
get_bin_path,
diff --git a/ansible_collections/kubernetes/core/tests/unit/modules/test_module_helm.py b/ansible_collections/kubernetes/core/tests/unit/modules/test_module_helm.py
index ca61cf3ef..199bd828f 100644
--- a/ansible_collections/kubernetes/core/tests/unit/modules/test_module_helm.py
+++ b/ansible_collections/kubernetes/core/tests/unit/modules/test_module_helm.py
@@ -7,14 +7,13 @@ from __future__ import absolute_import, division, print_function
__metaclass__ = type
import unittest
-
-from unittest.mock import MagicMock, patch, call
+from unittest.mock import MagicMock, call, patch
from ansible.module_utils import basic
from ansible_collections.kubernetes.core.plugins.modules import helm
from ansible_collections.kubernetes.core.tests.unit.utils.ansible_module_mock import (
- AnsibleFailJson,
AnsibleExitJson,
+ AnsibleFailJson,
exit_json,
fail_json,
get_bin_path,
@@ -87,12 +86,12 @@ class TestDependencyUpdateWithoutChartRepoUrlOption(unittest.TestCase):
helm.main()
helm.run_dep_update.assert_not_called()
mock_run_command.assert_called_once_with(
- "/usr/bin/helm upgrade -i --reset-values test /tmp/path",
+ "/usr/bin/helm upgrade -i --reset-values test '/tmp/path'",
environ_update={"HELM_NAMESPACE": "test"},
)
assert (
result.exception.args[0]["command"]
- == "/usr/bin/helm upgrade -i --reset-values test /tmp/path"
+ == "/usr/bin/helm upgrade -i --reset-values test '/tmp/path'"
)
def test_dependency_update_option_false(self):
@@ -117,12 +116,12 @@ class TestDependencyUpdateWithoutChartRepoUrlOption(unittest.TestCase):
helm.main()
helm.run_dep_update.assert_not_called()
mock_run_command.assert_called_once_with(
- "/usr/bin/helm upgrade -i --reset-values test /tmp/path",
+ "/usr/bin/helm upgrade -i --reset-values test '/tmp/path'",
environ_update={"HELM_NAMESPACE": "test"},
)
assert (
result.exception.args[0]["command"]
- == "/usr/bin/helm upgrade -i --reset-values test /tmp/path"
+ == "/usr/bin/helm upgrade -i --reset-values test '/tmp/path'"
)
def test_dependency_update_option_true(self):
@@ -146,14 +145,14 @@ class TestDependencyUpdateWithoutChartRepoUrlOption(unittest.TestCase):
mock_run_command.assert_has_calls(
[
call(
- "/usr/bin/helm upgrade -i --reset-values test /tmp/path",
+ "/usr/bin/helm upgrade -i --reset-values test '/tmp/path'",
environ_update={"HELM_NAMESPACE": "test"},
)
]
)
assert (
result.exception.args[0]["command"]
- == "/usr/bin/helm upgrade -i --reset-values test /tmp/path"
+ == "/usr/bin/helm upgrade -i --reset-values test '/tmp/path'"
)
def test_dependency_update_option_true_without_dependencies_block(self):
@@ -180,14 +179,14 @@ class TestDependencyUpdateWithoutChartRepoUrlOption(unittest.TestCase):
mock_run_command.assert_has_calls(
[
call(
- "/usr/bin/helm upgrade -i --reset-values test /tmp/path",
+ "/usr/bin/helm upgrade -i --reset-values test '/tmp/path'",
environ_update={"HELM_NAMESPACE": "test"},
)
]
)
assert (
result.exception.args[0]["command"]
- == "/usr/bin/helm upgrade -i --reset-values test /tmp/path"
+ == "/usr/bin/helm upgrade -i --reset-values test '/tmp/path'"
)
@@ -250,12 +249,12 @@ class TestDependencyUpdateWithChartRepoUrlOption(unittest.TestCase):
with self.assertRaises(AnsibleExitJson) as result:
helm.main()
mock_run_command.assert_called_once_with(
- "/usr/bin/helm --repo=http://repo.example/charts upgrade -i --reset-values test chart1",
+ "/usr/bin/helm --repo=http://repo.example/charts upgrade -i --reset-values test 'chart1'",
environ_update={"HELM_NAMESPACE": "test"},
)
assert (
result.exception.args[0]["command"]
- == "/usr/bin/helm --repo=http://repo.example/charts upgrade -i --reset-values test chart1"
+ == "/usr/bin/helm --repo=http://repo.example/charts upgrade -i --reset-values test 'chart1'"
)
def test_dependency_update_option_False(self):
@@ -279,12 +278,12 @@ class TestDependencyUpdateWithChartRepoUrlOption(unittest.TestCase):
with self.assertRaises(AnsibleExitJson) as result:
helm.main()
mock_run_command.assert_called_once_with(
- "/usr/bin/helm --repo=http://repo.example/charts upgrade -i --reset-values test chart1",
+ "/usr/bin/helm --repo=http://repo.example/charts upgrade -i --reset-values test 'chart1'",
environ_update={"HELM_NAMESPACE": "test"},
)
assert (
result.exception.args[0]["command"]
- == "/usr/bin/helm --repo=http://repo.example/charts upgrade -i --reset-values test chart1"
+ == "/usr/bin/helm --repo=http://repo.example/charts upgrade -i --reset-values test 'chart1'"
)
def test_dependency_update_option_True_and_replace_option_disabled(self):
@@ -337,12 +336,12 @@ class TestDependencyUpdateWithChartRepoUrlOption(unittest.TestCase):
with self.assertRaises(AnsibleExitJson) as result:
helm.main()
mock_run_command.assert_called_once_with(
- "/usr/bin/helm --repo=http://repo.example/charts install --dependency-update --replace test chart1",
+ "/usr/bin/helm --repo=http://repo.example/charts install --dependency-update --replace test 'chart1'",
environ_update={"HELM_NAMESPACE": "test"},
)
assert (
result.exception.args[0]["command"]
- == "/usr/bin/helm --repo=http://repo.example/charts install --dependency-update --replace test chart1"
+ == "/usr/bin/helm --repo=http://repo.example/charts install --dependency-update --replace test 'chart1'"
)
@@ -404,12 +403,12 @@ class TestDependencyUpdateWithChartRefIsUrl(unittest.TestCase):
with self.assertRaises(AnsibleExitJson) as result:
helm.main()
mock_run_command.assert_called_once_with(
- "/usr/bin/helm upgrade -i --reset-values test http://repo.example/charts/application.tgz",
+ "/usr/bin/helm upgrade -i --reset-values test 'http://repo.example/charts/application.tgz'",
environ_update={"HELM_NAMESPACE": "test"},
)
assert (
result.exception.args[0]["command"]
- == "/usr/bin/helm upgrade -i --reset-values test http://repo.example/charts/application.tgz"
+ == "/usr/bin/helm upgrade -i --reset-values test 'http://repo.example/charts/application.tgz'"
)
def test_dependency_update_option_False(self):
@@ -432,12 +431,12 @@ class TestDependencyUpdateWithChartRefIsUrl(unittest.TestCase):
with self.assertRaises(AnsibleExitJson) as result:
helm.main()
mock_run_command.assert_called_once_with(
- "/usr/bin/helm upgrade -i --reset-values test http://repo.example/charts/application.tgz",
+ "/usr/bin/helm upgrade -i --reset-values test 'http://repo.example/charts/application.tgz'",
environ_update={"HELM_NAMESPACE": "test"},
)
assert (
result.exception.args[0]["command"]
- == "/usr/bin/helm upgrade -i --reset-values test http://repo.example/charts/application.tgz"
+ == "/usr/bin/helm upgrade -i --reset-values test 'http://repo.example/charts/application.tgz'"
)
def test_dependency_update_option_True_and_replace_option_disabled(self):
@@ -488,10 +487,10 @@ class TestDependencyUpdateWithChartRefIsUrl(unittest.TestCase):
with self.assertRaises(AnsibleExitJson) as result:
helm.main()
mock_run_command.assert_called_once_with(
- "/usr/bin/helm install --dependency-update --replace test http://repo.example/charts/application.tgz",
+ "/usr/bin/helm install --dependency-update --replace test 'http://repo.example/charts/application.tgz'",
environ_update={"HELM_NAMESPACE": "test"},
)
assert (
result.exception.args[0]["command"]
- == "/usr/bin/helm install --dependency-update --replace test http://repo.example/charts/application.tgz"
+ == "/usr/bin/helm install --dependency-update --replace test 'http://repo.example/charts/application.tgz'"
)