From 3643e424fac09c9d4e89506f0497a1bf9d0e1ed1 Mon Sep 17 00:00:00 2001 From: Alan Malta Rodrigues Date: Tue, 15 Aug 2023 11:29:19 -0400 Subject: [PATCH] update unit tests --- test/python/Utils_t/Utilities_t.py | 12 ++++++++++- .../python/WMCore_t/BossAir_t/BasePlugin_t.py | 21 +++++++++++++++++++ 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/test/python/Utils_t/Utilities_t.py b/test/python/Utils_t/Utilities_t.py index 96ac6bba69..d416e965fc 100644 --- a/test/python/Utils_t/Utilities_t.py +++ b/test/python/Utils_t/Utilities_t.py @@ -8,7 +8,7 @@ from Utils.Utilities import makeList, makeNonEmptyList, strToBool, \ safeStr, rootUrlJoin, zipEncodeStr, lowerCmsHeaders, getSize, \ - encodeUnicodeToBytes, diskUse, numberCouchProcess + encodeUnicodeToBytes, diskUse, numberCouchProcess, orderVersionList class UtilitiesTests(unittest.TestCase): @@ -180,6 +180,16 @@ def testNumberCouchProcess(self): # there should be at least one process, but who knows... self.assertTrue(data >= 0) + def testOrderVersionList(self): + """ + Test the `orderVersionList` function. + """ + oldL = ["2.3.1", "1.2.3", "3.2.1", "1.3.2", "1.2"] + newL = ["1.2", "1.2.3", "1.3.2", "2.3.1", "3.2.1"] + with self.assertRaises(AssertionError): + self.assertListEqual(oldL, newL) + self.assertListEqual(orderVersionList(oldL), newL) + if __name__ == '__main__': unittest.main() diff --git a/test/python/WMCore_t/BossAir_t/BasePlugin_t.py b/test/python/WMCore_t/BossAir_t/BasePlugin_t.py index 40fe122925..4b37a38504 100644 --- a/test/python/WMCore_t/BossAir_t/BasePlugin_t.py +++ b/test/python/WMCore_t/BossAir_t/BasePlugin_t.py @@ -78,5 +78,26 @@ def testScramArchtoRequiredArch(self): return + def testCudaCapabilityToSingleVersion(self): + """ + Test conversion of a list of version strings to a single integer version + """ + bp = BasePlugin(config=None) + + # bad input + self.assertEqual(bp.cudaCapabilityToSingleVersion([]), 0) + self.assertEqual(bp.cudaCapabilityToSingleVersion({}), 0) + self.assertEqual(bp.cudaCapabilityToSingleVersion(None), 0) + # good and expected input + unorderedL = ["2.3.1", "1.2.3", "3.2.1", "1.3.2", "1.2"] + self.assertEqual(bp.cudaCapabilityToSingleVersion(unorderedL), 1020) + orderedL = ["1.2", "1.2.3", "1.3.2", "2.3.1", "3.2.1"] + self.assertEqual(bp.cudaCapabilityToSingleVersion(orderedL), 1020) + orderedL = ["1.2.3", "1.3.2", "2.3.1", "3.2.1"] + self.assertEqual(bp.cudaCapabilityToSingleVersion(orderedL), 1023) + orderedL = ["2.3.1", "3.2.1"] + self.assertEqual(bp.cudaCapabilityToSingleVersion(orderedL), 2031) + + if __name__ == '__main__': unittest.main()