orionis 0.405.0__py3-none-any.whl → 0.407.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- orionis/console/base/command.py +57 -50
- orionis/console/base/contracts/command.py +68 -0
- orionis/console/dynamic/contracts/progress_bar.py +3 -3
- orionis/console/dynamic/progress_bar.py +8 -8
- orionis/console/output/console.py +8 -2
- orionis/console/output/contracts/console.py +1 -1
- orionis/container/container.py +2 -2
- orionis/container/context/scope.py +4 -1
- orionis/container/contracts/service_provider.py +2 -2
- orionis/container/entities/binding.py +31 -44
- orionis/container/enums/lifetimes.py +22 -1
- orionis/container/facades/facade.py +1 -2
- orionis/container/providers/service_provider.py +2 -2
- orionis/foundation/application.py +542 -248
- orionis/foundation/config/app/entities/app.py +107 -90
- orionis/foundation/config/auth/entities/auth.py +4 -33
- orionis/foundation/config/cache/entities/cache.py +18 -41
- orionis/foundation/config/cache/entities/file.py +8 -35
- orionis/foundation/config/cache/entities/stores.py +17 -38
- orionis/foundation/config/cors/entities/cors.py +41 -54
- orionis/foundation/config/database/entities/connections.py +40 -56
- orionis/foundation/config/database/entities/database.py +11 -38
- orionis/foundation/config/database/entities/mysql.py +48 -76
- orionis/foundation/config/database/entities/oracle.py +30 -57
- orionis/foundation/config/database/entities/pgsql.py +45 -61
- orionis/foundation/config/database/entities/sqlite.py +26 -53
- orionis/foundation/config/filesystems/entitites/aws.py +28 -49
- orionis/foundation/config/filesystems/entitites/disks.py +27 -47
- orionis/foundation/config/filesystems/entitites/filesystems.py +15 -37
- orionis/foundation/config/filesystems/entitites/local.py +9 -35
- orionis/foundation/config/filesystems/entitites/public.py +14 -41
- orionis/foundation/config/logging/entities/channels.py +56 -86
- orionis/foundation/config/logging/entities/chunked.py +9 -9
- orionis/foundation/config/logging/entities/daily.py +8 -8
- orionis/foundation/config/logging/entities/hourly.py +6 -6
- orionis/foundation/config/logging/entities/logging.py +12 -18
- orionis/foundation/config/logging/entities/monthly.py +7 -7
- orionis/foundation/config/logging/entities/stack.py +5 -5
- orionis/foundation/config/logging/entities/weekly.py +6 -6
- orionis/foundation/config/mail/entities/file.py +9 -36
- orionis/foundation/config/mail/entities/mail.py +22 -40
- orionis/foundation/config/mail/entities/mailers.py +29 -44
- orionis/foundation/config/mail/entities/smtp.py +47 -48
- orionis/foundation/config/queue/entities/brokers.py +19 -41
- orionis/foundation/config/queue/entities/database.py +24 -46
- orionis/foundation/config/queue/entities/queue.py +28 -40
- orionis/foundation/config/roots/paths.py +272 -468
- orionis/foundation/config/session/entities/session.py +23 -53
- orionis/foundation/config/startup.py +165 -135
- orionis/foundation/config/testing/entities/testing.py +137 -122
- orionis/foundation/config/testing/enums/__init__.py +6 -2
- orionis/foundation/config/testing/enums/drivers.py +16 -0
- orionis/foundation/config/testing/enums/verbosity.py +18 -0
- orionis/foundation/contracts/application.py +152 -362
- orionis/foundation/providers/console_provider.py +24 -2
- orionis/foundation/providers/dumper_provider.py +24 -2
- orionis/foundation/providers/logger_provider.py +24 -2
- orionis/foundation/providers/path_resolver_provider.py +25 -2
- orionis/foundation/providers/progress_bar_provider.py +24 -2
- orionis/foundation/providers/testing_provider.py +39 -0
- orionis/foundation/providers/workers_provider.py +24 -2
- orionis/metadata/framework.py +1 -1
- orionis/services/asynchrony/contracts/coroutines.py +13 -5
- orionis/services/asynchrony/coroutines.py +33 -29
- orionis/services/asynchrony/exceptions/exception.py +9 -1
- orionis/services/environment/core/dot_env.py +46 -34
- orionis/services/environment/enums/__init__.py +0 -0
- orionis/services/environment/enums/cast_type.py +42 -0
- orionis/services/environment/helpers/functions.py +1 -2
- orionis/services/environment/key/__init__.py +0 -0
- orionis/services/environment/key/key_generator.py +37 -0
- orionis/services/environment/serializer/__init__.py +0 -0
- orionis/services/environment/serializer/values.py +21 -0
- orionis/services/environment/validators/__init__.py +0 -0
- orionis/services/environment/validators/key_name.py +46 -0
- orionis/services/environment/validators/types.py +45 -0
- orionis/services/system/contracts/imports.py +38 -18
- orionis/services/system/contracts/workers.py +29 -12
- orionis/services/system/imports.py +65 -25
- orionis/services/system/runtime/imports.py +18 -9
- orionis/services/system/workers.py +49 -16
- orionis/support/entities/__init__.py +0 -0
- orionis/support/entities/base.py +104 -0
- orionis/support/facades/testing.py +15 -0
- orionis/support/facades/workers.py +1 -1
- orionis/test/cases/asynchronous.py +0 -11
- orionis/test/cases/synchronous.py +0 -9
- orionis/test/contracts/dumper.py +11 -4
- orionis/test/contracts/kernel.py +5 -110
- orionis/test/contracts/logs.py +27 -65
- orionis/test/contracts/printer.py +16 -128
- orionis/test/contracts/test_result.py +100 -0
- orionis/test/contracts/unit_test.py +87 -150
- orionis/test/core/unit_test.py +608 -554
- orionis/test/entities/result.py +22 -2
- orionis/test/enums/__init__.py +0 -2
- orionis/test/enums/status.py +14 -9
- orionis/test/exceptions/config.py +9 -1
- orionis/test/exceptions/failure.py +34 -11
- orionis/test/exceptions/persistence.py +10 -2
- orionis/test/exceptions/runtime.py +9 -1
- orionis/test/exceptions/value.py +13 -1
- orionis/test/kernel.py +87 -289
- orionis/test/output/dumper.py +83 -18
- orionis/test/output/printer.py +399 -156
- orionis/test/records/logs.py +203 -82
- orionis/test/validators/__init__.py +33 -0
- orionis/test/validators/base_path.py +45 -0
- orionis/test/validators/execution_mode.py +45 -0
- orionis/test/validators/fail_fast.py +37 -0
- orionis/test/validators/folder_path.py +34 -0
- orionis/test/validators/module_name.py +31 -0
- orionis/test/validators/name_pattern.py +40 -0
- orionis/test/validators/pattern.py +36 -0
- orionis/test/validators/persistent.py +42 -0
- orionis/test/validators/persistent_driver.py +43 -0
- orionis/test/validators/print_result.py +37 -0
- orionis/test/validators/tags.py +37 -0
- orionis/test/validators/throw_exception.py +39 -0
- orionis/test/validators/verbosity.py +37 -0
- orionis/test/validators/web_report.py +35 -0
- orionis/test/validators/workers.py +31 -0
- orionis/test/view/render.py +48 -54
- {orionis-0.405.0.dist-info → orionis-0.407.0.dist-info}/METADATA +1 -1
- {orionis-0.405.0.dist-info → orionis-0.407.0.dist-info}/RECORD +170 -112
- tests/container/__init__.py +0 -0
- tests/container/context/__init__.py +0 -0
- tests/container/context/test_manager.py +27 -0
- tests/container/context/test_scope.py +23 -0
- tests/container/entities/__init__.py +0 -0
- tests/container/entities/test_binding.py +133 -0
- tests/container/enums/__init__.py +0 -0
- tests/container/enums/test_lifetimes.py +63 -0
- tests/container/facades/__init__.py +0 -0
- tests/container/facades/test_facade.py +61 -0
- tests/container/mocks/__init__.py +0 -0
- tests/container/mocks/mock_complex_classes.py +482 -0
- tests/container/mocks/mock_simple_classes.py +32 -0
- tests/container/providers/__init__.py +0 -0
- tests/container/providers/test_providers.py +48 -0
- tests/container/resolver/__init__.py +0 -0
- tests/container/resolver/test_resolver.py +55 -0
- tests/container/test_container.py +254 -0
- tests/container/test_singleton.py +98 -0
- tests/container/test_thread_safety.py +217 -0
- tests/container/validators/__init__.py +0 -0
- tests/container/validators/test_implements.py +140 -0
- tests/container/validators/test_is_abstract_class.py +99 -0
- tests/container/validators/test_is_callable.py +73 -0
- tests/container/validators/test_is_concrete_class.py +97 -0
- tests/container/validators/test_is_instance.py +105 -0
- tests/container/validators/test_is_not_subclass.py +117 -0
- tests/container/validators/test_is_subclass.py +115 -0
- tests/container/validators/test_is_valid_alias.py +113 -0
- tests/container/validators/test_lifetime.py +75 -0
- tests/example/test_example.py +2 -2
- tests/foundation/config/testing/test_foundation_config_testing.py +1 -1
- tests/metadata/test_metadata_framework.py +89 -24
- tests/metadata/test_metadata_package.py +55 -10
- tests/services/asynchrony/test_services_asynchrony_coroutine.py +52 -7
- tests/services/system/test_services_system_imports.py +119 -16
- tests/services/system/test_services_system_workers.py +71 -30
- tests/testing/test_testing_result.py +117 -117
- tests/testing/test_testing_unit.py +209 -209
- orionis/foundation/config/base.py +0 -112
- orionis/test/arguments/parser.py +0 -187
- orionis/test/contracts/parser.py +0 -43
- orionis/test/entities/arguments.py +0 -38
- orionis/test/enums/execution_mode.py +0 -16
- /orionis/{test/arguments → console/base/contracts}/__init__.py +0 -0
- /orionis/foundation/config/testing/enums/{test_mode.py → mode.py} +0 -0
- {orionis-0.405.0.dist-info → orionis-0.407.0.dist-info}/WHEEL +0 -0
- {orionis-0.405.0.dist-info → orionis-0.407.0.dist-info}/licenses/LICENCE +0 -0
- {orionis-0.405.0.dist-info → orionis-0.407.0.dist-info}/top_level.txt +0 -0
- {orionis-0.405.0.dist-info → orionis-0.407.0.dist-info}/zip-safe +0 -0
|
@@ -1,209 +1,209 @@
|
|
|
1
|
-
from unittest import TestLoader
|
|
2
|
-
from unittest.mock import MagicMock, patch
|
|
3
|
-
from orionis.test.cases.asynchronous import AsyncTestCase
|
|
4
|
-
from orionis.test.core.unit_test import UnitTest
|
|
5
|
-
from orionis.test.enums import ExecutionMode
|
|
6
|
-
from unittest import (
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
)
|
|
10
|
-
|
|
11
|
-
class TestTestingUnit(AsyncTestCase):
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
1
|
+
# from unittest import TestLoader
|
|
2
|
+
# from unittest.mock import MagicMock, patch
|
|
3
|
+
# from orionis.test.cases.asynchronous import AsyncTestCase
|
|
4
|
+
# from orionis.test.core.unit_test import UnitTest
|
|
5
|
+
# from orionis.test.enums import ExecutionMode
|
|
6
|
+
# from unittest import (
|
|
7
|
+
# TestSuite as StandardTestSuite,
|
|
8
|
+
# TestResult as StandardTestResult
|
|
9
|
+
# )
|
|
10
|
+
|
|
11
|
+
# class TestTestingUnit(AsyncTestCase):
|
|
12
|
+
|
|
13
|
+
# async def testDefaultConfiguration(self) -> None:
|
|
14
|
+
# """
|
|
15
|
+
# Test that UnitTest initializes with correct default configuration values.
|
|
16
|
+
|
|
17
|
+
# Notes
|
|
18
|
+
# -----
|
|
19
|
+
# Verifies that all default attributes are set as expected upon initialization.
|
|
20
|
+
# """
|
|
21
|
+
# unit_test = UnitTest()
|
|
22
|
+
# self.assertIsInstance(unit_test.loader, TestLoader)
|
|
23
|
+
# self.assertIsInstance(unit_test.suite, StandardTestSuite)
|
|
24
|
+
|
|
25
|
+
# async def testConfigureMethod(self) -> None:
|
|
26
|
+
# """
|
|
27
|
+
# Test the `configure` method for correct configuration updates.
|
|
28
|
+
# This test verifies that all configuration parameters of the `UnitTest` class
|
|
29
|
+
# can be updated through the `configure` method and that the changes are
|
|
30
|
+
# reflected in the instance attributes.
|
|
31
|
+
|
|
32
|
+
# Parameters
|
|
33
|
+
# ----------
|
|
34
|
+
# self : TestCase
|
|
35
|
+
# The test case instance.
|
|
36
|
+
|
|
37
|
+
# Notes
|
|
38
|
+
# -----
|
|
39
|
+
# The test checks the following configuration parameters:
|
|
40
|
+
# - verbosity
|
|
41
|
+
# - execution_mode
|
|
42
|
+
# - max_workers
|
|
43
|
+
# - fail_fast
|
|
44
|
+
# - print_result
|
|
45
|
+
# - throw_exception
|
|
46
|
+
# It also asserts that the `configure` method returns the instance itself.
|
|
47
|
+
# """
|
|
48
|
+
# unit_test = UnitTest()
|
|
49
|
+
# configured = unit_test.configure(
|
|
50
|
+
# verbosity=1,
|
|
51
|
+
# execution_mode=ExecutionMode.PARALLEL,
|
|
52
|
+
# max_workers=8,
|
|
53
|
+
# fail_fast=True,
|
|
54
|
+
# print_result=False,
|
|
55
|
+
# throw_exception=True
|
|
56
|
+
# )
|
|
57
|
+
|
|
58
|
+
# self.assertEqual(unit_test.verbosity, 1)
|
|
59
|
+
# self.assertEqual(unit_test.execution_mode, ExecutionMode.PARALLEL.value)
|
|
60
|
+
# self.assertEqual(unit_test.max_workers, 8)
|
|
61
|
+
# self.assertTrue(unit_test.fail_fast)
|
|
62
|
+
# self.assertFalse(unit_test.print_result)
|
|
63
|
+
# self.assertTrue(unit_test.throw_exception)
|
|
64
|
+
# self.assertEqual(configured, unit_test)
|
|
65
|
+
|
|
66
|
+
# async def testDiscoverTestsInModule(self) -> None:
|
|
67
|
+
# """
|
|
68
|
+
# Test that `discoverTestsInModule` correctly loads tests from a module.
|
|
69
|
+
|
|
70
|
+
# Verifies that tests can be discovered from a module and added to the test suite.
|
|
71
|
+
|
|
72
|
+
# Notes
|
|
73
|
+
# -----
|
|
74
|
+
# This test mocks the loader's `loadTestsFromName` method to ensure that
|
|
75
|
+
# `discoverTestsInModule` calls it with the correct arguments and that the
|
|
76
|
+
# returned suite is handled as expected.
|
|
77
|
+
# """
|
|
78
|
+
# unit_test = UnitTest()
|
|
79
|
+
# with patch.object(unit_test.loader, 'loadTestsFromName') as mock_load:
|
|
80
|
+
# mock_load.return_value = StandardTestSuite()
|
|
81
|
+
# result = unit_test.discoverTestsInModule(module_name='test_module')
|
|
82
|
+
|
|
83
|
+
# mock_load.assert_called_once_with(name='test_module')
|
|
84
|
+
# self.assertEqual(result, unit_test)
|
|
85
|
+
# self.assertEqual(len(unit_test.suite._tests), 0)
|
|
86
|
+
|
|
87
|
+
# async def testFlattenTestSuite(self) -> None:
|
|
88
|
+
# """
|
|
89
|
+
# Test the _flattenTestSuite method for correct flattening of nested test suites.
|
|
90
|
+
# This test verifies that the _flattenTestSuite method of the UnitTest class
|
|
91
|
+
# correctly flattens both simple and nested unittest suites into a single list
|
|
92
|
+
# of test cases.
|
|
93
|
+
|
|
94
|
+
# Parameters
|
|
95
|
+
# ----------
|
|
96
|
+
# self : TestCase
|
|
97
|
+
# The test case instance.
|
|
98
|
+
|
|
99
|
+
# Notes
|
|
100
|
+
# -----
|
|
101
|
+
# - Ensures that nested suites are recursively flattened.
|
|
102
|
+
# - Asserts that all test cases from nested suites are present in the flattened result.
|
|
103
|
+
# """
|
|
104
|
+
# unit_test = UnitTest()
|
|
105
|
+
# test_case1 = MagicMock()
|
|
106
|
+
# test_case2 = MagicMock()
|
|
107
|
+
|
|
108
|
+
# nested_suite = StandardTestSuite()
|
|
109
|
+
# nested_suite.addTest(test_case1)
|
|
110
|
+
# nested_suite.addTest(test_case2)
|
|
111
|
+
|
|
112
|
+
# main_suite = StandardTestSuite()
|
|
113
|
+
# main_suite.addTest(nested_suite)
|
|
114
|
+
|
|
115
|
+
# flattened = unit_test._UnitTest__flattenTestSuite(main_suite)
|
|
116
|
+
# self.assertEqual(len(flattened), 2)
|
|
117
|
+
# self.assertIn(test_case1, flattened)
|
|
118
|
+
# self.assertIn(test_case2, flattened)
|
|
119
|
+
|
|
120
|
+
# async def testMergeTestResults(self) -> None:
|
|
121
|
+
# """
|
|
122
|
+
# Test the _mergeTestResults method for correct merging of test results.
|
|
123
|
+
# Ensures that the method accurately combines the number of tests run,
|
|
124
|
+
# as well as the lists of failures and errors from individual test results.
|
|
125
|
+
|
|
126
|
+
# Notes
|
|
127
|
+
# -----
|
|
128
|
+
# - Verifies that the total number of tests run is updated correctly.
|
|
129
|
+
# - Checks that failures and errors are merged without loss of information.
|
|
130
|
+
# """
|
|
131
|
+
# unit_test = UnitTest()
|
|
132
|
+
# combined = StandardTestResult()
|
|
133
|
+
# individual = StandardTestResult()
|
|
134
|
+
|
|
135
|
+
# individual.testsRun = 2
|
|
136
|
+
# individual.failures = [('test1', 'failure')]
|
|
137
|
+
# individual.errors = [('test2', 'error')]
|
|
138
|
+
|
|
139
|
+
# unit_test._UnitTest__mergeTestResults(combined, individual)
|
|
140
|
+
# self.assertEqual(combined.testsRun, 2)
|
|
141
|
+
# self.assertEqual(len(combined.failures), 1)
|
|
142
|
+
# self.assertEqual(len(combined.errors), 1)
|
|
143
|
+
|
|
144
|
+
# async def testClearTests(self) -> None:
|
|
145
|
+
# """
|
|
146
|
+
# Test the clearTests method to ensure it resets the test suite.
|
|
147
|
+
# This test verifies that after adding a mock test to the suite and calling
|
|
148
|
+
# the clearTests method, the suite is emptied as expected.
|
|
149
|
+
|
|
150
|
+
# Steps
|
|
151
|
+
# -----
|
|
152
|
+
# 1. Create an instance of UnitTest.
|
|
153
|
+
# 2. Add a mock test to the test suite.
|
|
154
|
+
# 3. Call the clearTests method.
|
|
155
|
+
# 4. Assert that the test suite is empty.
|
|
156
|
+
|
|
157
|
+
# Assertions
|
|
158
|
+
# ----------
|
|
159
|
+
# - The length of the test suite should be zero after calling clearTests.
|
|
160
|
+
# """
|
|
161
|
+
# unit_test = UnitTest()
|
|
162
|
+
# mock_test = MagicMock()
|
|
163
|
+
# unit_test.suite.addTest(mock_test)
|
|
164
|
+
|
|
165
|
+
# unit_test.clearTests()
|
|
166
|
+
# self.assertEqual(len(unit_test.suite._tests), 0)
|
|
167
|
+
|
|
168
|
+
# async def testGetTestNames(self) -> None:
|
|
169
|
+
# """
|
|
170
|
+
# This test verifies that the `getTestNames` method of the `UnitTest` class
|
|
171
|
+
# correctly extracts and returns the identifiers of tests present in the test suite.
|
|
172
|
+
|
|
173
|
+
# Notes
|
|
174
|
+
# -----
|
|
175
|
+
# - Mocks a test case with a predefined identifier.
|
|
176
|
+
# - Adds the mock test to the test suite.
|
|
177
|
+
# - Asserts that the returned list of test names matches the expected value.
|
|
178
|
+
# """
|
|
179
|
+
# unit_test = UnitTest()
|
|
180
|
+
# mock_test = MagicMock()
|
|
181
|
+
# mock_test.id.return_value = 'test_id'
|
|
182
|
+
# unit_test.suite.addTest(mock_test)
|
|
183
|
+
|
|
184
|
+
# names = unit_test.getTestNames()
|
|
185
|
+
# self.assertEqual(names, ['test_id'])
|
|
186
|
+
|
|
187
|
+
# async def testGetTestCount(self) -> None:
|
|
188
|
+
# """
|
|
189
|
+
# Test that `getTestCount` returns the correct number of tests.
|
|
190
|
+
|
|
191
|
+
# Verifies that the count matches the number of tests in the suite.
|
|
192
|
+
|
|
193
|
+
# Notes
|
|
194
|
+
# -----
|
|
195
|
+
# - Adds two mock tests to the suite.
|
|
196
|
+
# - Asserts that `getTestCount` returns 2.
|
|
197
|
+
|
|
198
|
+
# Returns
|
|
199
|
+
# -------
|
|
200
|
+
# None
|
|
201
|
+
# """
|
|
202
|
+
# unit_test = UnitTest()
|
|
203
|
+
# mock_test1 = MagicMock()
|
|
204
|
+
# mock_test2 = MagicMock()
|
|
205
|
+
# unit_test.suite.addTest(mock_test1)
|
|
206
|
+
# unit_test.suite.addTest(mock_test2)
|
|
207
|
+
|
|
208
|
+
# count = unit_test.getTestCount()
|
|
209
|
+
# self.assertEqual(count, 2)
|
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
from dataclasses import asdict, fields
|
|
2
|
-
from dataclasses import MISSING
|
|
3
|
-
|
|
4
|
-
class BaseConfigEntity:
|
|
5
|
-
|
|
6
|
-
def toDict(self) -> dict:
|
|
7
|
-
"""
|
|
8
|
-
Converts the current instance into a dictionary representation.
|
|
9
|
-
|
|
10
|
-
Returns
|
|
11
|
-
-------
|
|
12
|
-
dict
|
|
13
|
-
Dictionary representation of the current instance.
|
|
14
|
-
"""
|
|
15
|
-
return asdict(self)
|
|
16
|
-
|
|
17
|
-
def getFields(self):
|
|
18
|
-
"""
|
|
19
|
-
Retrieves a list of field information for the current dataclass instance.
|
|
20
|
-
|
|
21
|
-
Returns
|
|
22
|
-
-------
|
|
23
|
-
list
|
|
24
|
-
A list of dictionaries, each containing details about a field:
|
|
25
|
-
- name (str): The name of the field.
|
|
26
|
-
- type (type): The type of the field.
|
|
27
|
-
- default: The default value of the field, if specified; otherwise, the value from metadata or None.
|
|
28
|
-
- metadata (mapping): The metadata associated with the field.
|
|
29
|
-
"""
|
|
30
|
-
# Dictionary to hold field information
|
|
31
|
-
__fields = []
|
|
32
|
-
|
|
33
|
-
# Iterate over the fields of the dataclass
|
|
34
|
-
# and extract relevant information
|
|
35
|
-
for field in fields(self):
|
|
36
|
-
|
|
37
|
-
# Get the field name
|
|
38
|
-
__name = field.name
|
|
39
|
-
|
|
40
|
-
# Get the field type with better handling for complex types
|
|
41
|
-
__type = getattr(field.type, '__name__', None)
|
|
42
|
-
|
|
43
|
-
# If the type is None, handle it
|
|
44
|
-
if __type is None:
|
|
45
|
-
|
|
46
|
-
# Handle generic types, unions, and other complex annotations
|
|
47
|
-
type_str = str(field.type)
|
|
48
|
-
|
|
49
|
-
# Clean up typing module references
|
|
50
|
-
type_str = type_str.replace('typing.', '')
|
|
51
|
-
|
|
52
|
-
# Handle Union types (e.g., "Channels | dict" or "Union[Channels, dict]")
|
|
53
|
-
if '|' in type_str or 'Union[' in type_str:
|
|
54
|
-
|
|
55
|
-
# Extract individual types from Union
|
|
56
|
-
if 'Union[' in type_str:
|
|
57
|
-
|
|
58
|
-
# Handle typing.Union format
|
|
59
|
-
inner = type_str.replace('Union[', '').replace(']', '')
|
|
60
|
-
types = [t.strip() for t in inner.split(',')]
|
|
61
|
-
|
|
62
|
-
else:
|
|
63
|
-
# Handle | format (Python 3.10+)
|
|
64
|
-
types = [t.strip() for t in type_str.split('|')]
|
|
65
|
-
|
|
66
|
-
# Get class names for custom types
|
|
67
|
-
clean_types = []
|
|
68
|
-
for t in types:
|
|
69
|
-
if '.' in t:
|
|
70
|
-
clean_types.append(t.split('.')[-1])
|
|
71
|
-
else:
|
|
72
|
-
clean_types.append(t)
|
|
73
|
-
|
|
74
|
-
# Join cleaned types with ' | '
|
|
75
|
-
__type = ' | '.join(clean_types)
|
|
76
|
-
|
|
77
|
-
else:
|
|
78
|
-
|
|
79
|
-
# Handle other complex types
|
|
80
|
-
if '.' in type_str:
|
|
81
|
-
__type = type_str.split('.')[-1]
|
|
82
|
-
else:
|
|
83
|
-
__type = type_str
|
|
84
|
-
|
|
85
|
-
# Extract metadata, default value, and type
|
|
86
|
-
__metadata = dict(field.metadata) or {}
|
|
87
|
-
|
|
88
|
-
# Extract the default value, if specified
|
|
89
|
-
__default = None
|
|
90
|
-
|
|
91
|
-
# Field has a direct default value
|
|
92
|
-
if field.default is not MISSING:
|
|
93
|
-
__default = field.default
|
|
94
|
-
|
|
95
|
-
# Field has a default factory (like list, dict, etc.)
|
|
96
|
-
elif field.default_factory is not MISSING:
|
|
97
|
-
__default = f"<factory: {field.default_factory.__name__}>"
|
|
98
|
-
|
|
99
|
-
# No default found, check metadata for custom default
|
|
100
|
-
else:
|
|
101
|
-
__default = __metadata.get('default', None)
|
|
102
|
-
|
|
103
|
-
# Append the field information to the list
|
|
104
|
-
__fields.append({
|
|
105
|
-
"name": __name,
|
|
106
|
-
"type": __type,
|
|
107
|
-
"default": __default,
|
|
108
|
-
"metadata": __metadata
|
|
109
|
-
})
|
|
110
|
-
|
|
111
|
-
# Return the list of field information
|
|
112
|
-
return __fields
|