Skip to content

Commit

Permalink
fix: remove any mention of setup from the tests
Browse files Browse the repository at this point in the history
  • Loading branch information
atsareg committed Sep 12, 2024
1 parent 4f554fc commit 207152f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 43 deletions.
26 changes: 10 additions & 16 deletions src/DIRAC/ConfigurationSystem/Client/test/Test_PathFinder.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,19 +64,17 @@ def pathFinder(monkeypatch):


@pytest.mark.parametrize(
"system, componentName, setup, componentType, result",
"system, componentName, componentType, result",
[
(
"WorkloadManagement/SandboxStoreHandler",
False,
False,
"Services",
"/Systems/WorkloadManagement/MyWM/Services/SandboxStoreHandler",
),
(
"WorkloadManagement",
"SandboxStoreHandler",
False,
"Services",
"/Systems/WorkloadManagement/MyWM/Services/SandboxStoreHandler",
),
Expand All @@ -85,26 +83,24 @@ def pathFinder(monkeypatch):
(
"WorkloadManagement/SimpleLogConsumer",
False,
False,
"NonRonsumersNon",
"/Systems/WorkloadManagement/MyWM/NonRonsumersNon/SimpleLogConsumer",
),
],
)
def test_getComponentSection(pathFinder, system, componentName, setup, componentType, result):
def test_getComponentSection(pathFinder, system, componentName, componentType, result):
"""Test getComponentSection"""
assert pathFinder.getComponentSection(system, componentName, setup, componentType) == result
assert pathFinder.getComponentSection(system, componentName, componentType) == result


@pytest.mark.parametrize(
"system, setup, result",
"system, result",
[
("WorkloadManagement", False, "/Systems/WorkloadManagement/MyWM/URLs"),
("WorkloadManagement", "TestSetup", "/Systems/WorkloadManagement/MyWM/URLs"),
("WorkloadManagement", "/Systems/WorkloadManagement/MyWM/URLs"),
],
)
def test_getSystemURLSection(pathFinder, system, setup, result):
assert pathFinder.getSystemURLs(system, setup)
def test_getSystemURLSection(pathFinder, system, result):
assert pathFinder.getSystemURLs(system)


@pytest.mark.parametrize(
Expand Down Expand Up @@ -200,11 +196,10 @@ def test_getServiceURLs(pathFinder, serviceName, service, failover, result):


@pytest.mark.parametrize(
"system, setup, failover, result",
"system, failover, result",
[
(
"WorkloadManagement",
None,
False,
{
"Service1": {"dips://server1:1234/WorkloadManagement/Service1"},
Expand All @@ -216,7 +211,6 @@ def test_getServiceURLs(pathFinder, serviceName, service, failover, result):
),
(
"WorkloadManagement",
None,
True,
{
"Service1": {"dips://server1:1234/WorkloadManagement/Service1"},
Expand All @@ -230,8 +224,8 @@ def test_getServiceURLs(pathFinder, serviceName, service, failover, result):
),
],
)
def test_getSystemURLs(pathFinder, system, setup, failover, result):
sysDict = pathFinder.getSystemURLs(system, setup=setup, failover=failover)
def test_getSystemURLs(pathFinder, system, failover, result):
sysDict = pathFinder.getSystemURLs(system, failover=failover)
for service in sysDict:
assert set(sysDict[service]) == result[service]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,6 @@ def clientMock(ret):
return clientModuleMock


def mockComponentSection(*_args, **kwargs):
"""Mock the PathFinder.getComponentSection to return individual componentSections."""
system = kwargs.get("system")
component = kwargs.get("component")
return f"/Systems/{system}/Production/Services/{component}"


def mockURLSection(*_args, **kwargs):
"""Mock the PathFinder.getSystemURLSection to return individual componentSections."""
system = kwargs.get("system")
return f"/Systems/{system}/Production/URLs/"


class TestComponentSupervisionAgent(unittest.TestCase):
"""TestComponentSupervisionAgent class."""

Expand Down Expand Up @@ -680,12 +667,6 @@ def gVal(*args, **_kwargs):

with patch("DIRAC.FrameworkSystem.Agent.ComponentSupervisionAgent.gConfig", new=gConfigMock), patch(
"DIRAC.FrameworkSystem.Agent.ComponentSupervisionAgent.socket.gethostname", return_value=host
), patch(
"DIRAC.FrameworkSystem.Agent.ComponentSupervisionAgent.PathFinder.getComponentSection",
side_effect=mockComponentSection,
), patch(
"DIRAC.FrameworkSystem.Agent.ComponentSupervisionAgent.PathFinder.getSystemURLSection",
side_effect=mockURLSection,
):
res = self.restartAgent.checkURLs()
self.assertTrue(res["OK"])
Expand All @@ -707,20 +688,14 @@ def test_checkURLs_2(self):
self.restartAgent.sysAdminClient.getOverallStatus.return_value = S_OK(dict(Services={}))

self.restartAgent.csAPI.commit = MagicMock(return_value=S_ERROR("Nope"))
with patch("DIRAC.FrameworkSystem.Agent.ComponentSupervisionAgent.gConfig", new=MagicMock()), patch(
"DIRAC.FrameworkSystem.Agent.ComponentSupervisionAgent.PathFinder.getComponentSection",
side_effect=mockComponentSection,
):
with patch("DIRAC.FrameworkSystem.Agent.ComponentSupervisionAgent.gConfig", new=MagicMock()):
res = self.restartAgent.checkURLs()
self.assertFalse(res["OK"])
self.assertIn("Failed to commit", res["Message"])
self.assertIn("Commit to CS failed", self.restartAgent.errors[0])

self.restartAgent.csAPI.commit = MagicMock(return_value=S_OK())
with patch("DIRAC.FrameworkSystem.Agent.ComponentSupervisionAgent.gConfig", new=MagicMock()), patch(
"DIRAC.FrameworkSystem.Agent.ComponentSupervisionAgent.PathFinder.getComponentSection",
side_effect=mockComponentSection,
):
with patch("DIRAC.FrameworkSystem.Agent.ComponentSupervisionAgent.gConfig", new=MagicMock()):
res = self.restartAgent.checkURLs()
self.assertTrue(res["OK"])

Expand Down

0 comments on commit 207152f

Please sign in to comment.