Compare commits
6 Commits
1b60debba7
...
75fde0f444
Author | SHA1 | Date | |
---|---|---|---|
75fde0f444 | |||
04f610c799 | |||
3178b59147 | |||
9c7008e179 | |||
7ff7dbc56b | |||
823d524a81 |
@ -19,15 +19,10 @@ __version__ = "2023.4.0"
|
|||||||
|
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
|
|
||||||
|
|
||||||
# imports:
|
# imports:
|
||||||
from .bool_pipe import BoolPipe
|
from .bool_pipe import BoolPipe
|
||||||
from .first_char_to_lower_pipe import FirstCharToLowerPipe
|
|
||||||
from .first_to_upper_pipe import FirstToUpperPipe
|
|
||||||
from .ip_address_pipe import IPAddressPipe
|
from .ip_address_pipe import IPAddressPipe
|
||||||
from .pipe_abc import PipeABC
|
from .pipe_abc import PipeABC
|
||||||
from .to_camel_case_pipe import ToCamelCasePipe
|
|
||||||
from .to_snake_case_pipe import ToSnakeCasePipe
|
|
||||||
|
|
||||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||||
version_info = VersionInfo(major="2023", minor="4", micro="0")
|
version_info = VersionInfo(major="2023", minor="4", micro="0")
|
||||||
|
@ -1,18 +0,0 @@
|
|||||||
from cpl_core.pipes.pipe_abc import PipeABC
|
|
||||||
|
|
||||||
|
|
||||||
class FirstCharToLowerPipe(PipeABC):
|
|
||||||
def __init__(self):
|
|
||||||
pass
|
|
||||||
|
|
||||||
def transform(self, value: any, *args):
|
|
||||||
r"""Converts first char to lower
|
|
||||||
|
|
||||||
Parameter:
|
|
||||||
value: :class:`str`
|
|
||||||
String to convert
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
String with first char as lower
|
|
||||||
"""
|
|
||||||
return f"{value[0].lower()}{value[1:]}"
|
|
@ -1,18 +0,0 @@
|
|||||||
from cpl_core.pipes.pipe_abc import PipeABC
|
|
||||||
|
|
||||||
|
|
||||||
class FirstToUpperPipe(PipeABC):
|
|
||||||
def __init__(self):
|
|
||||||
pass
|
|
||||||
|
|
||||||
def transform(self, value: str, *args):
|
|
||||||
r"""Converts first char to upper
|
|
||||||
|
|
||||||
Parameter:
|
|
||||||
chars: :class:`str`
|
|
||||||
String to convert
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
String with first char as upper
|
|
||||||
"""
|
|
||||||
return f"{value[0].upper()}{value[1:]}"
|
|
@ -13,7 +13,7 @@ class IPAddressPipe(PipeABC):
|
|||||||
|
|
||||||
for i in range(0, len(value)):
|
for i in range(0, len(value)):
|
||||||
byte = value[i]
|
byte = value[i]
|
||||||
if byte > 255:
|
if byte > 255 or byte < 0:
|
||||||
raise Exception("Invalid IP")
|
raise Exception("Invalid IP")
|
||||||
|
|
||||||
if i == len(value) - 1:
|
if i == len(value) - 1:
|
||||||
|
@ -1,26 +0,0 @@
|
|||||||
import string
|
|
||||||
|
|
||||||
from cpl_core.pipes import PipeABC
|
|
||||||
|
|
||||||
|
|
||||||
class ToCamelCasePipe(PipeABC):
|
|
||||||
def __init__(self):
|
|
||||||
pass
|
|
||||||
|
|
||||||
def transform(self, value: str, *args) -> str:
|
|
||||||
r"""Converts string to camel case
|
|
||||||
|
|
||||||
Parameter:
|
|
||||||
chars: :class:`str`
|
|
||||||
String to convert
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
String converted to CamelCase
|
|
||||||
"""
|
|
||||||
converted_name = value
|
|
||||||
char_set = string.punctuation + " "
|
|
||||||
for char in char_set:
|
|
||||||
if char in converted_name:
|
|
||||||
converted_name = "".join(word.title() for word in converted_name.split(char))
|
|
||||||
|
|
||||||
return converted_name
|
|
@ -1,27 +0,0 @@
|
|||||||
import re
|
|
||||||
|
|
||||||
from cpl_core.pipes import PipeABC
|
|
||||||
|
|
||||||
|
|
||||||
class ToSnakeCasePipe(PipeABC):
|
|
||||||
def __init__(self):
|
|
||||||
pass
|
|
||||||
|
|
||||||
def transform(self, value: str, *args) -> str:
|
|
||||||
r"""Converts string to snake case
|
|
||||||
|
|
||||||
Parameter:
|
|
||||||
chars: :class:`str`
|
|
||||||
String to convert
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
String converted to snake_case
|
|
||||||
"""
|
|
||||||
# convert to train-case to CamelCase
|
|
||||||
if "-" in value:
|
|
||||||
value = "".join(word.title() for word in value.split("-"))
|
|
||||||
|
|
||||||
pattern1 = re.compile(r"(.)([A-Z][a-z]+)")
|
|
||||||
pattern2 = re.compile(r"([a-z0-9])([A-Z])")
|
|
||||||
file_name = re.sub(pattern1, r"\1_\2", value)
|
|
||||||
return re.sub(pattern2, r"\1_\2", file_name).lower()
|
|
@ -37,9 +37,19 @@ class String:
|
|||||||
String converted to snake_case
|
String converted to snake_case
|
||||||
"""
|
"""
|
||||||
# convert to train-case to CamelCase
|
# convert to train-case to CamelCase
|
||||||
|
if "_" in chars:
|
||||||
|
chars = chars.replace("_", "-")
|
||||||
|
|
||||||
if "-" in chars:
|
if "-" in chars:
|
||||||
chars = "".join(word.title() for word in chars.split("-"))
|
chars = "".join(word.title() for word in chars.split("-"))
|
||||||
|
|
||||||
|
if " " in chars:
|
||||||
|
new_chars = ""
|
||||||
|
for word in chars.split(" "):
|
||||||
|
new_chars += String.first_to_upper(word)
|
||||||
|
|
||||||
|
chars = new_chars
|
||||||
|
|
||||||
pattern1 = re.compile(r"(.)([A-Z][a-z]+)")
|
pattern1 = re.compile(r"(.)([A-Z][a-z]+)")
|
||||||
pattern2 = re.compile(r"([a-z0-9])([A-Z])")
|
pattern2 = re.compile(r"([a-z0-9])([A-Z])")
|
||||||
file_name = re.sub(pattern1, r"\1_\2", chars)
|
file_name = re.sub(pattern1, r"\1_\2", chars)
|
||||||
|
@ -4,6 +4,7 @@ from cpl_core.application import ApplicationABC
|
|||||||
from cpl_core.configuration import ConfigurationABC
|
from cpl_core.configuration import ConfigurationABC
|
||||||
from cpl_core.dependency_injection import ServiceProviderABC
|
from cpl_core.dependency_injection import ServiceProviderABC
|
||||||
from unittests_cli.cli_test_suite import CLITestSuite
|
from unittests_cli.cli_test_suite import CLITestSuite
|
||||||
|
from unittests_core.core_test_suite import CoreTestSuite
|
||||||
from unittests_query.query_test_suite import QueryTestSuite
|
from unittests_query.query_test_suite import QueryTestSuite
|
||||||
from unittests_translation.translation_test_suite import TranslationTestSuite
|
from unittests_translation.translation_test_suite import TranslationTestSuite
|
||||||
|
|
||||||
@ -17,6 +18,7 @@ class Application(ApplicationABC):
|
|||||||
|
|
||||||
def main(self):
|
def main(self):
|
||||||
runner = unittest.TextTestRunner()
|
runner = unittest.TextTestRunner()
|
||||||
|
runner.run(CoreTestSuite())
|
||||||
runner.run(CLITestSuite())
|
runner.run(CLITestSuite())
|
||||||
runner.run(QueryTestSuite())
|
runner.run(QueryTestSuite())
|
||||||
runner.run(TranslationTestSuite())
|
runner.run(TranslationTestSuite())
|
||||||
|
@ -1,19 +1,31 @@
|
|||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
|
from unittests_core.pipes.bool_pipe_test_case import BoolPipeTestCase
|
||||||
|
from unittests_core.pipes.ip_address_pipe_test_case import IPAddressTestCase
|
||||||
|
from unittests_core.pipes.version_pipe_test_case import VersionPipeTestCase
|
||||||
|
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
|
from unittests_core.utils.string_test_case import StringTestCase
|
||||||
from unittests_query.enumerable_query_test_case import EnumerableQueryTestCase
|
|
||||||
from unittests_query.enumerable_test_case import EnumerableTestCase
|
|
||||||
from unittests_query.iterable_query_test_case import IterableQueryTestCase
|
|
||||||
from unittests_query.iterable_test_case import IterableTestCase
|
|
||||||
from unittests_query.sequence_test_case import SequenceTestCase
|
|
||||||
|
|
||||||
|
|
||||||
class QueryTestSuite(unittest.TestSuite):
|
class CoreTestSuite(unittest.TestSuite):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
unittest.TestSuite.__init__(self)
|
unittest.TestSuite.__init__(self)
|
||||||
|
|
||||||
loader = unittest.TestLoader()
|
loader = unittest.TestLoader()
|
||||||
self.addTests(loader.loadTestsFromTestCase(StringTestCase))
|
tests = [
|
||||||
|
# pipes
|
||||||
|
BoolPipeTestCase,
|
||||||
|
IPAddressTestCase,
|
||||||
|
VersionPipeTestCase,
|
||||||
|
# utils
|
||||||
|
CredentialManagerTestCase,
|
||||||
|
JSONProcessorTestCase,
|
||||||
|
StringTestCase,
|
||||||
|
]
|
||||||
|
|
||||||
|
for test in tests:
|
||||||
|
self.addTests(loader.loadTestsFromTestCase(test))
|
||||||
|
|
||||||
def run(self, *args):
|
def run(self, *args):
|
||||||
super().run(*args)
|
super().run(*args)
|
||||||
@ -21,4 +33,4 @@ class QueryTestSuite(unittest.TestSuite):
|
|||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
runner = unittest.TextTestRunner()
|
runner = unittest.TextTestRunner()
|
||||||
runner.run(QueryTestSuite())
|
runner.run(CoreTestSuite())
|
||||||
|
1
unittests/unittests_core/pipes/__init__.py
Normal file
1
unittests/unittests_core/pipes/__init__.py
Normal file
@ -0,0 +1 @@
|
|||||||
|
# imports
|
14
unittests/unittests_core/pipes/bool_pipe_test_case.py
Normal file
14
unittests/unittests_core/pipes/bool_pipe_test_case.py
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
import unittest
|
||||||
|
|
||||||
|
from cpl_core.pipes import BoolPipe
|
||||||
|
|
||||||
|
|
||||||
|
class BoolPipeTestCase(unittest.TestCase):
|
||||||
|
def setUp(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def test_transform(self):
|
||||||
|
pipe = BoolPipe()
|
||||||
|
|
||||||
|
self.assertEqual("True", pipe.transform(True))
|
||||||
|
self.assertEqual("False", pipe.transform(False))
|
20
unittests/unittests_core/pipes/ip_address_pipe_test_case.py
Normal file
20
unittests/unittests_core/pipes/ip_address_pipe_test_case.py
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
import unittest
|
||||||
|
|
||||||
|
from cpl_core.pipes import IPAddressPipe
|
||||||
|
|
||||||
|
|
||||||
|
class IPAddressTestCase(unittest.TestCase):
|
||||||
|
def setUp(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def test_transform(self):
|
||||||
|
pipe = IPAddressPipe()
|
||||||
|
|
||||||
|
self.assertEqual("192.168.178.1", pipe.transform([192, 168, 178, 1]))
|
||||||
|
self.assertEqual("255.255.255.255", pipe.transform([255, 255, 255, 255]))
|
||||||
|
self.assertEqual("0.0.0.0", pipe.transform([0, 0, 0, 0]))
|
||||||
|
|
||||||
|
self.assertRaises(Exception, lambda: pipe.transform([-192, 168, 178, 1]))
|
||||||
|
self.assertRaises(Exception, lambda: pipe.transform([256, 168, 178, 1]))
|
||||||
|
self.assertRaises(Exception, lambda: pipe.transform([256, 168, 178]))
|
||||||
|
self.assertRaises(Exception, lambda: pipe.transform([256, 168, 178, 1, 1]))
|
16
unittests/unittests_core/pipes/version_pipe_test_case.py
Normal file
16
unittests/unittests_core/pipes/version_pipe_test_case.py
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
import unittest
|
||||||
|
|
||||||
|
from cpl_core.pipes.version_pipe import VersionPipe
|
||||||
|
|
||||||
|
|
||||||
|
class VersionPipeTestCase(unittest.TestCase):
|
||||||
|
def setUp(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def test_transform(self):
|
||||||
|
pipe = VersionPipe()
|
||||||
|
|
||||||
|
self.assertEqual("1.1.1", pipe.transform({"Major": 1, "Minor": 1, "Micro": 1}))
|
||||||
|
self.assertEqual("0.1.1", pipe.transform({"Major": 0, "Minor": 1, "Micro": 1}))
|
||||||
|
self.assertEqual("0.0.1", pipe.transform({"Major": 0, "Minor": 0, "Micro": 1}))
|
||||||
|
self.assertEqual("0.0.0", pipe.transform({"Major": 0, "Minor": 0, "Micro": 0}))
|
@ -1,16 +0,0 @@
|
|||||||
from cpl_core.application.startup_extension_abc import StartupExtensionABC
|
|
||||||
from cpl_core.configuration.configuration_abc import ConfigurationABC
|
|
||||||
from cpl_core.dependency_injection.service_collection_abc import ServiceCollectionABC
|
|
||||||
from cpl_core.environment.application_environment_abc import ApplicationEnvironmentABC
|
|
||||||
|
|
||||||
|
|
||||||
class TestStartup_extension(StartupExtensionABC):
|
|
||||||
|
|
||||||
def __init__(self):
|
|
||||||
pass
|
|
||||||
|
|
||||||
def configure_configuration(self, config: ConfigurationABC, env: ApplicationEnvironmentABC):
|
|
||||||
pass
|
|
||||||
|
|
||||||
def configure_services(self, services: ServiceCollectionABC, env: ApplicationEnvironmentABC):
|
|
||||||
pass
|
|
@ -1,10 +1,40 @@
|
|||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
|
from cpl_core.utils import CredentialManager
|
||||||
|
|
||||||
|
|
||||||
class CredentialManagerTestCase(unittest.TestCase):
|
class CredentialManagerTestCase(unittest.TestCase):
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def test_equal(self):
|
def test_encrypt(self):
|
||||||
pass
|
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"])
|
@ -1,10 +1,57 @@
|
|||||||
|
import string
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
|
from cpl_core.utils import String
|
||||||
|
|
||||||
|
|
||||||
class StringTestCase(unittest.TestCase):
|
class StringTestCase(unittest.TestCase):
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def test_equal(self):
|
def test_convert_to_camel_case(self):
|
||||||
pass
|
expected = "HelloWorld"
|
||||||
|
|
||||||
|
self.assertEqual(expected, String.convert_to_camel_case("hello-world"))
|
||||||
|
self.assertEqual(expected, String.convert_to_camel_case("hello_world"))
|
||||||
|
self.assertEqual("helloWorld", String.convert_to_camel_case("helloWorld"))
|
||||||
|
self.assertEqual(expected, String.convert_to_camel_case("Hello_world"))
|
||||||
|
self.assertEqual(expected, String.convert_to_camel_case("Hello_World"))
|
||||||
|
self.assertEqual(expected, String.convert_to_camel_case("hello world"))
|
||||||
|
|
||||||
|
def test_convert_to_snake_case(self):
|
||||||
|
expected = "hello_world"
|
||||||
|
|
||||||
|
self.assertEqual(expected, String.convert_to_snake_case("Hello World"))
|
||||||
|
self.assertEqual(expected, String.convert_to_snake_case("hello-world"))
|
||||||
|
self.assertEqual(expected, String.convert_to_snake_case("hello_world"))
|
||||||
|
self.assertEqual(expected, String.convert_to_snake_case("helloWorld"))
|
||||||
|
self.assertEqual(expected, String.convert_to_snake_case("Hello_world"))
|
||||||
|
self.assertEqual(expected, String.convert_to_snake_case("Hello_World"))
|
||||||
|
self.assertEqual(expected, String.convert_to_snake_case("hello world"))
|
||||||
|
|
||||||
|
def test_first_to_upper(self):
|
||||||
|
expected = "HelloWorld"
|
||||||
|
|
||||||
|
self.assertEqual(expected, String.first_to_upper("helloWorld"))
|
||||||
|
self.assertEqual(expected, String.first_to_upper("HelloWorld"))
|
||||||
|
|
||||||
|
def test_first_to_lower(self):
|
||||||
|
expected = "helloWorld"
|
||||||
|
|
||||||
|
self.assertEqual(expected, String.first_to_lower("helloWorld"))
|
||||||
|
self.assertEqual(expected, String.first_to_lower("HelloWorld"))
|
||||||
|
|
||||||
|
def test_random_string(self):
|
||||||
|
expected = ""
|
||||||
|
|
||||||
|
for x in range(0, 100):
|
||||||
|
rstr = String.random_string(string.ascii_letters, 4)
|
||||||
|
self.assertNotEqual(expected, rstr)
|
||||||
|
self.assertEqual(4, len(rstr))
|
||||||
|
expected = rstr
|
||||||
|
|
||||||
|
for x in range(0, 100):
|
||||||
|
rstr = String.random_string(string.ascii_letters, 16)
|
||||||
|
self.assertNotEqual(expected, rstr)
|
||||||
|
self.assertEqual(16, len(rstr))
|
||||||
|
expected = rstr
|
||||||
|
Loading…
Reference in New Issue
Block a user