orionis 0.415.0__py3-none-any.whl → 0.417.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-0.415.0.dist-info → orionis-0.417.0.dist-info}/METADATA +1 -1
- {orionis-0.415.0.dist-info → orionis-0.417.0.dist-info}/RECORD +12 -8
- tests/testing/records/__init__.py +0 -0
- tests/testing/records/test_testing_records.py +181 -0
- tests/testing/test_testing_unit.py +147 -8
- tests/testing/validators/__init__.py +0 -0
- tests/testing/validators/test_testing_validators.py +449 -0
- {orionis-0.415.0.dist-info → orionis-0.417.0.dist-info}/WHEEL +0 -0
- {orionis-0.415.0.dist-info → orionis-0.417.0.dist-info}/licenses/LICENCE +0 -0
- {orionis-0.415.0.dist-info → orionis-0.417.0.dist-info}/top_level.txt +0 -0
- {orionis-0.415.0.dist-info → orionis-0.417.0.dist-info}/zip-safe +0 -0
orionis/metadata/framework.py
CHANGED
|
@@ -313,7 +313,7 @@ orionis/foundation/providers/progress_bar_provider.py,sha256=WW3grNgH-yV2meSSTeO
|
|
|
313
313
|
orionis/foundation/providers/testing_provider.py,sha256=iJSN2RIChbYIL-1ue6vmPmDMCSrvERDkti4Er9MPiLA,1102
|
|
314
314
|
orionis/foundation/providers/workers_provider.py,sha256=kiQjQRyUEyiBX2zcbF_KmqRgvc7Bvxsvg5oMtIvYniM,1075
|
|
315
315
|
orionis/metadata/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
316
|
-
orionis/metadata/framework.py,sha256=
|
|
316
|
+
orionis/metadata/framework.py,sha256=mgSuf0lS1a_bBnjhqeXaV2Y7ZfnUu4h2gWcRaoYMTmI,4960
|
|
317
317
|
orionis/metadata/package.py,sha256=tqLfBRo-w1j_GN4xvzUNFyweWYFS-qhSgAEc-AmCH1M,5452
|
|
318
318
|
orionis/services/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
319
319
|
orionis/services/asynchrony/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
@@ -483,7 +483,7 @@ orionis/test/validators/web_report.py,sha256=-h3Fe9jY93_kzUhd2NBIqEfCcBpu-8Ei9x3
|
|
|
483
483
|
orionis/test/validators/workers.py,sha256=LGffDKtK6SKixFKzIYPQpI5aFeQPAGXpv_LUtmEu6g4,1102
|
|
484
484
|
orionis/test/view/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
485
485
|
orionis/test/view/render.py,sha256=3ICz68l-WF3BtnYqH5m-ktN9UD00MELMbmMnyJDV74A,4768
|
|
486
|
-
orionis-0.
|
|
486
|
+
orionis-0.417.0.dist-info/licenses/LICENCE,sha256=-_4cF2EBKuYVS_SQpy1uapq0oJPUU1vl_RUWSy2jJTo,1111
|
|
487
487
|
tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
488
488
|
tests/container/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
489
489
|
tests/container/test_container.py,sha256=asv8TkkupVoex6SWod74NBl4dSs7wb9mLmu_glNdNy8,14815
|
|
@@ -558,7 +558,7 @@ tests/support/standard/test_services_std.py,sha256=U0hNF50YE4aLE3Z9yWB2awl9owFQR
|
|
|
558
558
|
tests/support/wrapper/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
559
559
|
tests/support/wrapper/test_services_wrapper_docdict.py,sha256=Q_qyqZodLiTQ6Pv9zILfIoZj6l-WPzNWuIoRf1GTGY0,7535
|
|
560
560
|
tests/testing/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
561
|
-
tests/testing/test_testing_unit.py,sha256=
|
|
561
|
+
tests/testing/test_testing_unit.py,sha256=Y7CBIs8n7GO_Grd9XLNz0BDT5ULSEbKK1zOUWkp3Vio,10207
|
|
562
562
|
tests/testing/cases/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
563
563
|
tests/testing/cases/test_testing_asynchronous.py,sha256=gBcUyx1gmhulC-51BLtJOCwQOK6EMBaUws8eG8nxYOs,2218
|
|
564
564
|
tests/testing/cases/test_testing_synchronous.py,sha256=n7btUA-2cXPx-HLRfyI7YtVuJvcSuYVC-z843SktPCk,2427
|
|
@@ -569,8 +569,12 @@ tests/testing/enums/test_testing_status.py,sha256=Jld1j4nn1IvK_Cok4k-BIRUg3DiB55
|
|
|
569
569
|
tests/testing/output/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
570
570
|
tests/testing/output/test_testing_dumper.py,sha256=QWuHEN-ImwiqNszqnsYUOJNwgZB1WM8ussw_DqFkfEY,1063
|
|
571
571
|
tests/testing/output/test_testing_printer.py,sha256=ov4u0FLHtdWt3onXDQr4-uaMMKE3QYZ4Z-K9LGOuUiM,1366
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
orionis-0.
|
|
572
|
+
tests/testing/records/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
573
|
+
tests/testing/records/test_testing_records.py,sha256=1MY5bCzY9yapjlOPB8t2SJz63V2_iGczqTmtnyHpnlE,6446
|
|
574
|
+
tests/testing/validators/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
575
|
+
tests/testing/validators/test_testing_validators.py,sha256=QdcF0Vhnnl_kD-PzceHJbUYOqwPTB1Td7YaTv8LTr30,19612
|
|
576
|
+
orionis-0.417.0.dist-info/METADATA,sha256=XLg_D-73TO_1-kXgtzAsdiwUPMvcOcRLbdK8rl3a1BA,4772
|
|
577
|
+
orionis-0.417.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
578
|
+
orionis-0.417.0.dist-info/top_level.txt,sha256=nkPWzvqkAzAmwPMPo3_iiUgzWMFOGfz6hVwdASslEGE,37
|
|
579
|
+
orionis-0.417.0.dist-info/zip-safe,sha256=frcCV1k9oG9oKj3dpUqdJg1PxRT2RSN_XKdLCPjaYaY,2
|
|
580
|
+
orionis-0.417.0.dist-info/RECORD,,
|
|
File without changes
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
import json
|
|
2
|
+
import tempfile
|
|
3
|
+
from orionis.test.cases.asynchronous import AsyncTestCase
|
|
4
|
+
from orionis.test.exceptions import OrionisTestValueError
|
|
5
|
+
from orionis.test.records.logs import TestLogs
|
|
6
|
+
|
|
7
|
+
class TestTestingRecords(AsyncTestCase):
|
|
8
|
+
|
|
9
|
+
async def testCreateAndGetReport(self):
|
|
10
|
+
"""
|
|
11
|
+
Tests the creation of a test report and retrieval of the most recent report.
|
|
12
|
+
|
|
13
|
+
This method creates a test report with all required fields, stores it using
|
|
14
|
+
the `TestLogs` class, and then retrieves the most recent report to verify
|
|
15
|
+
its contents.
|
|
16
|
+
|
|
17
|
+
Returns
|
|
18
|
+
-------
|
|
19
|
+
None
|
|
20
|
+
This is a test method and does not return any value. Assertions are used
|
|
21
|
+
to validate expected behavior.
|
|
22
|
+
"""
|
|
23
|
+
with tempfile.TemporaryDirectory() as tmpdir:
|
|
24
|
+
logs = TestLogs(tmpdir)
|
|
25
|
+
|
|
26
|
+
# Prepare a complete test report dictionary
|
|
27
|
+
report = {
|
|
28
|
+
"total_tests": 5,
|
|
29
|
+
"passed": 4,
|
|
30
|
+
"failed": 1,
|
|
31
|
+
"errors": 0,
|
|
32
|
+
"skipped": 0,
|
|
33
|
+
"total_time": 1.23,
|
|
34
|
+
"success_rate": 0.8,
|
|
35
|
+
"timestamp": "2024-06-01T12:00:00"
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
# Serialize the report to JSON and add to the dictionary
|
|
39
|
+
report["json"] = json.dumps(report)
|
|
40
|
+
|
|
41
|
+
# Store the report in the logs
|
|
42
|
+
result = logs.create(report)
|
|
43
|
+
self.assertTrue(result)
|
|
44
|
+
|
|
45
|
+
# Retrieve the most recent report
|
|
46
|
+
reports = logs.get(first=1)
|
|
47
|
+
self.assertEqual(len(reports), 1)
|
|
48
|
+
|
|
49
|
+
# Validate the contents of the retrieved report
|
|
50
|
+
self.assertEqual(json.loads(reports[0][1])["total_tests"], 5)
|
|
51
|
+
|
|
52
|
+
async def testCreateMissingFields(self):
|
|
53
|
+
"""
|
|
54
|
+
Tests error handling when creating a report with missing required fields.
|
|
55
|
+
|
|
56
|
+
This method attempts to create a report without the required 'timestamp'
|
|
57
|
+
field and expects an `OrionisTestValueError` to be raised.
|
|
58
|
+
|
|
59
|
+
Returns
|
|
60
|
+
-------
|
|
61
|
+
None
|
|
62
|
+
This is a test method and does not return any value. Assertions are used
|
|
63
|
+
to validate expected behavior.
|
|
64
|
+
"""
|
|
65
|
+
with tempfile.TemporaryDirectory() as tmpdir:
|
|
66
|
+
logs = TestLogs(tmpdir)
|
|
67
|
+
|
|
68
|
+
# Prepare a report missing the 'timestamp' field
|
|
69
|
+
report = {
|
|
70
|
+
"total_tests": 5,
|
|
71
|
+
"passed": 4,
|
|
72
|
+
"failed": 1,
|
|
73
|
+
"errors": 0,
|
|
74
|
+
"skipped": 0,
|
|
75
|
+
"total_time": 1.23,
|
|
76
|
+
"success_rate": 0.8,
|
|
77
|
+
}
|
|
78
|
+
report["json"] = json.dumps(report)
|
|
79
|
+
|
|
80
|
+
# Expect an error when creating the report
|
|
81
|
+
with self.assertRaises(OrionisTestValueError):
|
|
82
|
+
logs.create(report)
|
|
83
|
+
|
|
84
|
+
async def testResetDatabase(self):
|
|
85
|
+
"""
|
|
86
|
+
Tests the reset functionality of the test logs database.
|
|
87
|
+
|
|
88
|
+
This method creates a report, stores it, and then resets the logs database.
|
|
89
|
+
It verifies that the reset operation returns True.
|
|
90
|
+
|
|
91
|
+
Returns
|
|
92
|
+
-------
|
|
93
|
+
None
|
|
94
|
+
This is a test method and does not return any value. Assertions are used
|
|
95
|
+
to validate expected behavior.
|
|
96
|
+
"""
|
|
97
|
+
with tempfile.TemporaryDirectory() as tmpdir:
|
|
98
|
+
logs = TestLogs(tmpdir)
|
|
99
|
+
|
|
100
|
+
# Create and store a single report
|
|
101
|
+
report = {
|
|
102
|
+
"total_tests": 1,
|
|
103
|
+
"passed": 1,
|
|
104
|
+
"failed": 0,
|
|
105
|
+
"errors": 0,
|
|
106
|
+
"skipped": 0,
|
|
107
|
+
"total_time": 0.1,
|
|
108
|
+
"success_rate": 1.0,
|
|
109
|
+
"timestamp": "2024-06-01T12:00:00"
|
|
110
|
+
}
|
|
111
|
+
report["json"] = json.dumps(report)
|
|
112
|
+
logs.create(report)
|
|
113
|
+
|
|
114
|
+
# Reset the logs database and verify success
|
|
115
|
+
self.assertTrue(logs.reset())
|
|
116
|
+
|
|
117
|
+
async def testGetReportsInvalidParams(self):
|
|
118
|
+
"""
|
|
119
|
+
Tests error handling for invalid parameters passed to `TestLogs.get()`.
|
|
120
|
+
|
|
121
|
+
This method checks that passing mutually exclusive or invalid values to
|
|
122
|
+
`get()` raises an `OrionisTestValueError`.
|
|
123
|
+
|
|
124
|
+
Returns
|
|
125
|
+
-------
|
|
126
|
+
None
|
|
127
|
+
This is a test method and does not return any value. Assertions are used
|
|
128
|
+
to validate expected behavior.
|
|
129
|
+
"""
|
|
130
|
+
with tempfile.TemporaryDirectory() as tmpdir:
|
|
131
|
+
logs = TestLogs(tmpdir)
|
|
132
|
+
|
|
133
|
+
# Both 'first' and 'last' should not be provided together
|
|
134
|
+
with self.assertRaises(OrionisTestValueError):
|
|
135
|
+
logs.get(first=1, last=1)
|
|
136
|
+
|
|
137
|
+
# 'first' must be greater than zero
|
|
138
|
+
with self.assertRaises(OrionisTestValueError):
|
|
139
|
+
logs.get(first=0)
|
|
140
|
+
|
|
141
|
+
# 'last' must be greater than zero
|
|
142
|
+
with self.assertRaises(OrionisTestValueError):
|
|
143
|
+
logs.get(last=-1)
|
|
144
|
+
|
|
145
|
+
async def testGetLastReports(self):
|
|
146
|
+
"""
|
|
147
|
+
Tests retrieval of the last N reports and verifies their order.
|
|
148
|
+
|
|
149
|
+
This method creates multiple reports, retrieves the last two, and checks
|
|
150
|
+
that the reports are returned in descending order by their identifier.
|
|
151
|
+
|
|
152
|
+
Returns
|
|
153
|
+
-------
|
|
154
|
+
None
|
|
155
|
+
This is a test method and does not return any value. Assertions are used
|
|
156
|
+
to validate expected behavior.
|
|
157
|
+
"""
|
|
158
|
+
with tempfile.TemporaryDirectory() as tmpdir:
|
|
159
|
+
logs = TestLogs(tmpdir)
|
|
160
|
+
|
|
161
|
+
# Create and store three reports with increasing 'total_tests'
|
|
162
|
+
for i in range(3):
|
|
163
|
+
report = {
|
|
164
|
+
"total_tests": i+1,
|
|
165
|
+
"passed": i,
|
|
166
|
+
"failed": 1,
|
|
167
|
+
"errors": 0,
|
|
168
|
+
"skipped": 0,
|
|
169
|
+
"total_time": 0.1 * (i+1),
|
|
170
|
+
"success_rate": 0.5,
|
|
171
|
+
"timestamp": f"2024-06-01T12:00:0{i}"
|
|
172
|
+
}
|
|
173
|
+
report["json"] = json.dumps(report)
|
|
174
|
+
logs.create(report)
|
|
175
|
+
|
|
176
|
+
# Retrieve the last two reports
|
|
177
|
+
reports = logs.get(last=2)
|
|
178
|
+
self.assertEqual(len(reports), 2)
|
|
179
|
+
|
|
180
|
+
# Ensure the reports are ordered by descending identifier
|
|
181
|
+
self.assertTrue(reports[0][0] > reports[1][0])
|
|
@@ -9,17 +9,51 @@ class TestTestingUnit(AsyncTestCase):
|
|
|
9
9
|
|
|
10
10
|
async def testDefaultConfiguration(self) -> None:
|
|
11
11
|
"""
|
|
12
|
-
|
|
12
|
+
Tests the initialization of the `UnitTest` class to ensure it sets up
|
|
13
|
+
the default configuration values and internal attributes correctly.
|
|
14
|
+
|
|
15
|
+
Parameters
|
|
16
|
+
----------
|
|
17
|
+
self : TestTestingUnit
|
|
18
|
+
The test case instance.
|
|
19
|
+
|
|
20
|
+
Returns
|
|
21
|
+
-------
|
|
22
|
+
None
|
|
23
|
+
This method does not return any value.
|
|
24
|
+
|
|
25
|
+
Notes
|
|
26
|
+
-----
|
|
27
|
+
Verifies that the loader and suite attributes are instances of their expected classes.
|
|
13
28
|
"""
|
|
14
29
|
unit_test = UnitTest()
|
|
30
|
+
# Assert that the loader is correctly initialized as a TestLoader
|
|
15
31
|
self.assertIsInstance(unit_test._UnitTest__loader, unittest.TestLoader)
|
|
32
|
+
# Assert that the suite is correctly initialized as a TestSuite
|
|
16
33
|
self.assertIsInstance(unit_test._UnitTest__suite, unittest.TestSuite)
|
|
17
34
|
|
|
18
35
|
async def testConfigureMethod(self) -> None:
|
|
19
36
|
"""
|
|
20
|
-
Tests the `configure` method of the `UnitTest` class
|
|
37
|
+
Tests the `configure` method of the `UnitTest` class to ensure it correctly updates
|
|
38
|
+
the internal configuration attributes based on the provided arguments.
|
|
39
|
+
|
|
40
|
+
Parameters
|
|
41
|
+
----------
|
|
42
|
+
self : TestTestingUnit
|
|
43
|
+
The test case instance.
|
|
44
|
+
|
|
45
|
+
Returns
|
|
46
|
+
-------
|
|
47
|
+
None
|
|
48
|
+
This method does not return any value.
|
|
49
|
+
|
|
50
|
+
Notes
|
|
51
|
+
-----
|
|
52
|
+
- Verifies that each configuration parameter is set to the expected value.
|
|
53
|
+
- Ensures the `configure` method returns the same `UnitTest` instance for chaining.
|
|
21
54
|
"""
|
|
22
55
|
unit_test = UnitTest()
|
|
56
|
+
# Configure the UnitTest instance with custom parameters
|
|
23
57
|
configured = unit_test.configure(
|
|
24
58
|
verbosity=1,
|
|
25
59
|
execution_mode=ExecutionMode.PARALLEL,
|
|
@@ -31,6 +65,7 @@ class TestTestingUnit(AsyncTestCase):
|
|
|
31
65
|
persistent_driver=PersistentDrivers.JSON,
|
|
32
66
|
web_report=False
|
|
33
67
|
)
|
|
68
|
+
# Assert that each internal attribute matches the configured value
|
|
34
69
|
self.assertEqual(unit_test._UnitTest__verbosity, 1)
|
|
35
70
|
self.assertEqual(unit_test._UnitTest__execution_mode, ExecutionMode.PARALLEL.value)
|
|
36
71
|
self.assertEqual(unit_test._UnitTest__max_workers, 8)
|
|
@@ -39,31 +74,72 @@ class TestTestingUnit(AsyncTestCase):
|
|
|
39
74
|
self.assertFalse(unit_test._UnitTest__persistent)
|
|
40
75
|
self.assertEqual(unit_test._UnitTest__persistent_driver, PersistentDrivers.JSON.value)
|
|
41
76
|
self.assertFalse(unit_test._UnitTest__web_report)
|
|
77
|
+
# Ensure the configure method returns the same instance for chaining
|
|
42
78
|
self.assertIs(configured, unit_test)
|
|
43
79
|
|
|
44
80
|
async def testFlattenTestSuite(self) -> None:
|
|
45
81
|
"""
|
|
46
|
-
Tests the `_flattenTestSuite` method of the `UnitTest` class
|
|
82
|
+
Tests the `_flattenTestSuite` method of the `UnitTest` class to ensure it correctly flattens
|
|
83
|
+
nested `TestSuite` instances into a single list of test cases.
|
|
84
|
+
|
|
85
|
+
Parameters
|
|
86
|
+
----------
|
|
87
|
+
self : TestTestingUnit
|
|
88
|
+
The test case instance.
|
|
89
|
+
|
|
90
|
+
Returns
|
|
91
|
+
-------
|
|
92
|
+
None
|
|
93
|
+
This method does not return any value.
|
|
94
|
+
|
|
95
|
+
Notes
|
|
96
|
+
-----
|
|
97
|
+
- Verifies that all test cases within nested suites are extracted and returned in a flat list.
|
|
98
|
+
- Ensures that the flattened list contains all individual test cases from the nested structure.
|
|
47
99
|
"""
|
|
48
100
|
unit_test = UnitTest()
|
|
101
|
+
# Create mock test cases
|
|
49
102
|
test_case1 = MagicMock()
|
|
50
103
|
test_case2 = MagicMock()
|
|
104
|
+
# Create a nested TestSuite containing the mock test cases
|
|
51
105
|
nested_suite = unittest.TestSuite()
|
|
52
106
|
nested_suite.addTest(test_case1)
|
|
53
107
|
nested_suite.addTest(test_case2)
|
|
108
|
+
# Create the main TestSuite and add the nested suite to it
|
|
54
109
|
main_suite = unittest.TestSuite()
|
|
55
110
|
main_suite.addTest(nested_suite)
|
|
111
|
+
# Flatten the main suite using the method under test
|
|
56
112
|
flattened = unit_test._UnitTest__flattenTestSuite(main_suite)
|
|
113
|
+
# Assert that the flattened list contains both test cases
|
|
57
114
|
self.assertEqual(len(flattened), 2)
|
|
58
115
|
self.assertIn(test_case1, flattened)
|
|
59
116
|
self.assertIn(test_case2, flattened)
|
|
60
117
|
|
|
61
118
|
async def testMergeTestResults(self) -> None:
|
|
62
119
|
"""
|
|
63
|
-
Tests the `_mergeTestResults` method of the `UnitTest` class
|
|
120
|
+
Tests the `_mergeTestResults` method of the `UnitTest` class to ensure it correctly aggregates
|
|
121
|
+
the results from an individual `TestResult` into a combined `TestResult`.
|
|
122
|
+
|
|
123
|
+
Parameters
|
|
124
|
+
----------
|
|
125
|
+
self : TestTestingUnit
|
|
126
|
+
The test case instance.
|
|
127
|
+
|
|
128
|
+
Returns
|
|
129
|
+
-------
|
|
130
|
+
None
|
|
131
|
+
This method does not return any value.
|
|
132
|
+
|
|
133
|
+
Notes
|
|
134
|
+
-----
|
|
135
|
+
- Verifies that the number of tests run, failures, and errors are correctly merged.
|
|
136
|
+
- Ensures that skipped, expected failures, and unexpected successes are also handled.
|
|
137
|
+
- The method under test does not return a value; it modifies the `combined` result in place.
|
|
64
138
|
"""
|
|
65
139
|
unit_test = UnitTest()
|
|
140
|
+
# Create a combined TestResult to aggregate results into
|
|
66
141
|
combined = unittest.TestResult()
|
|
142
|
+
# Create an individual TestResult with sample data
|
|
67
143
|
individual = unittest.TestResult()
|
|
68
144
|
individual.testsRun = 2
|
|
69
145
|
individual.failures = [('test1', 'failure')]
|
|
@@ -71,40 +147,103 @@ class TestTestingUnit(AsyncTestCase):
|
|
|
71
147
|
individual.skipped = []
|
|
72
148
|
individual.expectedFailures = []
|
|
73
149
|
individual.unexpectedSuccesses = []
|
|
150
|
+
# Merge the individual results into the combined result
|
|
74
151
|
unit_test._UnitTest__mergeTestResults(combined, individual)
|
|
152
|
+
# Assert that the combined result reflects the merged data
|
|
75
153
|
self.assertEqual(combined.testsRun, 2)
|
|
76
154
|
self.assertEqual(len(combined.failures), 1)
|
|
77
155
|
self.assertEqual(len(combined.errors), 1)
|
|
78
156
|
|
|
79
157
|
async def testClearTests(self) -> None:
|
|
80
158
|
"""
|
|
81
|
-
Tests the `clearTests` method of the `UnitTest` class to
|
|
159
|
+
Tests the `clearTests` method of the `UnitTest` class to verify that it correctly resets the test suite,
|
|
160
|
+
removing all previously added test cases and leaving the suite empty.
|
|
161
|
+
|
|
162
|
+
Parameters
|
|
163
|
+
----------
|
|
164
|
+
self : TestTestingUnit
|
|
165
|
+
The test case instance.
|
|
166
|
+
|
|
167
|
+
Returns
|
|
168
|
+
-------
|
|
169
|
+
None
|
|
170
|
+
This method does not return any value.
|
|
171
|
+
|
|
172
|
+
Notes
|
|
173
|
+
-----
|
|
174
|
+
- Ensures that after calling `clearTests`, the internal test suite contains no test cases.
|
|
175
|
+
- Validates that the suite is properly cleared regardless of its previous state.
|
|
82
176
|
"""
|
|
83
177
|
unit_test = UnitTest()
|
|
178
|
+
# Add a mock test case to the suite
|
|
84
179
|
mock_test = MagicMock()
|
|
85
180
|
unit_test._UnitTest__suite.addTest(mock_test)
|
|
181
|
+
# Clear all tests from the suite
|
|
86
182
|
unit_test.clearTests()
|
|
183
|
+
# Assert that the suite is now empty
|
|
87
184
|
self.assertEqual(len(unit_test._UnitTest__suite._tests), 0)
|
|
88
185
|
|
|
89
186
|
async def testGetTestNames(self) -> None:
|
|
90
187
|
"""
|
|
91
|
-
Tests the `getTestNames` method of the `UnitTest` class
|
|
188
|
+
Tests the `getTestNames` method of the `UnitTest` class to ensure it accurately retrieves
|
|
189
|
+
the identifiers of all test cases present in the internal test suite.
|
|
190
|
+
|
|
191
|
+
Parameters
|
|
192
|
+
----------
|
|
193
|
+
self : TestTestingUnit
|
|
194
|
+
The test case instance.
|
|
195
|
+
|
|
196
|
+
Returns
|
|
197
|
+
-------
|
|
198
|
+
None
|
|
199
|
+
This method does not return any value.
|
|
200
|
+
|
|
201
|
+
Notes
|
|
202
|
+
-----
|
|
203
|
+
- Verifies that the method returns a list of test identifiers corresponding to each test case in the suite.
|
|
204
|
+
- Ensures that the returned list contains the expected test IDs as provided by the test case's `id()` method.
|
|
205
|
+
- The expected return value of `getTestNames` is a list of strings, where each string is the identifier of a test case.
|
|
92
206
|
"""
|
|
93
207
|
unit_test = UnitTest()
|
|
208
|
+
# Create a mock test case and set its id() method to return a specific identifier
|
|
94
209
|
mock_test = MagicMock()
|
|
95
210
|
mock_test.id.return_value = 'test_id'
|
|
211
|
+
# Add the mock test case to the UnitTest's internal suite
|
|
96
212
|
unit_test._UnitTest__suite.addTest(mock_test)
|
|
213
|
+
# Retrieve the list of test names using the method under test
|
|
97
214
|
names = unit_test.getTestNames()
|
|
215
|
+
# Assert that the returned list contains the expected test identifier
|
|
98
216
|
self.assertEqual(names, ['test_id'])
|
|
99
217
|
|
|
100
218
|
async def testGetTestCount(self) -> None:
|
|
101
219
|
"""
|
|
102
|
-
Tests the `getTestCount` method of the `UnitTest` class
|
|
220
|
+
Tests the `getTestCount` method of the `UnitTest` class to ensure it accurately returns
|
|
221
|
+
the total number of test cases present in the internal test suite.
|
|
222
|
+
|
|
223
|
+
Parameters
|
|
224
|
+
----------
|
|
225
|
+
self : TestTestingUnit
|
|
226
|
+
The test case instance.
|
|
227
|
+
|
|
228
|
+
Returns
|
|
229
|
+
-------
|
|
230
|
+
None
|
|
231
|
+
This method does not return any value.
|
|
232
|
+
|
|
233
|
+
Notes
|
|
234
|
+
-----
|
|
235
|
+
- Verifies that the method returns the correct count of test cases added to the suite.
|
|
236
|
+
- Ensures that the count matches the number of test cases present in the suite at the time of invocation.
|
|
237
|
+
- The expected return value of `getTestCount` is an integer representing the number of test cases in the suite.
|
|
103
238
|
"""
|
|
104
239
|
unit_test = UnitTest()
|
|
240
|
+
# Create two mock test cases
|
|
105
241
|
mock_test1 = MagicMock()
|
|
106
242
|
mock_test2 = MagicMock()
|
|
243
|
+
# Add the mock test cases to the UnitTest's internal suite
|
|
107
244
|
unit_test._UnitTest__suite.addTest(mock_test1)
|
|
108
245
|
unit_test._UnitTest__suite.addTest(mock_test2)
|
|
246
|
+
# Retrieve the count of test cases using the method under test
|
|
109
247
|
count = unit_test.getTestCount()
|
|
110
|
-
|
|
248
|
+
# Assert that the returned count matches the number of test cases added
|
|
249
|
+
self.assertEqual(count, 2)
|
|
File without changes
|
|
@@ -0,0 +1,449 @@
|
|
|
1
|
+
from orionis.test.cases.asynchronous import AsyncTestCase
|
|
2
|
+
from orionis.support.facades.workers import Workers
|
|
3
|
+
from orionis.test.exceptions import OrionisTestValueError
|
|
4
|
+
from orionis.test.validators import *
|
|
5
|
+
|
|
6
|
+
class TestTestingDumper(AsyncTestCase):
|
|
7
|
+
|
|
8
|
+
async def testValidWorkers(self) -> None:
|
|
9
|
+
"""
|
|
10
|
+
Tests the ValidWorkers validator for correct validation of worker counts.
|
|
11
|
+
|
|
12
|
+
This method verifies that ValidWorkers accepts valid worker counts within the allowed range,
|
|
13
|
+
and raises OrionisTestValueError for invalid values such as zero, negative numbers, values
|
|
14
|
+
exceeding the maximum allowed, and non-integer types.
|
|
15
|
+
|
|
16
|
+
Returns
|
|
17
|
+
-------
|
|
18
|
+
None
|
|
19
|
+
This method does not return any value. It asserts expected behavior using test assertions.
|
|
20
|
+
"""
|
|
21
|
+
# Get the maximum allowed number of workers from the Workers facade
|
|
22
|
+
max_allowed = Workers.calculate()
|
|
23
|
+
|
|
24
|
+
# Valid cases: should return the input value if within allowed range
|
|
25
|
+
self.assertEqual(ValidWorkers(1), 1)
|
|
26
|
+
self.assertEqual(ValidWorkers(max_allowed), max_allowed)
|
|
27
|
+
|
|
28
|
+
# Invalid cases: should raise OrionisTestValueError for out-of-range or wrong type
|
|
29
|
+
with self.assertRaises(OrionisTestValueError):
|
|
30
|
+
ValidWorkers(0) # Zero is not allowed
|
|
31
|
+
with self.assertRaises(OrionisTestValueError):
|
|
32
|
+
ValidWorkers(max_allowed + 1) # Exceeds maximum allowed
|
|
33
|
+
with self.assertRaises(OrionisTestValueError):
|
|
34
|
+
ValidWorkers(-5) # Negative value is not allowed
|
|
35
|
+
with self.assertRaises(OrionisTestValueError):
|
|
36
|
+
ValidWorkers("not_an_int") # Non-integer type is not allowed
|
|
37
|
+
|
|
38
|
+
async def testValidBasePath(self) -> None:
|
|
39
|
+
"""
|
|
40
|
+
Tests the ValidBasePath validator for correct validation of base path inputs.
|
|
41
|
+
|
|
42
|
+
This method checks that ValidBasePath accepts valid path strings and Path objects,
|
|
43
|
+
returning a pathlib.Path instance. It also verifies that invalid inputs such as empty strings,
|
|
44
|
+
None, and non-path types raise OrionisTestValueError.
|
|
45
|
+
|
|
46
|
+
Parameters
|
|
47
|
+
----------
|
|
48
|
+
None
|
|
49
|
+
|
|
50
|
+
Returns
|
|
51
|
+
-------
|
|
52
|
+
None
|
|
53
|
+
This method does not return any value. It asserts expected behavior using test assertions.
|
|
54
|
+
"""
|
|
55
|
+
from orionis.test.validators import ValidBasePath
|
|
56
|
+
from pathlib import Path
|
|
57
|
+
|
|
58
|
+
# Valid cases: should return a Path instance for valid string or Path input
|
|
59
|
+
self.assertIsInstance(ValidBasePath("/tmp"), Path)
|
|
60
|
+
self.assertIsInstance(ValidBasePath(Path("/tmp")), Path)
|
|
61
|
+
|
|
62
|
+
# Invalid cases: should raise OrionisTestValueError for empty string, None, or non-path type
|
|
63
|
+
with self.assertRaises(OrionisTestValueError):
|
|
64
|
+
ValidBasePath("")
|
|
65
|
+
with self.assertRaises(OrionisTestValueError):
|
|
66
|
+
ValidBasePath(None)
|
|
67
|
+
with self.assertRaises(OrionisTestValueError):
|
|
68
|
+
ValidBasePath(123)
|
|
69
|
+
|
|
70
|
+
async def testValidExecutionMode(self) -> None:
|
|
71
|
+
"""
|
|
72
|
+
Tests the ValidExecutionMode validator for correct validation of execution mode inputs.
|
|
73
|
+
|
|
74
|
+
This method verifies that ValidExecutionMode accepts valid execution mode strings and enum values,
|
|
75
|
+
returning the corresponding string value. It also checks that invalid inputs such as unknown strings
|
|
76
|
+
and non-enum types raise OrionisTestValueError.
|
|
77
|
+
|
|
78
|
+
Parameters
|
|
79
|
+
----------
|
|
80
|
+
None
|
|
81
|
+
|
|
82
|
+
Returns
|
|
83
|
+
-------
|
|
84
|
+
None
|
|
85
|
+
This method does not return any value. It asserts expected behavior using test assertions.
|
|
86
|
+
"""
|
|
87
|
+
from orionis.test.validators import ValidExecutionMode
|
|
88
|
+
from orionis.foundation.config.testing.enums.mode import ExecutionMode
|
|
89
|
+
|
|
90
|
+
# Valid cases: should return the string value for valid mode string or enum input
|
|
91
|
+
self.assertEqual(ValidExecutionMode("parallel"), ExecutionMode.PARALLEL.value)
|
|
92
|
+
self.assertEqual(ValidExecutionMode(ExecutionMode.SEQUENTIAL), ExecutionMode.SEQUENTIAL.value)
|
|
93
|
+
|
|
94
|
+
# Invalid cases: should raise OrionisTestValueError for unknown string or non-enum type
|
|
95
|
+
with self.assertRaises(OrionisTestValueError):
|
|
96
|
+
ValidExecutionMode("INVALID") # Unknown execution mode string
|
|
97
|
+
with self.assertRaises(OrionisTestValueError):
|
|
98
|
+
ValidExecutionMode(123) # Non-enum type
|
|
99
|
+
|
|
100
|
+
async def testValidFailFast(self) -> None:
|
|
101
|
+
"""
|
|
102
|
+
Tests the ValidFailFast validator for correct validation of fail-fast configuration.
|
|
103
|
+
|
|
104
|
+
This method verifies that ValidFailFast accepts valid boolean inputs, returning the corresponding
|
|
105
|
+
boolean value. It also checks that invalid inputs, such as non-boolean types or None, raise
|
|
106
|
+
OrionisTestValueError.
|
|
107
|
+
|
|
108
|
+
Parameters
|
|
109
|
+
----------
|
|
110
|
+
None
|
|
111
|
+
|
|
112
|
+
Returns
|
|
113
|
+
-------
|
|
114
|
+
None
|
|
115
|
+
This method does not return any value. It asserts expected behavior using test assertions.
|
|
116
|
+
"""
|
|
117
|
+
from orionis.test.validators import ValidFailFast
|
|
118
|
+
|
|
119
|
+
# Valid cases: should return True or False for boolean input
|
|
120
|
+
self.assertTrue(ValidFailFast(True))
|
|
121
|
+
self.assertFalse(ValidFailFast(False))
|
|
122
|
+
|
|
123
|
+
# Invalid cases: should raise OrionisTestValueError for non-boolean or None input
|
|
124
|
+
with self.assertRaises(OrionisTestValueError):
|
|
125
|
+
ValidFailFast("not_bool")
|
|
126
|
+
with self.assertRaises(OrionisTestValueError):
|
|
127
|
+
ValidFailFast(None)
|
|
128
|
+
|
|
129
|
+
async def testValidFolderPath(self) -> None:
|
|
130
|
+
"""
|
|
131
|
+
Tests the ValidFolderPath validator for correct validation of folder path inputs.
|
|
132
|
+
|
|
133
|
+
This method checks that ValidFolderPath accepts valid folder path strings, including those
|
|
134
|
+
with leading or trailing whitespace, and returns the normalized string path. It also verifies
|
|
135
|
+
that invalid inputs such as empty strings, None, or non-string types raise OrionisTestValueError.
|
|
136
|
+
|
|
137
|
+
Returns
|
|
138
|
+
-------
|
|
139
|
+
None
|
|
140
|
+
This method does not return any value. It asserts expected behavior using test assertions.
|
|
141
|
+
"""
|
|
142
|
+
from orionis.test.validators import ValidFolderPath
|
|
143
|
+
|
|
144
|
+
# Valid cases: should return the normalized string path for valid input
|
|
145
|
+
self.assertEqual(ValidFolderPath("/tmp"), "/tmp")
|
|
146
|
+
self.assertEqual(ValidFolderPath(" /tmp "), "/tmp")
|
|
147
|
+
|
|
148
|
+
# Invalid cases: should raise OrionisTestValueError for empty string, None, or non-string type
|
|
149
|
+
with self.assertRaises(OrionisTestValueError):
|
|
150
|
+
ValidFolderPath("")
|
|
151
|
+
with self.assertRaises(OrionisTestValueError):
|
|
152
|
+
ValidFolderPath(None)
|
|
153
|
+
with self.assertRaises(OrionisTestValueError):
|
|
154
|
+
ValidFolderPath(123)
|
|
155
|
+
|
|
156
|
+
async def testValidModuleName(self) -> None:
|
|
157
|
+
"""
|
|
158
|
+
Tests the ValidModuleName validator for correct validation of module name inputs.
|
|
159
|
+
|
|
160
|
+
This method verifies that ValidModuleName accepts valid non-empty string module names,
|
|
161
|
+
returning the normalized string value. It also checks that invalid inputs such as empty strings,
|
|
162
|
+
None, or non-string types raise OrionisTestValueError.
|
|
163
|
+
|
|
164
|
+
Parameters
|
|
165
|
+
----------
|
|
166
|
+
None
|
|
167
|
+
|
|
168
|
+
Returns
|
|
169
|
+
-------
|
|
170
|
+
None
|
|
171
|
+
This method does not return any value. It asserts expected behavior using test assertions.
|
|
172
|
+
"""
|
|
173
|
+
from orionis.test.validators import ValidModuleName
|
|
174
|
+
|
|
175
|
+
# Valid case: should return the normalized string for a valid module name
|
|
176
|
+
self.assertEqual(ValidModuleName("mod"), "mod")
|
|
177
|
+
|
|
178
|
+
# Invalid cases: should raise OrionisTestValueError for empty string, None, or non-string type
|
|
179
|
+
with self.assertRaises(OrionisTestValueError):
|
|
180
|
+
ValidModuleName("")
|
|
181
|
+
with self.assertRaises(OrionisTestValueError):
|
|
182
|
+
ValidModuleName(None)
|
|
183
|
+
with self.assertRaises(OrionisTestValueError):
|
|
184
|
+
ValidModuleName(123)
|
|
185
|
+
|
|
186
|
+
async def testValidNamePattern(self) -> None:
|
|
187
|
+
"""
|
|
188
|
+
Tests the ValidNamePattern validator for correct validation of name pattern inputs.
|
|
189
|
+
|
|
190
|
+
This method verifies that ValidNamePattern accepts valid non-empty string patterns and None,
|
|
191
|
+
returning the normalized string pattern or None. It also checks that invalid inputs such as
|
|
192
|
+
empty strings or non-string types raise OrionisTestValueError.
|
|
193
|
+
|
|
194
|
+
Parameters
|
|
195
|
+
----------
|
|
196
|
+
None
|
|
197
|
+
|
|
198
|
+
Returns
|
|
199
|
+
-------
|
|
200
|
+
None
|
|
201
|
+
This method does not return any value. It asserts expected behavior using test assertions.
|
|
202
|
+
"""
|
|
203
|
+
from orionis.test.validators import ValidNamePattern
|
|
204
|
+
|
|
205
|
+
# Valid case: should return the normalized string for a valid pattern
|
|
206
|
+
self.assertEqual(ValidNamePattern("test_*"), "test_*")
|
|
207
|
+
|
|
208
|
+
# Valid case: should return None when input is None
|
|
209
|
+
self.assertIsNone(ValidNamePattern(None))
|
|
210
|
+
|
|
211
|
+
# Invalid cases: should raise OrionisTestValueError for empty string or non-string type
|
|
212
|
+
with self.assertRaises(OrionisTestValueError):
|
|
213
|
+
ValidNamePattern("")
|
|
214
|
+
with self.assertRaises(OrionisTestValueError):
|
|
215
|
+
ValidNamePattern(123)
|
|
216
|
+
|
|
217
|
+
async def testValidPattern(self) -> None:
|
|
218
|
+
"""
|
|
219
|
+
Tests the ValidPattern validator for correct validation of pattern string inputs.
|
|
220
|
+
|
|
221
|
+
This method verifies that ValidPattern accepts valid non-empty string patterns,
|
|
222
|
+
returning the normalized string value. It also checks that invalid inputs such as
|
|
223
|
+
empty strings, None, or non-string types raise OrionisTestValueError.
|
|
224
|
+
|
|
225
|
+
Returns
|
|
226
|
+
-------
|
|
227
|
+
None
|
|
228
|
+
This method does not return any value. It asserts expected behavior using test assertions.
|
|
229
|
+
"""
|
|
230
|
+
from orionis.test.validators import ValidPattern
|
|
231
|
+
|
|
232
|
+
# Valid case: should return the normalized string for a valid pattern
|
|
233
|
+
self.assertEqual(ValidPattern("abc"), "abc")
|
|
234
|
+
|
|
235
|
+
# Invalid cases: should raise OrionisTestValueError for empty string, None, or non-string type
|
|
236
|
+
with self.assertRaises(OrionisTestValueError):
|
|
237
|
+
ValidPattern("")
|
|
238
|
+
with self.assertRaises(OrionisTestValueError):
|
|
239
|
+
ValidPattern(None)
|
|
240
|
+
with self.assertRaises(OrionisTestValueError):
|
|
241
|
+
ValidPattern(123)
|
|
242
|
+
|
|
243
|
+
async def testValidPersistentDriver(self) -> None:
|
|
244
|
+
"""
|
|
245
|
+
Tests the ValidPersistentDriver validator for correct validation of persistent driver inputs.
|
|
246
|
+
|
|
247
|
+
This method verifies that ValidPersistentDriver accepts valid persistent driver names as strings
|
|
248
|
+
and enum values, returning the corresponding normalized string value. It also checks that invalid
|
|
249
|
+
inputs, such as unknown driver names or non-enum types, raise OrionisTestValueError.
|
|
250
|
+
|
|
251
|
+
Parameters
|
|
252
|
+
----------
|
|
253
|
+
None
|
|
254
|
+
|
|
255
|
+
Returns
|
|
256
|
+
-------
|
|
257
|
+
None
|
|
258
|
+
This method does not return any value. It asserts expected behavior using test assertions.
|
|
259
|
+
"""
|
|
260
|
+
from orionis.test.validators import ValidPersistentDriver
|
|
261
|
+
from orionis.foundation.config.testing.enums.drivers import PersistentDrivers
|
|
262
|
+
|
|
263
|
+
# Valid cases: should return the normalized string for valid driver name or enum input
|
|
264
|
+
self.assertEqual(ValidPersistentDriver("sqlite"), "sqlite")
|
|
265
|
+
self.assertEqual(ValidPersistentDriver(PersistentDrivers.SQLITE), "sqlite")
|
|
266
|
+
|
|
267
|
+
# Invalid cases: should raise OrionisTestValueError for unknown driver name or non-enum type
|
|
268
|
+
with self.assertRaises(OrionisTestValueError):
|
|
269
|
+
ValidPersistentDriver("invalid")
|
|
270
|
+
with self.assertRaises(OrionisTestValueError):
|
|
271
|
+
ValidPersistentDriver(123)
|
|
272
|
+
|
|
273
|
+
async def testValidPersistent(self) -> None:
|
|
274
|
+
"""
|
|
275
|
+
Tests the ValidPersistent validator for correct validation of persistent configuration values.
|
|
276
|
+
|
|
277
|
+
This method verifies that ValidPersistent accepts valid boolean inputs, returning the corresponding
|
|
278
|
+
boolean value. It also checks that invalid inputs, such as non-boolean types or None, raise
|
|
279
|
+
OrionisTestValueError.
|
|
280
|
+
|
|
281
|
+
Parameters
|
|
282
|
+
----------
|
|
283
|
+
None
|
|
284
|
+
|
|
285
|
+
Returns
|
|
286
|
+
-------
|
|
287
|
+
None
|
|
288
|
+
This method does not return any value. It asserts expected behavior using test assertions.
|
|
289
|
+
"""
|
|
290
|
+
from orionis.test.validators import ValidPersistent
|
|
291
|
+
|
|
292
|
+
# Valid cases: should return True or False for boolean input
|
|
293
|
+
self.assertTrue(ValidPersistent(True))
|
|
294
|
+
self.assertFalse(ValidPersistent(False))
|
|
295
|
+
|
|
296
|
+
# Invalid cases: should raise OrionisTestValueError for non-boolean or None input
|
|
297
|
+
with self.assertRaises(OrionisTestValueError):
|
|
298
|
+
ValidPersistent("not_bool")
|
|
299
|
+
with self.assertRaises(OrionisTestValueError):
|
|
300
|
+
ValidPersistent(None)
|
|
301
|
+
|
|
302
|
+
async def testValidPrintResult(self) -> None:
|
|
303
|
+
"""
|
|
304
|
+
Tests the ValidPrintResult validator for correct validation of print result configuration.
|
|
305
|
+
|
|
306
|
+
This method verifies that ValidPrintResult accepts valid boolean inputs, returning the corresponding
|
|
307
|
+
boolean value. It also checks that invalid inputs, such as non-boolean types or None, raise
|
|
308
|
+
OrionisTestValueError.
|
|
309
|
+
|
|
310
|
+
Parameters
|
|
311
|
+
----------
|
|
312
|
+
None
|
|
313
|
+
|
|
314
|
+
Returns
|
|
315
|
+
-------
|
|
316
|
+
None
|
|
317
|
+
This method does not return any value. It asserts expected behavior using test assertions.
|
|
318
|
+
"""
|
|
319
|
+
from orionis.test.validators import ValidPrintResult
|
|
320
|
+
|
|
321
|
+
# Valid cases: should return True or False for boolean input
|
|
322
|
+
self.assertTrue(ValidPrintResult(True))
|
|
323
|
+
self.assertFalse(ValidPrintResult(False))
|
|
324
|
+
|
|
325
|
+
# Invalid cases: should raise OrionisTestValueError for non-boolean or None input
|
|
326
|
+
with self.assertRaises(OrionisTestValueError):
|
|
327
|
+
ValidPrintResult("not_bool")
|
|
328
|
+
with self.assertRaises(OrionisTestValueError):
|
|
329
|
+
ValidPrintResult(None)
|
|
330
|
+
|
|
331
|
+
async def testValidTags(self) -> None:
|
|
332
|
+
"""
|
|
333
|
+
Tests the ValidTags validator for correct validation of tag list inputs.
|
|
334
|
+
|
|
335
|
+
This method verifies that ValidTags accepts a list of non-empty string tags, normalizes whitespace,
|
|
336
|
+
and returns a list of cleaned tag strings. It also checks that None is accepted and returns None.
|
|
337
|
+
Invalid cases, such as empty lists, lists containing empty strings or non-string types, and non-list
|
|
338
|
+
inputs, should raise OrionisTestValueError.
|
|
339
|
+
|
|
340
|
+
Returns
|
|
341
|
+
-------
|
|
342
|
+
None
|
|
343
|
+
This method does not return any value. It asserts expected behavior using test assertions.
|
|
344
|
+
"""
|
|
345
|
+
from orionis.test.validators import ValidTags
|
|
346
|
+
|
|
347
|
+
# Valid case: should return a list of normalized tag strings
|
|
348
|
+
self.assertEqual(ValidTags(["a", "b ", " c"]), ["a", "b", "c"])
|
|
349
|
+
|
|
350
|
+
# Valid case: should return None when input is None
|
|
351
|
+
self.assertIsNone(ValidTags(None))
|
|
352
|
+
|
|
353
|
+
# Invalid case: should raise OrionisTestValueError for empty list
|
|
354
|
+
with self.assertRaises(OrionisTestValueError):
|
|
355
|
+
ValidTags([])
|
|
356
|
+
|
|
357
|
+
# Invalid case: should raise OrionisTestValueError for list containing empty string
|
|
358
|
+
with self.assertRaises(OrionisTestValueError):
|
|
359
|
+
ValidTags([""])
|
|
360
|
+
|
|
361
|
+
# Invalid case: should raise OrionisTestValueError for list containing non-string type
|
|
362
|
+
with self.assertRaises(OrionisTestValueError):
|
|
363
|
+
ValidTags([123])
|
|
364
|
+
|
|
365
|
+
# Invalid case: should raise OrionisTestValueError for non-list input
|
|
366
|
+
with self.assertRaises(OrionisTestValueError):
|
|
367
|
+
ValidTags("not_a_list")
|
|
368
|
+
|
|
369
|
+
async def testValidThrowException(self) -> None:
|
|
370
|
+
"""
|
|
371
|
+
Tests the ValidThrowException validator for correct validation of throw exception configuration.
|
|
372
|
+
|
|
373
|
+
This method verifies that ValidThrowException accepts valid boolean inputs, returning the corresponding
|
|
374
|
+
boolean value. It also checks that invalid inputs, such as non-boolean types or None, raise
|
|
375
|
+
OrionisTestValueError.
|
|
376
|
+
|
|
377
|
+
Parameters
|
|
378
|
+
----------
|
|
379
|
+
None
|
|
380
|
+
|
|
381
|
+
Returns
|
|
382
|
+
-------
|
|
383
|
+
None
|
|
384
|
+
This method does not return any value. It asserts expected behavior using test assertions.
|
|
385
|
+
"""
|
|
386
|
+
from orionis.test.validators import ValidThrowException
|
|
387
|
+
|
|
388
|
+
# Valid cases: should return True or False for boolean input
|
|
389
|
+
self.assertTrue(ValidThrowException(True))
|
|
390
|
+
self.assertFalse(ValidThrowException(False))
|
|
391
|
+
|
|
392
|
+
# Invalid cases: should raise OrionisTestValueError for non-boolean or None input
|
|
393
|
+
with self.assertRaises(OrionisTestValueError):
|
|
394
|
+
ValidThrowException("not_bool")
|
|
395
|
+
with self.assertRaises(OrionisTestValueError):
|
|
396
|
+
ValidThrowException(None)
|
|
397
|
+
|
|
398
|
+
async def testValidVerbosity(self) -> None:
|
|
399
|
+
"""
|
|
400
|
+
Tests the ValidVerbosity validator for correct validation of verbosity mode inputs.
|
|
401
|
+
|
|
402
|
+
This method verifies that ValidVerbosity accepts valid verbosity mode enum values and their corresponding
|
|
403
|
+
integer values, returning the normalized integer value. It also checks that invalid inputs such as
|
|
404
|
+
negative values, unknown integers, or non-integer types raise OrionisTestValueError.
|
|
405
|
+
|
|
406
|
+
Returns
|
|
407
|
+
-------
|
|
408
|
+
None
|
|
409
|
+
This method does not return any value. It asserts expected behavior using test assertions.
|
|
410
|
+
"""
|
|
411
|
+
from orionis.test.validators import ValidVerbosity
|
|
412
|
+
from orionis.foundation.config.testing.enums.verbosity import VerbosityMode
|
|
413
|
+
|
|
414
|
+
# Valid cases: should return the integer value for valid enum or integer input
|
|
415
|
+
self.assertEqual(ValidVerbosity(VerbosityMode.MINIMAL), VerbosityMode.MINIMAL.value)
|
|
416
|
+
self.assertEqual(ValidVerbosity(VerbosityMode.DETAILED.value), VerbosityMode.DETAILED.value)
|
|
417
|
+
|
|
418
|
+
# Invalid cases: should raise OrionisTestValueError for negative, unknown, or non-integer input
|
|
419
|
+
with self.assertRaises(OrionisTestValueError):
|
|
420
|
+
ValidVerbosity(-1)
|
|
421
|
+
with self.assertRaises(OrionisTestValueError):
|
|
422
|
+
ValidVerbosity("not_int")
|
|
423
|
+
with self.assertRaises(OrionisTestValueError):
|
|
424
|
+
ValidVerbosity(999)
|
|
425
|
+
|
|
426
|
+
async def testValidWebReport(self) -> None:
|
|
427
|
+
"""
|
|
428
|
+
Tests the ValidWebReport validator for correct validation of web report configuration.
|
|
429
|
+
|
|
430
|
+
This method verifies that ValidWebReport accepts valid boolean inputs, returning the corresponding
|
|
431
|
+
boolean value. It also checks that invalid inputs, such as non-boolean types or None, raise
|
|
432
|
+
OrionisTestValueError.
|
|
433
|
+
|
|
434
|
+
Returns
|
|
435
|
+
-------
|
|
436
|
+
None
|
|
437
|
+
This method does not return any value. It asserts expected behavior using test assertions.
|
|
438
|
+
"""
|
|
439
|
+
from orionis.test.validators import ValidWebReport
|
|
440
|
+
|
|
441
|
+
# Valid cases: should return True or False for boolean input
|
|
442
|
+
self.assertTrue(ValidWebReport(True))
|
|
443
|
+
self.assertFalse(ValidWebReport(False))
|
|
444
|
+
|
|
445
|
+
# Invalid cases: should raise OrionisTestValueError for non-boolean or None input
|
|
446
|
+
with self.assertRaises(OrionisTestValueError):
|
|
447
|
+
ValidWebReport("not_bool")
|
|
448
|
+
with self.assertRaises(OrionisTestValueError):
|
|
449
|
+
ValidWebReport(None)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|