From b52497292c77d8af879fb2eaa3f32d0a1a8ba604 Mon Sep 17 00:00:00 2001 From: jeanluc Date: Mon, 12 Aug 2024 19:44:07 +0200 Subject: [PATCH] Fix tests --- pyproject.toml | 2 + tests/functional/cache/test_consul.py | 6 -- tests/unit/modules/test_consul.py | 117 ++++++++++++-------------- tests/unit/pillar/test_consul.py | 3 +- tests/unit/states/test_consul.py | 9 +- 5 files changed, 58 insertions(+), 79 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 2620673..2a0ae2e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -78,6 +78,8 @@ tests = [ "pytest>=7.2.0", "pytest-salt-factories>=1.0.0; sys_platform == 'win32'", "pytest-salt-factories[docker]>=1.0.0; sys_platform != 'win32'", + "pytest-subtests", + "python-consul", ] [project.entry-points."salt.loader"] diff --git a/tests/functional/cache/test_consul.py b/tests/functional/cache/test_consul.py index 0fb553e..df24f65 100644 --- a/tests/functional/cache/test_consul.py +++ b/tests/functional/cache/test_consul.py @@ -13,12 +13,6 @@ log = logging.getLogger(__name__) -pytestmark = [ - pytest.mark.skip_on_fips_enabled_platform, - pytest.mark.slow_test, - pytest.mark.skip_if_binaries_missing("dockerd"), -] - def confirm_consul_is_ready(timeout_at, container): sleeptime = 0.1 diff --git a/tests/unit/modules/test_consul.py b/tests/unit/modules/test_consul.py index 76113cc..e36aeb6 100644 --- a/tests/unit/modules/test_consul.py +++ b/tests/unit/modules/test_consul.py @@ -7,12 +7,13 @@ from unittest.mock import patch import pytest -import salt.modules.consul as consul import salt.utils.http import salt.utils.json import salt.utils.platform from salt.exceptions import SaltInvocationError +from saltext.consul.modules import consul + log = logging.getLogger(__name__) @@ -27,9 +28,6 @@ def configure_loader_modules(): def test_list(): - """ - Test salt.modules.consul.list function - """ mock_query = MagicMock(return_value={"data": ["foo"], "res": True}) with patch.object(consul, "_query", mock_query): consul_return = consul.list_(consul_url="http://127.0.0.1", token="test_token") @@ -38,9 +36,6 @@ def test_list(): def test_get(): - """ - Test salt.modules.consul.get function - """ # # No key argument results in SaltInvocationError, exception # @@ -115,9 +110,6 @@ def test_get(): def test_put(): - """ - Test salt.modules.consul.put function - """ # # No key argument results in SaltInvocationError, exception # @@ -190,9 +182,6 @@ def test_put(): def test_delete(): - """ - Test salt.modules.consul.delete function - """ # # No key argument results in SaltInvocationError, exception # @@ -234,9 +223,6 @@ def test_delete(): def test_agent_maintenance(): - """ - Test consul agent maintenance - """ consul_url = "http://localhost:1313" key = "cluster/key" @@ -248,7 +234,7 @@ def test_agent_maintenance(): # no consul url error with patch.dict(consul.__salt__, {"config.get": mock_nourl}): - with patch.object(salt.modules.consul, "session_list", return_value=mock_result): + with patch.object(consul, "session_list", return_value=mock_result): result = consul.agent_maintenance(consul_url="") expected = {"message": "No Consul URL found.", "res": False} assert expected == result @@ -256,7 +242,7 @@ def test_agent_maintenance(): # no required argument with patch.object(salt.utils.http, "query", return_value=mock_http_result): with patch.dict(consul.__salt__, {"config.get": mock_url}): - with patch.object(salt.modules.consul, "session_list", return_value=mock_result): + with patch.object(consul, "session_list", return_value=mock_result): msg = 'Required parameter "enable" is missing.' result = consul.agent_maintenance(consul_url=consul_url) expected = {"message": msg, "res": False} @@ -264,7 +250,7 @@ def test_agent_maintenance(): with patch.object(salt.utils.http, "query", return_value=mock_http_result): with patch.dict(consul.__salt__, {"config.get": mock_url}): - with patch.object(salt.modules.consul, "session_list", return_value=mock_result): + with patch.object(consul, "session_list", return_value=mock_result): msg = "Agent maintenance mode {}ed." value = "enabl" result = consul.agent_maintenance(consul_url=consul_url, enable=value) @@ -273,7 +259,7 @@ def test_agent_maintenance(): with patch.object(salt.utils.http, "query", return_value=mock_http_result_false): with patch.dict(consul.__salt__, {"config.get": mock_url}): - with patch.object(salt.modules.consul, "session_list", return_value=mock_result): + with patch.object(consul, "session_list", return_value=mock_result): msg = "Unable to change maintenance mode for agent." value = "enabl" result = consul.agent_maintenance(consul_url=consul_url, enable=value) @@ -296,7 +282,7 @@ def test_agent_join(): # no consul url error with patch.dict(consul.__salt__, {"config.get": mock_nourl}): - with patch.object(salt.modules.consul, "session_list", return_value=mock_result): + with patch.object(consul, "session_list", return_value=mock_result): result = consul.agent_join(consul_url="") expected = {"message": "No Consul URL found.", "res": False} assert expected == result @@ -304,13 +290,13 @@ def test_agent_join(): # no required argument with patch.object(salt.utils.http, "query", return_value=mock_http_result): with patch.dict(consul.__salt__, {"config.get": mock_url}): - with patch.object(salt.modules.consul, "session_list", return_value=mock_result): + with patch.object(consul, "session_list", return_value=mock_result): msg = 'Required parameter "address" is missing.' pytest.raises(SaltInvocationError, consul.agent_join, consul_url=consul_url) with patch.object(salt.utils.http, "query", return_value=mock_http_result): with patch.dict(consul.__salt__, {"config.get": mock_url}): - with patch.object(salt.modules.consul, "session_list", return_value=mock_result): + with patch.object(consul, "session_list", return_value=mock_result): msg = "Agent joined the cluster" result = consul.agent_join(consul_url=consul_url, address="test") expected = {"message": msg, "res": True} @@ -318,7 +304,7 @@ def test_agent_join(): with patch.object(salt.utils.http, "query", return_value=mock_http_result_false): with patch.dict(consul.__salt__, {"config.get": mock_url}): - with patch.object(salt.modules.consul, "session_list", return_value=mock_result): + with patch.object(consul, "session_list", return_value=mock_result): msg = "Unable to join the cluster." value = "enabl" result = consul.agent_join(consul_url=consul_url, address="test") @@ -341,7 +327,7 @@ def test_agent_leave(): # no consul url error with patch.dict(consul.__salt__, {"config.get": mock_nourl}): - with patch.object(salt.modules.consul, "session_list", return_value=mock_result): + with patch.object(consul, "session_list", return_value=mock_result): result = consul.agent_join(consul_url="") expected = {"message": "No Consul URL found.", "res": False} assert expected == result @@ -351,12 +337,12 @@ def test_agent_leave(): # no required argument with patch.object(salt.utils.http, "query", return_value=mock_http_result): with patch.dict(consul.__salt__, {"config.get": mock_url}): - with patch.object(salt.modules.consul, "session_list", return_value=mock_result): + with patch.object(consul, "session_list", return_value=mock_result): pytest.raises(SaltInvocationError, consul.agent_leave, consul_url=consul_url) with patch.object(salt.utils.http, "query", return_value=mock_http_result): with patch.dict(consul.__salt__, {"config.get": mock_url}): - with patch.object(salt.modules.consul, "session_list", return_value=mock_result): + with patch.object(consul, "session_list", return_value=mock_result): msg = "Node {} put in leave state." result = consul.agent_leave(consul_url=consul_url, node=node) expected = {"message": msg.format(node), "res": True} @@ -364,7 +350,7 @@ def test_agent_leave(): with patch.object(salt.utils.http, "query", return_value=mock_http_result_false): with patch.dict(consul.__salt__, {"config.get": mock_url}): - with patch.object(salt.modules.consul, "session_list", return_value=mock_result): + with patch.object(consul, "session_list", return_value=mock_result): msg = "Unable to change state for {}." result = consul.agent_leave(consul_url=consul_url, node=node) expected = {"message": msg.format(node), "res": False} @@ -386,7 +372,7 @@ def test_agent_check_register(): # no consul url error with patch.dict(consul.__salt__, {"config.get": mock_nourl}): - with patch.object(salt.modules.consul, "session_list", return_value=mock_result): + with patch.object(consul, "session_list", return_value=mock_result): result = consul.agent_check_register(consul_url="") expected = {"message": "No Consul URL found.", "res": False} assert expected == result @@ -396,7 +382,7 @@ def test_agent_check_register(): # no required arguments with patch.object(salt.utils.http, "query", return_value=mock_http_result): with patch.dict(consul.__salt__, {"config.get": mock_url}): - with patch.object(salt.modules.consul, "session_list", return_value=mock_result): + with patch.object(consul, "session_list", return_value=mock_result): pytest.raises( SaltInvocationError, consul.agent_check_register, @@ -423,7 +409,7 @@ def test_agent_check_register(): with patch.object(salt.utils.http, "query", return_value=mock_http_result): with patch.dict(consul.__salt__, {"config.get": mock_url}): - with patch.object(salt.modules.consul, "session_list", return_value=mock_result): + with patch.object(consul, "session_list", return_value=mock_result): msg = "Check {} added to agent." result = consul.agent_check_register( consul_url=consul_url, @@ -438,7 +424,7 @@ def test_agent_check_register(): with patch.object(salt.utils.http, "query", return_value=mock_http_result_false): with patch.dict(consul.__salt__, {"config.get": mock_url}): - with patch.object(salt.modules.consul, "session_list", return_value=mock_result): + with patch.object(consul, "session_list", return_value=mock_result): msg = "Unable to add check to agent." result = consul.agent_check_register( consul_url=consul_url, @@ -467,7 +453,7 @@ def test_agent_check_deregister(): # no consul url error with patch.dict(consul.__salt__, {"config.get": mock_nourl}): - with patch.object(salt.modules.consul, "session_list", return_value=mock_result): + with patch.object(consul, "session_list", return_value=mock_result): result = consul.agent_check_register(consul_url="") expected = {"message": "No Consul URL found.", "res": False} assert expected == result @@ -477,7 +463,7 @@ def test_agent_check_deregister(): # no required arguments with patch.object(salt.utils.http, "query", return_value=mock_http_result): with patch.dict(consul.__salt__, {"config.get": mock_url}): - with patch.object(salt.modules.consul, "session_list", return_value=mock_result): + with patch.object(consul, "session_list", return_value=mock_result): pytest.raises( SaltInvocationError, consul.agent_check_deregister, @@ -486,7 +472,7 @@ def test_agent_check_deregister(): with patch.object(salt.utils.http, "query", return_value=mock_http_result): with patch.dict(consul.__salt__, {"config.get": mock_url}): - with patch.object(salt.modules.consul, "session_list", return_value=mock_result): + with patch.object(consul, "session_list", return_value=mock_result): msg = "Check {} removed from agent." result = consul.agent_check_deregister(consul_url=consul_url, checkid=checkid) expected = {"message": msg.format(checkid), "res": True} @@ -494,7 +480,7 @@ def test_agent_check_deregister(): with patch.object(salt.utils.http, "query", return_value=mock_http_result_false): with patch.dict(consul.__salt__, {"config.get": mock_url}): - with patch.object(salt.modules.consul, "session_list", return_value=mock_result): + with patch.object(consul, "session_list", return_value=mock_result): msg = "Unable to remove check from agent." result = consul.agent_check_deregister(consul_url=consul_url, checkid=checkid) expected = {"message": msg.format(checkid), "res": False} @@ -516,7 +502,7 @@ def test_agent_check_pass(): # no consul url error with patch.dict(consul.__salt__, {"config.get": mock_nourl}): - with patch.object(salt.modules.consul, "session_list", return_value=mock_result): + with patch.object(consul, "session_list", return_value=mock_result): result = consul.agent_check_register(consul_url="") expected = {"message": "No Consul URL found.", "res": False} assert expected == result @@ -526,7 +512,7 @@ def test_agent_check_pass(): # no required arguments with patch.object(salt.utils.http, "query", return_value=mock_http_result): with patch.dict(consul.__salt__, {"config.get": mock_url}): - with patch.object(salt.modules.consul, "session_list", return_value=mock_result): + with patch.object(consul, "session_list", return_value=mock_result): pytest.raises( SaltInvocationError, consul.agent_check_pass, @@ -535,7 +521,7 @@ def test_agent_check_pass(): with patch.object(salt.utils.http, "query", return_value=mock_http_result): with patch.dict(consul.__salt__, {"config.get": mock_url}): - with patch.object(salt.modules.consul, "session_list", return_value=mock_result): + with patch.object(consul, "session_list", return_value=mock_result): msg = "Check {} marked as passing." result = consul.agent_check_pass(consul_url=consul_url, checkid=checkid) expected = {"message": msg.format(checkid), "res": True} @@ -543,7 +529,7 @@ def test_agent_check_pass(): with patch.object(salt.utils.http, "query", return_value=mock_http_result_false): with patch.dict(consul.__salt__, {"config.get": mock_url}): - with patch.object(salt.modules.consul, "session_list", return_value=mock_result): + with patch.object(consul, "session_list", return_value=mock_result): msg = "Unable to update check {}." result = consul.agent_check_pass(consul_url=consul_url, checkid=checkid) expected = {"message": msg.format(checkid), "res": False} @@ -565,7 +551,7 @@ def test_agent_check_warn(): # no consul url error with patch.dict(consul.__salt__, {"config.get": mock_nourl}): - with patch.object(salt.modules.consul, "session_list", return_value=mock_result): + with patch.object(consul, "session_list", return_value=mock_result): result = consul.agent_check_register(consul_url="") expected = {"message": "No Consul URL found.", "res": False} assert expected == result @@ -575,7 +561,7 @@ def test_agent_check_warn(): # no required arguments with patch.object(salt.utils.http, "query", return_value=mock_http_result): with patch.dict(consul.__salt__, {"config.get": mock_url}): - with patch.object(salt.modules.consul, "session_list", return_value=mock_result): + with patch.object(consul, "session_list", return_value=mock_result): pytest.raises( SaltInvocationError, consul.agent_check_warn, @@ -584,7 +570,7 @@ def test_agent_check_warn(): with patch.object(salt.utils.http, "query", return_value=mock_http_result): with patch.dict(consul.__salt__, {"config.get": mock_url}): - with patch.object(salt.modules.consul, "session_list", return_value=mock_result): + with patch.object(consul, "session_list", return_value=mock_result): msg = "Check {} marked as warning." result = consul.agent_check_warn(consul_url=consul_url, checkid=checkid) expected = {"message": msg.format(checkid), "res": True} @@ -592,7 +578,7 @@ def test_agent_check_warn(): with patch.object(salt.utils.http, "query", return_value=mock_http_result_false): with patch.dict(consul.__salt__, {"config.get": mock_url}): - with patch.object(salt.modules.consul, "session_list", return_value=mock_result): + with patch.object(consul, "session_list", return_value=mock_result): msg = "Unable to update check {}." result = consul.agent_check_warn(consul_url=consul_url, checkid=checkid) expected = {"message": msg.format(checkid), "res": False} @@ -614,7 +600,7 @@ def test_agent_check_fail(): # no consul url error with patch.dict(consul.__salt__, {"config.get": mock_nourl}): - with patch.object(salt.modules.consul, "session_list", return_value=mock_result): + with patch.object(consul, "session_list", return_value=mock_result): result = consul.agent_check_register(consul_url="") expected = {"message": "No Consul URL found.", "res": False} assert expected == result @@ -624,7 +610,7 @@ def test_agent_check_fail(): # no required arguments with patch.object(salt.utils.http, "query", return_value=mock_http_result): with patch.dict(consul.__salt__, {"config.get": mock_url}): - with patch.object(salt.modules.consul, "session_list", return_value=mock_result): + with patch.object(consul, "session_list", return_value=mock_result): pytest.raises( SaltInvocationError, consul.agent_check_fail, @@ -633,7 +619,7 @@ def test_agent_check_fail(): with patch.object(salt.utils.http, "query", return_value=mock_http_result): with patch.dict(consul.__salt__, {"config.get": mock_url}): - with patch.object(salt.modules.consul, "session_list", return_value=mock_result): + with patch.object(consul, "session_list", return_value=mock_result): msg = "Check {} marked as critical." result = consul.agent_check_fail(consul_url=consul_url, checkid=checkid) expected = {"message": msg.format(checkid), "res": True} @@ -641,7 +627,7 @@ def test_agent_check_fail(): with patch.object(salt.utils.http, "query", return_value=mock_http_result_false): with patch.dict(consul.__salt__, {"config.get": mock_url}): - with patch.object(salt.modules.consul, "session_list", return_value=mock_result): + with patch.object(consul, "session_list", return_value=mock_result): msg = "Unable to update check {}." result = consul.agent_check_fail(consul_url=consul_url, checkid=checkid) expected = {"message": msg.format(checkid), "res": False} @@ -663,7 +649,7 @@ def test_agent_service_register(): # no consul url error with patch.dict(consul.__salt__, {"config.get": mock_nourl}): - with patch.object(salt.modules.consul, "session_list", return_value=mock_result): + with patch.object(consul, "session_list", return_value=mock_result): result = consul.agent_service_register(consul_url="") expected = {"message": "No Consul URL found.", "res": False} assert expected == result @@ -673,7 +659,7 @@ def test_agent_service_register(): # no required arguments with patch.object(salt.utils.http, "query", return_value=mock_http_result): with patch.dict(consul.__salt__, {"config.get": mock_url}): - with patch.object(salt.modules.consul, "session_list", return_value=mock_result): + with patch.object(consul, "session_list", return_value=mock_result): pytest.raises( SaltInvocationError, consul.agent_service_register, @@ -682,7 +668,7 @@ def test_agent_service_register(): with patch.object(salt.utils.http, "query", return_value=mock_http_result): with patch.dict(consul.__salt__, {"config.get": mock_url}): - with patch.object(salt.modules.consul, "session_list", return_value=mock_result): + with patch.object(consul, "session_list", return_value=mock_result): msg = "Service {} registered on agent." result = consul.agent_service_register( consul_url=consul_url, @@ -697,7 +683,7 @@ def test_agent_service_register(): with patch.object(salt.utils.http, "query", return_value=mock_http_result_false): with patch.dict(consul.__salt__, {"config.get": mock_url}): - with patch.object(salt.modules.consul, "session_list", return_value=mock_result): + with patch.object(consul, "session_list", return_value=mock_result): msg = "Unable to register service {}." result = consul.agent_service_register( consul_url=consul_url, @@ -726,7 +712,7 @@ def test_agent_service_deregister(): # no consul url error with patch.dict(consul.__salt__, {"config.get": mock_nourl}): - with patch.object(salt.modules.consul, "session_list", return_value=mock_result): + with patch.object(consul, "session_list", return_value=mock_result): result = consul.agent_service_deregister(consul_url="") expected = {"message": "No Consul URL found.", "res": False} assert expected == result @@ -736,7 +722,7 @@ def test_agent_service_deregister(): # no required arguments with patch.object(salt.utils.http, "query", return_value=mock_http_result): with patch.dict(consul.__salt__, {"config.get": mock_url}): - with patch.object(salt.modules.consul, "session_list", return_value=mock_result): + with patch.object(consul, "session_list", return_value=mock_result): pytest.raises( SaltInvocationError, consul.agent_service_deregister, @@ -745,7 +731,7 @@ def test_agent_service_deregister(): with patch.object(salt.utils.http, "query", return_value=mock_http_result): with patch.dict(consul.__salt__, {"config.get": mock_url}): - with patch.object(salt.modules.consul, "session_list", return_value=mock_result): + with patch.object(consul, "session_list", return_value=mock_result): msg = "Service {} removed from agent." result = consul.agent_service_deregister(consul_url=consul_url, serviceid=serviceid) expected = {"message": msg.format(serviceid), "res": True} @@ -753,7 +739,7 @@ def test_agent_service_deregister(): with patch.object(salt.utils.http, "query", return_value=mock_http_result_false): with patch.dict(consul.__salt__, {"config.get": mock_url}): - with patch.object(salt.modules.consul, "session_list", return_value=mock_result): + with patch.object(consul, "session_list", return_value=mock_result): msg = "Unable to remove service {}." result = consul.agent_service_deregister(consul_url=consul_url, serviceid=serviceid) expected = {"message": msg.format(serviceid), "res": False} @@ -775,7 +761,7 @@ def test_agent_service_maintenance(): # no consul url error with patch.dict(consul.__salt__, {"config.get": mock_nourl}): - with patch.object(salt.modules.consul, "session_list", return_value=mock_result): + with patch.object(consul, "session_list", return_value=mock_result): result = consul.agent_service_maintenance(consul_url="") expected = {"message": "No Consul URL found.", "res": False} assert expected == result @@ -785,7 +771,7 @@ def test_agent_service_maintenance(): # no required arguments with patch.object(salt.utils.http, "query", return_value=mock_http_result): with patch.dict(consul.__salt__, {"config.get": mock_url}): - with patch.object(salt.modules.consul, "session_list", return_value=mock_result): + with patch.object(consul, "session_list", return_value=mock_result): pytest.raises( SaltInvocationError, consul.agent_service_maintenance, @@ -802,7 +788,7 @@ def test_agent_service_maintenance(): with patch.object(salt.utils.http, "query", return_value=mock_http_result): with patch.dict(consul.__salt__, {"config.get": mock_url}): - with patch.object(salt.modules.consul, "session_list", return_value=mock_result): + with patch.object(consul, "session_list", return_value=mock_result): msg = "Service {} set in maintenance mode." result = consul.agent_service_maintenance( consul_url=consul_url, serviceid=serviceid, enable=True @@ -812,7 +798,7 @@ def test_agent_service_maintenance(): with patch.object(salt.utils.http, "query", return_value=mock_http_result_false): with patch.dict(consul.__salt__, {"config.get": mock_url}): - with patch.object(salt.modules.consul, "session_list", return_value=mock_result): + with patch.object(consul, "session_list", return_value=mock_result): msg = "Unable to set service {} to maintenance mode." result = consul.agent_service_maintenance( consul_url=consul_url, serviceid=serviceid, enable=True @@ -836,7 +822,7 @@ def test_session_create(): # no consul url error with patch.dict(consul.__salt__, {"config.get": mock_nourl}): - with patch.object(salt.modules.consul, "session_list", return_value=mock_result): + with patch.object(consul, "session_list", return_value=mock_result): result = consul.session_create(consul_url="") expected = {"message": "No Consul URL found.", "res": False} assert expected == result @@ -846,7 +832,7 @@ def test_session_create(): # no required arguments with patch.object(salt.utils.http, "query", return_value=mock_http_result): with patch.dict(consul.__salt__, {"config.get": mock_url}): - with patch.object(salt.modules.consul, "session_list", return_value=mock_result): + with patch.object(consul, "session_list", return_value=mock_result): pytest.raises( SaltInvocationError, consul.session_create, @@ -855,7 +841,7 @@ def test_session_create(): with patch.object(salt.utils.http, "query", return_value=mock_http_result): with patch.dict(consul.__salt__, {"config.get": mock_url}): - with patch.object(salt.modules.consul, "session_list", return_value=mock_result): + with patch.object(consul, "session_list", return_value=mock_result): msg = "Created session {}." result = consul.session_create(consul_url=consul_url, name=name) expected = {"message": msg.format(name), "res": True} @@ -863,7 +849,7 @@ def test_session_create(): with patch.object(salt.utils.http, "query", return_value=mock_http_result_false): with patch.dict(consul.__salt__, {"config.get": mock_url}): - with patch.object(salt.modules.consul, "session_list", return_value=mock_result): + with patch.object(consul, "session_list", return_value=mock_result): msg = "Unable to create session {}." result = consul.session_create(consul_url=consul_url, name=name) expected = {"message": msg.format(name), "res": False} @@ -1509,8 +1495,9 @@ def test_acl_create(): "http://localhost:1313/v1/acl/create", method="PUT", params={}, - data='{"Name": "name1", "Rules": [{"node": "host.example.local", "policy": "write"}, {"agent": "host.example.local", "policy": "write"}, {"session": "host.example.local", "policy": "write"}, {"key": "", "policy": "read"}, {"service": "", "policy": "read"}]}', + data='{"Name": "name1", "Rules": "node \\"host.example.local\\" {\\n policy = \\"write\\"\\n}\\nagent \\"host.example.local\\" {\\n policy = \\"write\\"\\n}\\nsession \\"host.example.local\\" {\\n policy = \\"write\\"\\n}\\nkey \\"\\" {\\n policy = \\"read\\"\\n}\\nservice \\"\\" {\\n policy = \\"read\\"\\n}\\n"}', decode=True, + text=False, status=True, header_dict={"X-Consul-Token": "randomtoken", "Content-Type": "application/json"}, opts={"consul": {"url": "http://127.0.0.1", "token": "test_token"}}, diff --git a/tests/unit/pillar/test_consul.py b/tests/unit/pillar/test_consul.py index 8682dd6..ff46a32 100644 --- a/tests/unit/pillar/test_consul.py +++ b/tests/unit/pillar/test_consul.py @@ -2,7 +2,8 @@ from unittest.mock import patch import pytest -import salt.pillar.consul_pillar as consul_pillar + +from saltext.consul.pillar import consul_pillar pytestmark = [ pytest.mark.skipif(not consul_pillar.consul, reason="python-consul module not installed") diff --git a/tests/unit/states/test_consul.py b/tests/unit/states/test_consul.py index f706eab..2df99c1 100644 --- a/tests/unit/states/test_consul.py +++ b/tests/unit/states/test_consul.py @@ -7,7 +7,8 @@ from unittest.mock import patch import pytest -import salt.states.consul as consul + +from saltext.consul.states import consul log = logging.getLogger(__name__) @@ -26,9 +27,6 @@ def configure_loader_modules(): def test_acl_present(): - """ - Test salt.states.consul.acl_present function - """ acl_info = { "data": [ { @@ -88,9 +86,6 @@ def test_acl_present(): def test_acl_absent(): - """ - Test salt.states.consul.acl_absent function - """ # # Test when the ACL does exist #