Added TimeFormatSettings Test

This commit is contained in:
Sven Heidemann 2020-12-25 12:37:14 +01:00
parent 9c87dbd031
commit b03ef60276
3 changed files with 37 additions and 3 deletions

View File

View 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)

View File

@ -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)