2019-03-23 23:16:03 +00:00
|
|
|
import unittest
|
|
|
|
|
|
|
|
from tutor import utils
|
|
|
|
|
|
|
|
|
|
|
|
class UtilsTests(unittest.TestCase):
|
|
|
|
def test_common_domain(self):
|
2019-05-11 17:19:41 +00:00
|
|
|
self.assertEqual(
|
|
|
|
"domain.com", utils.common_domain("sub1.domain.com", "sub2.domain.com")
|
|
|
|
)
|
|
|
|
self.assertEqual(
|
|
|
|
"sub1.domain.com",
|
|
|
|
utils.common_domain("sub1.domain.com", "sub2.sub1.domain.com"),
|
|
|
|
)
|
2019-03-23 23:16:03 +00:00
|
|
|
self.assertEqual("com", utils.common_domain("domain1.com", "domain2.com"))
|
2019-05-11 17:19:41 +00:00
|
|
|
self.assertEqual(
|
|
|
|
"domain.com", utils.common_domain("sub.domain.com", "ub.domain.com")
|
|
|
|
)
|
2019-03-24 21:24:50 +00:00
|
|
|
|
2019-05-11 22:11:44 +00:00
|
|
|
def test_reverse_host(self):
|
|
|
|
self.assertEqual("com.google.www", utils.reverse_host("www.google.com"))
|
2019-11-22 08:20:17 +00:00
|
|
|
|
|
|
|
def test_list_if(self):
|
|
|
|
self.assertEqual('["cms"]', utils.list_if([("lms", False), ("cms", True)]))
|