#157 #165
@ -1,5 +1,7 @@
|
||||
import unittest
|
||||
|
||||
from unittests_core.utils.credential_manager_test_case import CredentialManagerTestCase
|
||||
from unittests_core.utils.json_processor_test_case import JSONProcessorTestCase
|
||||
from unittests_core.utils.string_test_case import StringTestCase
|
||||
|
||||
|
||||
@ -8,6 +10,8 @@ class CoreTestSuite(unittest.TestSuite):
|
||||
unittest.TestSuite.__init__(self)
|
||||
|
||||
loader = unittest.TestLoader()
|
||||
self.addTests(loader.loadTestsFromTestCase(CredentialManagerTestCase))
|
||||
self.addTests(loader.loadTestsFromTestCase(JSONProcessorTestCase))
|
||||
self.addTests(loader.loadTestsFromTestCase(StringTestCase))
|
||||
|
||||
def run(self, *args):
|
||||
|
@ -1,10 +1,40 @@
|
||||
import unittest
|
||||
|
||||
from cpl_core.utils import CredentialManager
|
||||
|
||||
|
||||
class CredentialManagerTestCase(unittest.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
pass
|
||||
|
||||
def test_equal(self):
|
||||
pass
|
||||
def test_encrypt(self):
|
||||
self.assertEqual("ZkVjSkplQUx4aW1zWHlPbA==", CredentialManager.encrypt("fEcJJeALximsXyOl"))
|
||||
self.assertEqual("QmtVd1l4dW5Sck9jRmVTQQ==", CredentialManager.encrypt("BkUwYxunRrOcFeSA"))
|
||||
self.assertEqual("c2FtaHF1VkNSdmZpSGxDcQ==", CredentialManager.encrypt("samhquVCRvfiHlCq"))
|
||||
self.assertEqual("S05aWHBPYW9DbkRSV01rWQ==", CredentialManager.encrypt("KNZXpOaoCnDRWMkY"))
|
||||
self.assertEqual("QmtUV0Zsb3h1Y254UkJWeg==", CredentialManager.encrypt("BkTWFloxucnxRBVz"))
|
||||
self.assertEqual("VFdNTkRuYXB1b1dndXNKdw==", CredentialManager.encrypt("TWMNDnapuoWgusJw"))
|
||||
self.assertEqual("WVRiQXVSZXRMblpicWNrcQ==", CredentialManager.encrypt("YTbAuRetLnZbqckq"))
|
||||
self.assertEqual("bmN4aExackxhYUVVdnV2VA==", CredentialManager.encrypt("ncxhLZrLaaEUvuvT"))
|
||||
self.assertEqual("dmpNT0J5U0lLQmFrc0pIYQ==", CredentialManager.encrypt("vjMOBySIKBaksJHa"))
|
||||
self.assertEqual("ZHd6WHFzSlFvQlhRbGtVZw==", CredentialManager.encrypt("dwzXqsJQoBXQlkUg"))
|
||||
self.assertEqual("Q0lmUUhOREtiUmxnY2VCbQ==", CredentialManager.encrypt("CIfQHNDKbRlgceBm"))
|
||||
|
||||
def test_decrypt(self):
|
||||
self.assertEqual("fEcJJeALximsXyOl", CredentialManager.decrypt("ZkVjSkplQUx4aW1zWHlPbA=="))
|
||||
self.assertEqual("BkUwYxunRrOcFeSA", CredentialManager.decrypt("QmtVd1l4dW5Sck9jRmVTQQ=="))
|
||||
self.assertEqual("samhquVCRvfiHlCq", CredentialManager.decrypt("c2FtaHF1VkNSdmZpSGxDcQ=="))
|
||||
self.assertEqual("KNZXpOaoCnDRWMkY", CredentialManager.decrypt("S05aWHBPYW9DbkRSV01rWQ=="))
|
||||
self.assertEqual("BkTWFloxucnxRBVz", CredentialManager.decrypt("QmtUV0Zsb3h1Y254UkJWeg=="))
|
||||
self.assertEqual("TWMNDnapuoWgusJw", CredentialManager.decrypt("VFdNTkRuYXB1b1dndXNKdw=="))
|
||||
self.assertEqual("YTbAuRetLnZbqckq", CredentialManager.decrypt("WVRiQXVSZXRMblpicWNrcQ=="))
|
||||
self.assertEqual("ncxhLZrLaaEUvuvT", CredentialManager.decrypt("bmN4aExackxhYUVVdnV2VA=="))
|
||||
self.assertEqual("vjMOBySIKBaksJHa", CredentialManager.decrypt("dmpNT0J5U0lLQmFrc0pIYQ=="))
|
||||
self.assertEqual("dwzXqsJQoBXQlkUg", CredentialManager.decrypt("ZHd6WHFzSlFvQlhRbGtVZw=="))
|
||||
self.assertEqual("CIfQHNDKbRlgceBm", CredentialManager.decrypt("Q0lmUUhOREtiUmxnY2VCbQ=="))
|
||||
|
||||
def test_build_string(self):
|
||||
self.assertEqual(
|
||||
"TestStringWithCredentialsfEcJJeALximsXyOlHere",
|
||||
CredentialManager.build_string("TestStringWithCredentials$credentialsHere", "ZkVjSkplQUx4aW1zWHlPbA=="),
|
||||
)
|
||||
|
38
unittests/unittests_core/utils/json_processor_test_case.py
Normal file
38
unittests/unittests_core/utils/json_processor_test_case.py
Normal file
@ -0,0 +1,38 @@
|
||||
import unittest
|
||||
|
||||
from cpl_core.utils.json_processor import JSONProcessor
|
||||
|
||||
|
||||
class SubTestClass:
|
||||
def __init__(self, value: str = None):
|
||||
self.value = value
|
||||
|
||||
|
||||
class TestClass:
|
||||
def __init__(self, i: int = None, s: str = None, d: dict = None, l: list = None, value: SubTestClass = None):
|
||||
self.i = i
|
||||
self.s = s
|
||||
self.d = d
|
||||
self.l = l
|
||||
self.value = value
|
||||
|
||||
|
||||
class JSONProcessorTestCase(unittest.TestCase):
|
||||
def setUp(self):
|
||||
pass
|
||||
|
||||
def test_process(self):
|
||||
test_dict = {
|
||||
"i": 10,
|
||||
"s": "Hello World",
|
||||
"d": {"test": "Test"},
|
||||
"l": range(0, 11),
|
||||
"value": {"value": "Hello World"},
|
||||
}
|
||||
test: TestClass = JSONProcessor.process(TestClass, test_dict)
|
||||
|
||||
self.assertEqual(test.i, test_dict["i"])
|
||||
self.assertEqual(test.s, test_dict["s"])
|
||||
self.assertEqual(test.d, test_dict["d"])
|
||||
self.assertEqual(test.l, test_dict["l"])
|
||||
self.assertEqual(test.value.value, test_dict["value"]["value"])
|
@ -5,7 +5,6 @@ from cpl_core.utils import String
|
||||
|
||||
|
||||
class StringTestCase(unittest.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
pass
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user