Added TimeFormatSettings Test
This commit is contained in:
parent
9c87dbd031
commit
b03ef60276
0
src/tests/cases/time/__init__.py
Normal file
0
src/tests/cases/time/__init__.py
Normal file
26
src/tests/cases/time/time_format_settings.py
Normal file
26
src/tests/cases/time/time_format_settings.py
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
import unittest
|
||||||
|
|
||||||
|
from sh_edraft.time.model import TimeFormatSettingsNames, TimeFormatSettings
|
||||||
|
|
||||||
|
|
||||||
|
class TimeFormatSettingsTest(unittest.TestCase):
|
||||||
|
|
||||||
|
def setUp(self): pass
|
||||||
|
|
||||||
|
def test_from_dict(self):
|
||||||
|
test_dict = {
|
||||||
|
TimeFormatSettingsNames.date_format.value: '%H:%M:%S',
|
||||||
|
TimeFormatSettingsNames.time_format.value: '%Y-%m-%d',
|
||||||
|
TimeFormatSettingsNames.date_time_format.value: '%Y-%m-%d %H:%M:%S.%f',
|
||||||
|
TimeFormatSettingsNames.date_time_log_format.value: '%Y-%m-%d_%H-%M-%S'
|
||||||
|
}
|
||||||
|
|
||||||
|
settings = TimeFormatSettings()
|
||||||
|
settings.from_dict(test_dict)
|
||||||
|
|
||||||
|
self.assertIsNotNone(settings)
|
||||||
|
|
||||||
|
self.assertEqual(test_dict[TimeFormatSettingsNames.date_format.value], settings.date_format)
|
||||||
|
self.assertEqual(test_dict[TimeFormatSettingsNames.time_format.value], settings.time_format)
|
||||||
|
self.assertEqual(test_dict[TimeFormatSettingsNames.date_time_format.value], settings.date_time_format)
|
||||||
|
self.assertEqual(test_dict[TimeFormatSettingsNames.date_time_log_format.value], settings.date_time_log_format)
|
@ -1,5 +1,6 @@
|
|||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
|
from tests.cases.time.time_format_settings import TimeFormatSettingsTest
|
||||||
from tests.cases.utils.credential_manager import CredentialManagerTest
|
from tests.cases.utils.credential_manager import CredentialManagerTest
|
||||||
|
|
||||||
|
|
||||||
@ -7,13 +8,20 @@ class Tester:
|
|||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self._suite = unittest.TestSuite()
|
self._suite = unittest.TestSuite()
|
||||||
|
self._cases = []
|
||||||
|
|
||||||
|
def _build_cases(self):
|
||||||
|
for case in self._cases:
|
||||||
|
case_functions = [method_name for method_name in dir(case) if callable(getattr(case, method_name)) and method_name.startswith('test_')]
|
||||||
|
for function in case_functions:
|
||||||
|
self._suite.addTest(case(function))
|
||||||
|
|
||||||
def create(self):
|
def create(self):
|
||||||
self._suite.addTest(CredentialManagerTest(CredentialManagerTest.test_encode.__name__))
|
self._cases.append(CredentialManagerTest)
|
||||||
self._suite.addTest(CredentialManagerTest(CredentialManagerTest.test_decode.__name__))
|
self._cases.append(TimeFormatSettingsTest)
|
||||||
self._suite.addTest(CredentialManagerTest(CredentialManagerTest.test_build_string.__name__))
|
|
||||||
|
|
||||||
def start(self):
|
def start(self):
|
||||||
|
self._build_cases()
|
||||||
runner = unittest.TextTestRunner()
|
runner = unittest.TextTestRunner()
|
||||||
runner.run(self._suite)
|
runner.run(self._suite)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user