Skip to content

Commit

Permalink
unit test changes
Browse files Browse the repository at this point in the history
  • Loading branch information
amaltaro committed Dec 5, 2024
1 parent 87e4c6f commit 608f2c5
Showing 1 changed file with 17 additions and 4 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()

0 comments on commit 608f2c5

Please sign in to comment.