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.
Files changed (175) hide show
  1. orionis/console/base/command.py +57 -50
  2. orionis/console/base/contracts/command.py +68 -0
  3. orionis/console/dynamic/contracts/progress_bar.py +3 -3
  4. orionis/console/dynamic/progress_bar.py +8 -8
  5. orionis/console/output/console.py +8 -2
  6. orionis/console/output/contracts/console.py +1 -1
  7. orionis/container/container.py +2 -2
  8. orionis/container/context/scope.py +4 -1
  9. orionis/container/contracts/service_provider.py +2 -2
  10. orionis/container/entities/binding.py +31 -44
  11. orionis/container/enums/lifetimes.py +22 -1
  12. orionis/container/facades/facade.py +1 -2
  13. orionis/container/providers/service_provider.py +2 -2
  14. orionis/foundation/application.py +542 -248
  15. orionis/foundation/config/app/entities/app.py +107 -90
  16. orionis/foundation/config/auth/entities/auth.py +4 -33
  17. orionis/foundation/config/cache/entities/cache.py +18 -41
  18. orionis/foundation/config/cache/entities/file.py +8 -35
  19. orionis/foundation/config/cache/entities/stores.py +17 -38
  20. orionis/foundation/config/cors/entities/cors.py +41 -54
  21. orionis/foundation/config/database/entities/connections.py +40 -56
  22. orionis/foundation/config/database/entities/database.py +11 -38
  23. orionis/foundation/config/database/entities/mysql.py +48 -76
  24. orionis/foundation/config/database/entities/oracle.py +30 -57
  25. orionis/foundation/config/database/entities/pgsql.py +45 -61
  26. orionis/foundation/config/database/entities/sqlite.py +26 -53
  27. orionis/foundation/config/filesystems/entitites/aws.py +28 -49
  28. orionis/foundation/config/filesystems/entitites/disks.py +27 -47
  29. orionis/foundation/config/filesystems/entitites/filesystems.py +15 -37
  30. orionis/foundation/config/filesystems/entitites/local.py +9 -35
  31. orionis/foundation/config/filesystems/entitites/public.py +14 -41
  32. orionis/foundation/config/logging/entities/channels.py +56 -86
  33. orionis/foundation/config/logging/entities/chunked.py +9 -9
  34. orionis/foundation/config/logging/entities/daily.py +8 -8
  35. orionis/foundation/config/logging/entities/hourly.py +6 -6
  36. orionis/foundation/config/logging/entities/logging.py +12 -18
  37. orionis/foundation/config/logging/entities/monthly.py +7 -7
  38. orionis/foundation/config/logging/entities/stack.py +5 -5
  39. orionis/foundation/config/logging/entities/weekly.py +6 -6
  40. orionis/foundation/config/mail/entities/file.py +9 -36
  41. orionis/foundation/config/mail/entities/mail.py +22 -40
  42. orionis/foundation/config/mail/entities/mailers.py +29 -44
  43. orionis/foundation/config/mail/entities/smtp.py +47 -48
  44. orionis/foundation/config/queue/entities/brokers.py +19 -41
  45. orionis/foundation/config/queue/entities/database.py +24 -46
  46. orionis/foundation/config/queue/entities/queue.py +28 -40
  47. orionis/foundation/config/roots/paths.py +272 -468
  48. orionis/foundation/config/session/entities/session.py +23 -53
  49. orionis/foundation/config/startup.py +165 -135
  50. orionis/foundation/config/testing/entities/testing.py +137 -122
  51. orionis/foundation/config/testing/enums/__init__.py +6 -2
  52. orionis/foundation/config/testing/enums/drivers.py +16 -0
  53. orionis/foundation/config/testing/enums/verbosity.py +18 -0
  54. orionis/foundation/contracts/application.py +152 -362
  55. orionis/foundation/providers/console_provider.py +24 -2
  56. orionis/foundation/providers/dumper_provider.py +24 -2
  57. orionis/foundation/providers/logger_provider.py +24 -2
  58. orionis/foundation/providers/path_resolver_provider.py +25 -2
  59. orionis/foundation/providers/progress_bar_provider.py +24 -2
  60. orionis/foundation/providers/testing_provider.py +39 -0
  61. orionis/foundation/providers/workers_provider.py +24 -2
  62. orionis/metadata/framework.py +1 -1
  63. orionis/services/asynchrony/contracts/coroutines.py +13 -5
  64. orionis/services/asynchrony/coroutines.py +33 -29
  65. orionis/services/asynchrony/exceptions/exception.py +9 -1
  66. orionis/services/environment/core/dot_env.py +46 -34
  67. orionis/services/environment/enums/__init__.py +0 -0
  68. orionis/services/environment/enums/cast_type.py +42 -0
  69. orionis/services/environment/helpers/functions.py +1 -2
  70. orionis/services/environment/key/__init__.py +0 -0
  71. orionis/services/environment/key/key_generator.py +37 -0
  72. orionis/services/environment/serializer/__init__.py +0 -0
  73. orionis/services/environment/serializer/values.py +21 -0
  74. orionis/services/environment/validators/__init__.py +0 -0
  75. orionis/services/environment/validators/key_name.py +46 -0
  76. orionis/services/environment/validators/types.py +45 -0
  77. orionis/services/system/contracts/imports.py +38 -18
  78. orionis/services/system/contracts/workers.py +29 -12
  79. orionis/services/system/imports.py +65 -25
  80. orionis/services/system/runtime/imports.py +18 -9
  81. orionis/services/system/workers.py +49 -16
  82. orionis/support/entities/__init__.py +0 -0
  83. orionis/support/entities/base.py +104 -0
  84. orionis/support/facades/testing.py +15 -0
  85. orionis/support/facades/workers.py +1 -1
  86. orionis/test/cases/asynchronous.py +0 -11
  87. orionis/test/cases/synchronous.py +0 -9
  88. orionis/test/contracts/dumper.py +11 -4
  89. orionis/test/contracts/kernel.py +5 -110
  90. orionis/test/contracts/logs.py +27 -65
  91. orionis/test/contracts/printer.py +16 -128
  92. orionis/test/contracts/test_result.py +100 -0
  93. orionis/test/contracts/unit_test.py +87 -150
  94. orionis/test/core/unit_test.py +608 -554
  95. orionis/test/entities/result.py +22 -2
  96. orionis/test/enums/__init__.py +0 -2
  97. orionis/test/enums/status.py +14 -9
  98. orionis/test/exceptions/config.py +9 -1
  99. orionis/test/exceptions/failure.py +34 -11
  100. orionis/test/exceptions/persistence.py +10 -2
  101. orionis/test/exceptions/runtime.py +9 -1
  102. orionis/test/exceptions/value.py +13 -1
  103. orionis/test/kernel.py +87 -289
  104. orionis/test/output/dumper.py +83 -18
  105. orionis/test/output/printer.py +399 -156
  106. orionis/test/records/logs.py +203 -82
  107. orionis/test/validators/__init__.py +33 -0
  108. orionis/test/validators/base_path.py +45 -0
  109. orionis/test/validators/execution_mode.py +45 -0
  110. orionis/test/validators/fail_fast.py +37 -0
  111. orionis/test/validators/folder_path.py +34 -0
  112. orionis/test/validators/module_name.py +31 -0
  113. orionis/test/validators/name_pattern.py +40 -0
  114. orionis/test/validators/pattern.py +36 -0
  115. orionis/test/validators/persistent.py +42 -0
  116. orionis/test/validators/persistent_driver.py +43 -0
  117. orionis/test/validators/print_result.py +37 -0
  118. orionis/test/validators/tags.py +37 -0
  119. orionis/test/validators/throw_exception.py +39 -0
  120. orionis/test/validators/verbosity.py +37 -0
  121. orionis/test/validators/web_report.py +35 -0
  122. orionis/test/validators/workers.py +31 -0
  123. orionis/test/view/render.py +48 -54
  124. {orionis-0.405.0.dist-info → orionis-0.407.0.dist-info}/METADATA +1 -1
  125. {orionis-0.405.0.dist-info → orionis-0.407.0.dist-info}/RECORD +170 -112
  126. tests/container/__init__.py +0 -0
  127. tests/container/context/__init__.py +0 -0
  128. tests/container/context/test_manager.py +27 -0
  129. tests/container/context/test_scope.py +23 -0
  130. tests/container/entities/__init__.py +0 -0
  131. tests/container/entities/test_binding.py +133 -0
  132. tests/container/enums/__init__.py +0 -0
  133. tests/container/enums/test_lifetimes.py +63 -0
  134. tests/container/facades/__init__.py +0 -0
  135. tests/container/facades/test_facade.py +61 -0
  136. tests/container/mocks/__init__.py +0 -0
  137. tests/container/mocks/mock_complex_classes.py +482 -0
  138. tests/container/mocks/mock_simple_classes.py +32 -0
  139. tests/container/providers/__init__.py +0 -0
  140. tests/container/providers/test_providers.py +48 -0
  141. tests/container/resolver/__init__.py +0 -0
  142. tests/container/resolver/test_resolver.py +55 -0
  143. tests/container/test_container.py +254 -0
  144. tests/container/test_singleton.py +98 -0
  145. tests/container/test_thread_safety.py +217 -0
  146. tests/container/validators/__init__.py +0 -0
  147. tests/container/validators/test_implements.py +140 -0
  148. tests/container/validators/test_is_abstract_class.py +99 -0
  149. tests/container/validators/test_is_callable.py +73 -0
  150. tests/container/validators/test_is_concrete_class.py +97 -0
  151. tests/container/validators/test_is_instance.py +105 -0
  152. tests/container/validators/test_is_not_subclass.py +117 -0
  153. tests/container/validators/test_is_subclass.py +115 -0
  154. tests/container/validators/test_is_valid_alias.py +113 -0
  155. tests/container/validators/test_lifetime.py +75 -0
  156. tests/example/test_example.py +2 -2
  157. tests/foundation/config/testing/test_foundation_config_testing.py +1 -1
  158. tests/metadata/test_metadata_framework.py +89 -24
  159. tests/metadata/test_metadata_package.py +55 -10
  160. tests/services/asynchrony/test_services_asynchrony_coroutine.py +52 -7
  161. tests/services/system/test_services_system_imports.py +119 -16
  162. tests/services/system/test_services_system_workers.py +71 -30
  163. tests/testing/test_testing_result.py +117 -117
  164. tests/testing/test_testing_unit.py +209 -209
  165. orionis/foundation/config/base.py +0 -112
  166. orionis/test/arguments/parser.py +0 -187
  167. orionis/test/contracts/parser.py +0 -43
  168. orionis/test/entities/arguments.py +0 -38
  169. orionis/test/enums/execution_mode.py +0 -16
  170. /orionis/{test/arguments → console/base/contracts}/__init__.py +0 -0
  171. /orionis/foundation/config/testing/enums/{test_mode.py → mode.py} +0 -0
  172. {orionis-0.405.0.dist-info → orionis-0.407.0.dist-info}/WHEEL +0 -0
  173. {orionis-0.405.0.dist-info → orionis-0.407.0.dist-info}/licenses/LICENCE +0 -0
  174. {orionis-0.405.0.dist-info → orionis-0.407.0.dist-info}/top_level.txt +0 -0
  175. {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
- 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
+ # 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