Skip to content

Commit

Permalink
unit test changes
Browse files Browse the repository at this point in the history
more unit test fixes
  • Loading branch information
amaltaro committed Dec 10, 2024
1 parent 982cfda commit 45eaf42
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 8 deletions.
21 changes: 17 additions & 4 deletions test/python/Utils_t/Patterns_t.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,17 @@
Patterns_t module provide unit tests for Patterns module
Unittests for Utilities functions
"""


import time
import unittest
from Utils.Patterns import Singleton
from Utils.Patterns import Singleton, getDomainName


class Test(object, metaclass=Singleton):#Test(with_metaclass(Singleton, object)):
class Test(object, metaclass=Singleton):
"Example of Singleton class"
def __init__(self):
self.time = time.time()


class PatternsTests(unittest.TestCase):
"""
unittest for Patterns functions
Expand All @@ -27,5 +26,19 @@ def testSingleton(self):
self.assertEqual(obj1.time, obj2.time)
self.assertEqual(id(obj1), id(obj2))


def testGetDomainName(self):
"Test the getDomainName function"
# test with http protocol
self.assertEqual(getDomainName("http://cmsweb.cern.ch/blah/two"), "cmsweb")
# test with https protocol
self.assertEqual(getDomainName("https://cmsweb.cern.ch/blah/two"), "cmsweb")
self.assertEqual(getDomainName("https://cmsweb-testbed.cern.ch"), "cmsweb-testbed")
self.assertEqual(getDomainName("https://cmsweb-preprod.cern.ch"), "cmsweb-preprod")
self.assertEqual(getDomainName("https://cmsweb-test3.cern.ch"), "cmsweb-test3")
# test with unexpected/wrong URL
self.assertEqual(getDomainName("https://cmsweb.blah.ch"), "")


if __name__ == '__main__':
unittest.main()
Original file line number Diff line number Diff line change
Expand Up @@ -96,15 +96,17 @@ def _queryAndCompareWithDBS(self, pileupDict, pileupConfig, dbsUrl):

for dataset in datasets:
dbsBlocks = reader.listFileBlocks(dataset=dataset)
rucioBlocksLocation = rucioObj.getPileupLockedAndAvailable(dataset,
account=self.rucioAcct)
rucioBlocks = rucioObj.getBlocksInContainer(container=dataset)
print(f"DBS knows {len(dbsBlocks)} while Rucio knows {len(rucioBlocks)} blocks for {dataset}")
# now pileup data location comes from MSPileup (from MockMSPileupAPI)
rucioBlocksLocation = ["T2_XX_SiteA", "T2_XX_SiteB", "T2_XX_SiteC"]

# first, validate the number of blocks and their names
self.assertItemsEqual(list(blockDict), dbsBlocks)
self.assertItemsEqual(list(blockDict), list(rucioBlocksLocation))
self.assertItemsEqual(list(blockDict), rucioBlocks)
# now validate the block location between Rucio and PileupFetcher
for block, blockLocation in viewitems(blockDict):
self.assertItemsEqual(blockLocation['PhEDExNodeNames'], rucioBlocksLocation[block])
self.assertItemsEqual(blockLocation['PhEDExNodeNames'], rucioBlocksLocation)

# finally, validate the files
fileList = []
Expand Down

0 comments on commit 45eaf42

Please sign in to comment.