orionis 0.414.0__py3-none-any.whl → 0.415.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/metadata/framework.py +1 -1
- orionis/test/core/unit_test.py +26 -10
- orionis/test/output/dumper.py +1 -1
- {orionis-0.414.0.dist-info → orionis-0.415.0.dist-info}/METADATA +1 -1
- {orionis-0.414.0.dist-info → orionis-0.415.0.dist-info}/RECORD +77 -68
- orionis-0.415.0.dist-info/top_level.txt +4 -0
- tests/container/entities/test_binding.py +1 -1
- tests/container/test_thread_safety.py +0 -1
- tests/testing/cases/__init__.py +0 -0
- tests/testing/cases/test_testing_asynchronous.py +63 -0
- tests/testing/cases/test_testing_synchronous.py +59 -0
- tests/testing/entities/__init__.py +0 -0
- tests/testing/entities/test_testing_result.py +185 -0
- tests/testing/enums/__init__.py +0 -0
- tests/testing/enums/test_testing_status.py +68 -0
- tests/testing/output/__init__.py +0 -0
- tests/testing/output/test_testing_dumper.py +32 -0
- tests/testing/output/test_testing_printer.py +42 -0
- tests/testing/test_testing_unit.py +110 -209
- orionis-0.414.0.dist-info/top_level.txt +0 -2
- tests/testing/test_testing_result.py +0 -131
- {tests/foundation → environment}/__init__.py +0 -0
- {tests/services/environment → environment}/test_services_environment.py +0 -0
- {tests/foundation/config → foundation}/__init__.py +0 -0
- {tests/foundation/config/app → foundation/config}/__init__.py +0 -0
- {tests/foundation/config/auth → foundation/config/app}/__init__.py +0 -0
- {tests/foundation → foundation}/config/app/test_foundation_config_app.py +0 -0
- {tests/foundation/config/cache → foundation/config/auth}/__init__.py +0 -0
- {tests/foundation → foundation}/config/auth/test_foundation_config_auth.py +0 -0
- {tests/foundation/config/cors → foundation/config/cache}/__init__.py +0 -0
- {tests/foundation → foundation}/config/cache/test_foundation_config_cache.py +0 -0
- {tests/foundation → foundation}/config/cache/test_foundation_config_cache_file.py +0 -0
- {tests/foundation → foundation}/config/cache/test_foundation_config_cache_stores.py +0 -0
- {tests/foundation/config/database → foundation/config/cors}/__init__.py +0 -0
- {tests/foundation → foundation}/config/cors/test_foundation_config_cors.py +0 -0
- {tests/foundation/config/filesystems → foundation/config/database}/__init__.py +0 -0
- {tests/foundation → foundation}/config/database/test_foundation_config_database.py +0 -0
- {tests/foundation → foundation}/config/database/test_foundation_config_database_connections.py +0 -0
- {tests/foundation → foundation}/config/database/test_foundation_config_database_mysql.py +0 -0
- {tests/foundation → foundation}/config/database/test_foundation_config_database_oracle.py +0 -0
- {tests/foundation → foundation}/config/database/test_foundation_config_database_pgsql.py +0 -0
- {tests/foundation → foundation}/config/database/test_foundation_config_database_sqlite.py +0 -0
- {tests/foundation/config/logging → foundation/config/filesystems}/__init__.py +0 -0
- {tests/foundation → foundation}/config/filesystems/test_foundation_config_filesystems.py +0 -0
- {tests/foundation → foundation}/config/filesystems/test_foundation_config_filesystems_aws.py +0 -0
- {tests/foundation → foundation}/config/filesystems/test_foundation_config_filesystems_disks.py +0 -0
- {tests/foundation → foundation}/config/filesystems/test_foundation_config_filesystems_local.py +0 -0
- {tests/foundation → foundation}/config/filesystems/test_foundation_config_filesystems_public.py +0 -0
- {tests/foundation/config/mail → foundation/config/logging}/__init__.py +0 -0
- {tests/foundation → foundation}/config/logging/test_foundation_config_logging.py +0 -0
- {tests/foundation → foundation}/config/logging/test_foundation_config_logging_channels.py +0 -0
- {tests/foundation → foundation}/config/logging/test_foundation_config_logging_chunked.py +0 -0
- {tests/foundation → foundation}/config/logging/test_foundation_config_logging_daily.py +0 -0
- {tests/foundation → foundation}/config/logging/test_foundation_config_logging_hourly.py +0 -0
- {tests/foundation → foundation}/config/logging/test_foundation_config_logging_monthly.py +0 -0
- {tests/foundation → foundation}/config/logging/test_foundation_config_logging_stack.py +0 -0
- {tests/foundation → foundation}/config/logging/test_foundation_config_logging_weekly.py +0 -0
- {tests/foundation/config/queue → foundation/config/mail}/__init__.py +0 -0
- {tests/foundation → foundation}/config/mail/test_foundation_config_mail.py +0 -0
- {tests/foundation → foundation}/config/mail/test_foundation_config_mail_file.py +0 -0
- {tests/foundation → foundation}/config/mail/test_foundation_config_mail_mailers.py +0 -0
- {tests/foundation → foundation}/config/mail/test_foundation_config_mail_smtp.py +0 -0
- {tests/foundation/config/root → foundation/config/queue}/__init__.py +0 -0
- {tests/foundation → foundation}/config/queue/test_foundation_config_queue.py +0 -0
- {tests/foundation → foundation}/config/queue/test_foundation_config_queue_brokers.py +0 -0
- {tests/foundation → foundation}/config/queue/test_foundation_config_queue_database.py +0 -0
- {tests/foundation/config/session → foundation/config/root}/__init__.py +0 -0
- {tests/foundation → foundation}/config/root/test_foundation_config_root_paths.py +0 -0
- {tests/foundation/config/startup → foundation/config/session}/__init__.py +0 -0
- {tests/foundation → foundation}/config/session/test_foundation_config_session.py +0 -0
- {tests/foundation/config/testing → foundation/config/startup}/__init__.py +0 -0
- {tests/foundation → foundation}/config/startup/test_foundation_config_startup.py +0 -0
- {tests/foundation/exceptions → foundation/config/testing}/__init__.py +0 -0
- {tests/foundation → foundation}/config/testing/test_foundation_config_testing.py +0 -0
- {tests/services/environment → foundation/exceptions}/__init__.py +0 -0
- {tests/foundation → foundation}/exceptions/test_foundation_config_exceptions.py +0 -0
- {orionis-0.414.0.dist-info → orionis-0.415.0.dist-info}/WHEEL +0 -0
- {orionis-0.414.0.dist-info → orionis-0.415.0.dist-info}/licenses/LICENCE +0 -0
- {orionis-0.414.0.dist-info → orionis-0.415.0.dist-info}/zip-safe +0 -0
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
from enum import Enum
|
|
2
|
+
from orionis.test.cases.asynchronous import AsyncTestCase
|
|
3
|
+
from orionis.test.enums.status import TestStatus
|
|
4
|
+
|
|
5
|
+
class TestTestStatus(AsyncTestCase):
|
|
6
|
+
|
|
7
|
+
async def testHasEnumMembers(self):
|
|
8
|
+
"""
|
|
9
|
+
Checks that the TestStatus enum contains the expected members.
|
|
10
|
+
|
|
11
|
+
This test verifies the presence of the following enum members:
|
|
12
|
+
'PASSED', 'FAILED', 'ERRORED', and 'SKIPPED'.
|
|
13
|
+
|
|
14
|
+
Returns
|
|
15
|
+
-------
|
|
16
|
+
None
|
|
17
|
+
This method does not return a value. It asserts the existence of enum members.
|
|
18
|
+
"""
|
|
19
|
+
# Assert that each expected member exists in TestStatus
|
|
20
|
+
self.assertTrue(hasattr(TestStatus, "PASSED"))
|
|
21
|
+
self.assertTrue(hasattr(TestStatus, "FAILED"))
|
|
22
|
+
self.assertTrue(hasattr(TestStatus, "ERRORED"))
|
|
23
|
+
self.assertTrue(hasattr(TestStatus, "SKIPPED"))
|
|
24
|
+
|
|
25
|
+
async def testEnumValuesAreUnique(self):
|
|
26
|
+
"""
|
|
27
|
+
Ensures that all TestStatus enum member values are unique.
|
|
28
|
+
|
|
29
|
+
This test collects all values from the TestStatus enum and checks for uniqueness.
|
|
30
|
+
|
|
31
|
+
Returns
|
|
32
|
+
-------
|
|
33
|
+
None
|
|
34
|
+
This method does not return a value. It asserts the uniqueness of enum values.
|
|
35
|
+
"""
|
|
36
|
+
# Gather all enum values
|
|
37
|
+
values = [status.value for status in TestStatus]
|
|
38
|
+
# Assert that the number of values equals the number of unique values
|
|
39
|
+
self.assertEqual(len(values), len(set(values)))
|
|
40
|
+
|
|
41
|
+
async def testEnumIsInstanceOfEnum(self):
|
|
42
|
+
"""
|
|
43
|
+
Validates that TestStatus is a subclass of Enum.
|
|
44
|
+
|
|
45
|
+
This test checks the inheritance of TestStatus from the Enum base class.
|
|
46
|
+
|
|
47
|
+
Returns
|
|
48
|
+
-------
|
|
49
|
+
None
|
|
50
|
+
This method does not return a value. It asserts the subclass relationship.
|
|
51
|
+
"""
|
|
52
|
+
# Assert that TestStatus inherits from Enum
|
|
53
|
+
self.assertTrue(issubclass(TestStatus, Enum))
|
|
54
|
+
|
|
55
|
+
async def testEnumMembersType(self):
|
|
56
|
+
"""
|
|
57
|
+
Confirms that each member of TestStatus is an instance of TestStatus.
|
|
58
|
+
|
|
59
|
+
This test iterates through all members of TestStatus and checks their type.
|
|
60
|
+
|
|
61
|
+
Returns
|
|
62
|
+
-------
|
|
63
|
+
None
|
|
64
|
+
This method does not return a value. It asserts the type of each enum member.
|
|
65
|
+
"""
|
|
66
|
+
# Assert that each enum member is an instance of TestStatus
|
|
67
|
+
for status in TestStatus:
|
|
68
|
+
self.assertIsInstance(status, TestStatus)
|
|
File without changes
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
from orionis.test.cases.asynchronous import AsyncTestCase
|
|
2
|
+
from orionis.test.output.dumper import TestDumper
|
|
3
|
+
|
|
4
|
+
class TestTestingDumper(AsyncTestCase):
|
|
5
|
+
|
|
6
|
+
async def testMethodsExist(self):
|
|
7
|
+
"""
|
|
8
|
+
Checks if the required methods are present in the TestDumper class.
|
|
9
|
+
|
|
10
|
+
This test verifies that the `TestDumper` class contains all methods
|
|
11
|
+
specified in the `required_methods` list. It asserts the existence of
|
|
12
|
+
each method using `hasattr`.
|
|
13
|
+
|
|
14
|
+
Returns
|
|
15
|
+
-------
|
|
16
|
+
None
|
|
17
|
+
This method does not return any value. It raises an assertion error if any required method is missing.
|
|
18
|
+
"""
|
|
19
|
+
|
|
20
|
+
required_methods = [
|
|
21
|
+
"dd",
|
|
22
|
+
"dump"
|
|
23
|
+
]
|
|
24
|
+
|
|
25
|
+
# Iterate over the list of required method names
|
|
26
|
+
for method_name in required_methods:
|
|
27
|
+
|
|
28
|
+
# Assert that each required method exists in TestDumper
|
|
29
|
+
self.assertTrue(
|
|
30
|
+
hasattr(TestDumper, method_name),
|
|
31
|
+
f"{method_name} does not exist"
|
|
32
|
+
)
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
from orionis.test.cases.asynchronous import AsyncTestCase
|
|
2
|
+
from orionis.test.output.printer import TestPrinter
|
|
3
|
+
|
|
4
|
+
class TestTestingPrinter(AsyncTestCase):
|
|
5
|
+
|
|
6
|
+
async def testMethodsExist(self):
|
|
7
|
+
"""
|
|
8
|
+
Checks for the existence of required methods in the TestPrinter class.
|
|
9
|
+
|
|
10
|
+
This test ensures that all methods listed in `required_methods` are present
|
|
11
|
+
in the `TestPrinter` class by asserting their existence using `hasattr`.
|
|
12
|
+
|
|
13
|
+
Parameters
|
|
14
|
+
----------
|
|
15
|
+
self : TestTestingPrinter
|
|
16
|
+
The test case instance.
|
|
17
|
+
|
|
18
|
+
Returns
|
|
19
|
+
-------
|
|
20
|
+
None
|
|
21
|
+
Raises an AssertionError if any required method is missing.
|
|
22
|
+
"""
|
|
23
|
+
# List of method names that must exist in TestPrinter
|
|
24
|
+
required_methods = [
|
|
25
|
+
"print",
|
|
26
|
+
"startMessage",
|
|
27
|
+
"finishMessage",
|
|
28
|
+
"executePanel",
|
|
29
|
+
"linkWebReport",
|
|
30
|
+
"summaryTable",
|
|
31
|
+
"displayResults",
|
|
32
|
+
"unittestResult"
|
|
33
|
+
]
|
|
34
|
+
|
|
35
|
+
# Check each required method for existence in TestPrinter
|
|
36
|
+
for method_name in required_methods:
|
|
37
|
+
|
|
38
|
+
# Assert that the method exists in TestPrinter
|
|
39
|
+
self.assertTrue(
|
|
40
|
+
hasattr(TestPrinter, method_name),
|
|
41
|
+
f"{method_name} does not exist"
|
|
42
|
+
)
|
|
@@ -1,209 +1,110 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
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
|
-
# 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
|
+
import unittest
|
|
2
|
+
from unittest.mock import MagicMock
|
|
3
|
+
from orionis.foundation.config.testing.enums.drivers import PersistentDrivers
|
|
4
|
+
from orionis.foundation.config.testing.enums.mode import ExecutionMode
|
|
5
|
+
from orionis.test.cases.asynchronous import AsyncTestCase
|
|
6
|
+
from orionis.test.core.unit_test import UnitTest
|
|
7
|
+
|
|
8
|
+
class TestTestingUnit(AsyncTestCase):
|
|
9
|
+
|
|
10
|
+
async def testDefaultConfiguration(self) -> None:
|
|
11
|
+
"""
|
|
12
|
+
Test that the `UnitTest` class initializes with correct default configuration values.
|
|
13
|
+
"""
|
|
14
|
+
unit_test = UnitTest()
|
|
15
|
+
self.assertIsInstance(unit_test._UnitTest__loader, unittest.TestLoader)
|
|
16
|
+
self.assertIsInstance(unit_test._UnitTest__suite, unittest.TestSuite)
|
|
17
|
+
|
|
18
|
+
async def testConfigureMethod(self) -> None:
|
|
19
|
+
"""
|
|
20
|
+
Tests the `configure` method of the `UnitTest` class for correct configuration updates.
|
|
21
|
+
"""
|
|
22
|
+
unit_test = UnitTest()
|
|
23
|
+
configured = unit_test.configure(
|
|
24
|
+
verbosity=1,
|
|
25
|
+
execution_mode=ExecutionMode.PARALLEL,
|
|
26
|
+
max_workers=8,
|
|
27
|
+
fail_fast=True,
|
|
28
|
+
print_result=False,
|
|
29
|
+
throw_exception=True,
|
|
30
|
+
persistent=False,
|
|
31
|
+
persistent_driver=PersistentDrivers.JSON,
|
|
32
|
+
web_report=False
|
|
33
|
+
)
|
|
34
|
+
self.assertEqual(unit_test._UnitTest__verbosity, 1)
|
|
35
|
+
self.assertEqual(unit_test._UnitTest__execution_mode, ExecutionMode.PARALLEL.value)
|
|
36
|
+
self.assertEqual(unit_test._UnitTest__max_workers, 8)
|
|
37
|
+
self.assertTrue(unit_test._UnitTest__fail_fast)
|
|
38
|
+
self.assertTrue(unit_test._UnitTest__throw_exception)
|
|
39
|
+
self.assertFalse(unit_test._UnitTest__persistent)
|
|
40
|
+
self.assertEqual(unit_test._UnitTest__persistent_driver, PersistentDrivers.JSON.value)
|
|
41
|
+
self.assertFalse(unit_test._UnitTest__web_report)
|
|
42
|
+
self.assertIs(configured, unit_test)
|
|
43
|
+
|
|
44
|
+
async def testFlattenTestSuite(self) -> None:
|
|
45
|
+
"""
|
|
46
|
+
Tests the `_flattenTestSuite` method of the `UnitTest` class for correct flattening of nested test suites.
|
|
47
|
+
"""
|
|
48
|
+
unit_test = UnitTest()
|
|
49
|
+
test_case1 = MagicMock()
|
|
50
|
+
test_case2 = MagicMock()
|
|
51
|
+
nested_suite = unittest.TestSuite()
|
|
52
|
+
nested_suite.addTest(test_case1)
|
|
53
|
+
nested_suite.addTest(test_case2)
|
|
54
|
+
main_suite = unittest.TestSuite()
|
|
55
|
+
main_suite.addTest(nested_suite)
|
|
56
|
+
flattened = unit_test._UnitTest__flattenTestSuite(main_suite)
|
|
57
|
+
self.assertEqual(len(flattened), 2)
|
|
58
|
+
self.assertIn(test_case1, flattened)
|
|
59
|
+
self.assertIn(test_case2, flattened)
|
|
60
|
+
|
|
61
|
+
async def testMergeTestResults(self) -> None:
|
|
62
|
+
"""
|
|
63
|
+
Tests the `_mergeTestResults` method of the `UnitTest` class for correct aggregation of test results.
|
|
64
|
+
"""
|
|
65
|
+
unit_test = UnitTest()
|
|
66
|
+
combined = unittest.TestResult()
|
|
67
|
+
individual = unittest.TestResult()
|
|
68
|
+
individual.testsRun = 2
|
|
69
|
+
individual.failures = [('test1', 'failure')]
|
|
70
|
+
individual.errors = [('test2', 'error')]
|
|
71
|
+
individual.skipped = []
|
|
72
|
+
individual.expectedFailures = []
|
|
73
|
+
individual.unexpectedSuccesses = []
|
|
74
|
+
unit_test._UnitTest__mergeTestResults(combined, individual)
|
|
75
|
+
self.assertEqual(combined.testsRun, 2)
|
|
76
|
+
self.assertEqual(len(combined.failures), 1)
|
|
77
|
+
self.assertEqual(len(combined.errors), 1)
|
|
78
|
+
|
|
79
|
+
async def testClearTests(self) -> None:
|
|
80
|
+
"""
|
|
81
|
+
Tests the `clearTests` method of the `UnitTest` class to ensure it properly resets the test suite.
|
|
82
|
+
"""
|
|
83
|
+
unit_test = UnitTest()
|
|
84
|
+
mock_test = MagicMock()
|
|
85
|
+
unit_test._UnitTest__suite.addTest(mock_test)
|
|
86
|
+
unit_test.clearTests()
|
|
87
|
+
self.assertEqual(len(unit_test._UnitTest__suite._tests), 0)
|
|
88
|
+
|
|
89
|
+
async def testGetTestNames(self) -> None:
|
|
90
|
+
"""
|
|
91
|
+
Tests the `getTestNames` method of the `UnitTest` class for correct extraction of test identifiers.
|
|
92
|
+
"""
|
|
93
|
+
unit_test = UnitTest()
|
|
94
|
+
mock_test = MagicMock()
|
|
95
|
+
mock_test.id.return_value = 'test_id'
|
|
96
|
+
unit_test._UnitTest__suite.addTest(mock_test)
|
|
97
|
+
names = unit_test.getTestNames()
|
|
98
|
+
self.assertEqual(names, ['test_id'])
|
|
99
|
+
|
|
100
|
+
async def testGetTestCount(self) -> None:
|
|
101
|
+
"""
|
|
102
|
+
Tests the `getTestCount` method of the `UnitTest` class for accurate test counting.
|
|
103
|
+
"""
|
|
104
|
+
unit_test = UnitTest()
|
|
105
|
+
mock_test1 = MagicMock()
|
|
106
|
+
mock_test2 = MagicMock()
|
|
107
|
+
unit_test._UnitTest__suite.addTest(mock_test1)
|
|
108
|
+
unit_test._UnitTest__suite.addTest(mock_test2)
|
|
109
|
+
count = unit_test.getTestCount()
|
|
110
|
+
self.assertEqual(count, 2)
|
|
@@ -1,131 +0,0 @@
|
|
|
1
|
-
# from orionis.test.cases.asynchronous import AsyncTestCase
|
|
2
|
-
# from orionis.test.entities.result import TestResult
|
|
3
|
-
# from orionis.test.enums import TestStatus
|
|
4
|
-
|
|
5
|
-
# class TestTestingResult(AsyncTestCase):
|
|
6
|
-
|
|
7
|
-
# async def testDefaultValues(self) -> None:
|
|
8
|
-
# """
|
|
9
|
-
# Ensures that when optional fields are not provided during initialization of a TestResult
|
|
10
|
-
# instance, they are set to None.
|
|
11
|
-
|
|
12
|
-
# Notes
|
|
13
|
-
# -----
|
|
14
|
-
# This test verifies the default behavior of the following optional fields:
|
|
15
|
-
# - error_message
|
|
16
|
-
# - traceback
|
|
17
|
-
# - class_name
|
|
18
|
-
# - method
|
|
19
|
-
# - module
|
|
20
|
-
# - file_path
|
|
21
|
-
|
|
22
|
-
# Assertions
|
|
23
|
-
# ----------
|
|
24
|
-
# Each optional field is checked to confirm it is None after initialization.
|
|
25
|
-
# """
|
|
26
|
-
# result = TestResult(
|
|
27
|
-
# id=1,
|
|
28
|
-
# name="Sample Test",
|
|
29
|
-
# status=TestStatus.PASSED,
|
|
30
|
-
# execution_time=0.5
|
|
31
|
-
# )
|
|
32
|
-
# self.assertIsNone(result.error_message)
|
|
33
|
-
# self.assertIsNone(result.traceback)
|
|
34
|
-
# self.assertIsNone(result.class_name)
|
|
35
|
-
# self.assertIsNone(result.method)
|
|
36
|
-
# self.assertIsNone(result.module)
|
|
37
|
-
# self.assertIsNone(result.file_path)
|
|
38
|
-
|
|
39
|
-
# async def testRequiredFields(self) -> None:
|
|
40
|
-
# """
|
|
41
|
-
# Test that TestResult enforces the presence of all required (non-optional) fields during initialization.
|
|
42
|
-
# This test verifies that omitting any required field when creating a TestResult instance raises a TypeError.
|
|
43
|
-
|
|
44
|
-
# Notes
|
|
45
|
-
# -----
|
|
46
|
-
# - Attempts to instantiate TestResult with no arguments.
|
|
47
|
-
# - Attempts to instantiate TestResult missing the 'id' field.
|
|
48
|
-
# - Expects a TypeError to be raised in both cases.
|
|
49
|
-
# """
|
|
50
|
-
# with self.assertRaises(TypeError):
|
|
51
|
-
# TestResult() # Missing all required fields
|
|
52
|
-
|
|
53
|
-
# with self.assertRaises(TypeError):
|
|
54
|
-
# # Missing id
|
|
55
|
-
# TestResult(
|
|
56
|
-
# name="Sample Test",
|
|
57
|
-
# status=TestStatus.PASSED,
|
|
58
|
-
# execution_time=0.5
|
|
59
|
-
# )
|
|
60
|
-
|
|
61
|
-
# async def testImmutable(self) -> None:
|
|
62
|
-
# """
|
|
63
|
-
# Test the immutability of TestResult instances.
|
|
64
|
-
# This test ensures that TestResult, implemented as a frozen dataclass, does not allow
|
|
65
|
-
# modification of its attributes after instantiation.
|
|
66
|
-
|
|
67
|
-
# Parameters
|
|
68
|
-
# ----------
|
|
69
|
-
# self : TestCase
|
|
70
|
-
# The test case instance.
|
|
71
|
-
|
|
72
|
-
# Raises
|
|
73
|
-
# ------
|
|
74
|
-
# FrozenInstanceError
|
|
75
|
-
# If an attempt is made to modify an attribute of a frozen TestResult instance.
|
|
76
|
-
# """
|
|
77
|
-
# result = TestResult(
|
|
78
|
-
# id=1,
|
|
79
|
-
# name="Sample Test",
|
|
80
|
-
# status=TestStatus.PASSED,
|
|
81
|
-
# execution_time=0.5
|
|
82
|
-
# )
|
|
83
|
-
# with self.assertRaises(Exception):
|
|
84
|
-
# result.name = "Modified Name"
|
|
85
|
-
|
|
86
|
-
# async def testStatusValues(self) -> None:
|
|
87
|
-
# """
|
|
88
|
-
# Parameters
|
|
89
|
-
# ----------
|
|
90
|
-
# self : TestCase
|
|
91
|
-
# The test case instance.
|
|
92
|
-
|
|
93
|
-
# Notes
|
|
94
|
-
# -----
|
|
95
|
-
# This test iterates over all possible values of the `TestStatus` enum and verifies
|
|
96
|
-
# that each value can be assigned to the `status` field of a `TestResult` instance.
|
|
97
|
-
# It asserts that the assigned status matches the expected value.
|
|
98
|
-
# """
|
|
99
|
-
# for status in TestStatus:
|
|
100
|
-
# result = TestResult(
|
|
101
|
-
# id=1,
|
|
102
|
-
# name="Status Test",
|
|
103
|
-
# status=status,
|
|
104
|
-
# execution_time=0.1
|
|
105
|
-
# )
|
|
106
|
-
# self.assertEqual(result.status, status)
|
|
107
|
-
|
|
108
|
-
# async def testErrorFields(self) -> None:
|
|
109
|
-
# """
|
|
110
|
-
# Parameters
|
|
111
|
-
# ----------
|
|
112
|
-
# self : TestCase
|
|
113
|
-
# The test case instance.
|
|
114
|
-
|
|
115
|
-
# Notes
|
|
116
|
-
# -----
|
|
117
|
-
# Verifies that the `error_message` and `traceback` fields are correctly stored in the `TestResult`
|
|
118
|
-
# object when provided during initialization.
|
|
119
|
-
# """
|
|
120
|
-
# error_msg = "Test failed"
|
|
121
|
-
# traceback = "Traceback info"
|
|
122
|
-
# result = TestResult(
|
|
123
|
-
# id=1,
|
|
124
|
-
# name="Failing Test",
|
|
125
|
-
# status=TestStatus.FAILED,
|
|
126
|
-
# execution_time=0.2,
|
|
127
|
-
# error_message=error_msg,
|
|
128
|
-
# traceback=traceback
|
|
129
|
-
# )
|
|
130
|
-
# self.assertEqual(result.error_message, error_msg)
|
|
131
|
-
# self.assertEqual(result.traceback, traceback)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{tests/foundation → foundation}/config/database/test_foundation_config_database_connections.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|