From 8816ea1d3f508bb92bb25c487801488dd5fcc8e3 Mon Sep 17 00:00:00 2001 From: Federico Stagni Date: Thu, 12 Oct 2023 16:54:11 +0200 Subject: [PATCH] test: fixed test to correct version --- Pilot/pilotTools.py | 4 ++-- Pilot/tests/Test_simplePilotLogger.py | 28 +++++++++++++-------------- 2 files changed, 15 insertions(+), 17 deletions(-) diff --git a/Pilot/pilotTools.py b/Pilot/pilotTools.py index 6ae5101e..8c9b70e3 100644 --- a/Pilot/pilotTools.py +++ b/Pilot/pilotTools.py @@ -1152,10 +1152,10 @@ def __getSearchPaths(self): vo = self.__getVO() paths = [ "/Defaults/Pilot", - "/%s/Pilot" % vo, "/%s/Pilot" % self.setup, "/%s/Defaults/Pilot" % vo, "/%s/%s/Pilot" % (vo, self.setup), + "/%s/Pilot" % vo, ] return paths @@ -1163,7 +1163,7 @@ def __getSearchPaths(self): @staticmethod def getOptionForPaths(paths, inDict): """ - Get the preferred option from an input dict passed ond a path list. It modifies the inDict. + Get the preferred option from an input dict passed and a path list. It modifies the inDict. :param list paths: list of paths to walk through to get a preferred option. An option found in a path which comes later has a preference over options found in earlier paths. diff --git a/Pilot/tests/Test_simplePilotLogger.py b/Pilot/tests/Test_simplePilotLogger.py index fea8e98a..e900baf9 100644 --- a/Pilot/tests/Test_simplePilotLogger.py +++ b/Pilot/tests/Test_simplePilotLogger.py @@ -4,9 +4,9 @@ import json import os -import sys -import string import random +import string +import sys import tempfile try: @@ -49,13 +49,19 @@ def test_getOptionForPaths(self): jsonFile = os.path.join(basedir, "../../tests/CI/pilot_newSchema.json") vo = "gridpp" setup = "DIRAC-Certification" - paths = ["/Defaults/Pilot", "/%s/Pilot" % setup, "/%s/Defaults/Pilot" % vo, "/%s/%s/Pilot" % (vo, setup)] + paths = [ + "/Defaults/Pilot", + "/%s/Pilot" % setup, + "/%s/Defaults/Pilot" % vo, + "/%s/%s/Pilot" % (vo, setup), + "/%s/Pilot" % vo + ] with open(jsonFile, "r") as fp: jsonDict = json.load(fp) res = PilotParams.getOptionForPaths(paths, jsonDict) self.assertEqual(res["RemoteLogging"], "True") self.assertEqual(res["UploadSE"], "UKI-LT2-IC-HEP-disk") - del jsonDict[vo][setup]["Pilot"]["RemoteLogging"] # remove a vo-specific settings, a default value is False: + del jsonDict[vo]["Pilot"]["RemoteLogging"] # remove a vo-specific settings, a default value is False: res = PilotParams.getOptionForPaths(paths, jsonDict) self.assertEqual(res["RemoteLogging"], "False") @@ -80,19 +86,11 @@ def test_pilotOptions(self, argvmock, mockPaths): "/%s/Pilot" % setup, "/%s/Defaults/Pilot" % vo, "/%s/%s/Pilot" % (vo, setup), + "/%s/Pilot" % vo ] mockPaths.return_value = paths pp = PilotParams() - lTESTcommands = [ - "CheckWorkerNode", - "InstallDIRAC", - "ConfigureBasics", - "CheckCECapabilities", - "CheckWNCapabilities", - "ConfigureSite", - "ConfigureArchitecture", - "ConfigureCPURequirements", - ] + lTESTcommands = "CheckWorkerNode, InstallDIRAC, ConfigureBasics, RegisterPilot, CheckCECapabilities, CheckWNCapabilities, ConfigureSite, ConfigureArchitecture, ConfigureCPURequirements" pp.gridCEType = "TEST" @@ -105,7 +103,7 @@ def test_pilotOptions(self, argvmock, mockPaths): self.assertEqual(res.get("UploadPath"), "/gridpp/pilotlogs/") self.assertTrue("Commands" in res) self.assertEqual(res["Commands"].get(pp.gridCEType), lTESTcommands) - self.assertEqual(pp.commands, lTESTcommands) + self.assertEqual(', '.join(pp.commands), lTESTcommands) self.assertEqual(pp.releaseVersion, "VAR_DIRAC_VERSION")