orionis 0.413.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.
Files changed (90) hide show
  1. orionis/metadata/framework.py +1 -1
  2. orionis/support/entities/base.py +45 -26
  3. orionis/support/facades/console.py +8 -2
  4. orionis/support/facades/dumper.py +8 -2
  5. orionis/support/facades/logger.py +9 -2
  6. orionis/support/facades/path_resolver.py +9 -2
  7. orionis/support/facades/progress_bar.py +9 -2
  8. orionis/support/facades/testing.py +9 -2
  9. orionis/support/facades/workers.py +9 -2
  10. orionis/test/core/unit_test.py +26 -10
  11. orionis/test/output/dumper.py +1 -1
  12. {orionis-0.413.0.dist-info → orionis-0.415.0.dist-info}/METADATA +1 -1
  13. {orionis-0.413.0.dist-info → orionis-0.415.0.dist-info}/RECORD +88 -76
  14. orionis-0.415.0.dist-info/top_level.txt +4 -0
  15. tests/container/entities/test_binding.py +1 -1
  16. tests/container/test_thread_safety.py +0 -1
  17. tests/support/entities/__init__.py +0 -0
  18. tests/support/entities/mock_dataclass.py +34 -0
  19. tests/support/entities/test_base.py +72 -0
  20. tests/testing/cases/__init__.py +0 -0
  21. tests/testing/cases/test_testing_asynchronous.py +63 -0
  22. tests/testing/cases/test_testing_synchronous.py +59 -0
  23. tests/testing/entities/__init__.py +0 -0
  24. tests/testing/entities/test_testing_result.py +185 -0
  25. tests/testing/enums/__init__.py +0 -0
  26. tests/testing/enums/test_testing_status.py +68 -0
  27. tests/testing/output/__init__.py +0 -0
  28. tests/testing/output/test_testing_dumper.py +32 -0
  29. tests/testing/output/test_testing_printer.py +42 -0
  30. tests/testing/test_testing_unit.py +110 -209
  31. orionis-0.413.0.dist-info/top_level.txt +0 -2
  32. tests/testing/test_testing_result.py +0 -131
  33. {tests/foundation → environment}/__init__.py +0 -0
  34. {tests/services/environment → environment}/test_services_environment.py +0 -0
  35. {tests/foundation/config → foundation}/__init__.py +0 -0
  36. {tests/foundation/config/app → foundation/config}/__init__.py +0 -0
  37. {tests/foundation/config/auth → foundation/config/app}/__init__.py +0 -0
  38. {tests/foundation → foundation}/config/app/test_foundation_config_app.py +0 -0
  39. {tests/foundation/config/cache → foundation/config/auth}/__init__.py +0 -0
  40. {tests/foundation → foundation}/config/auth/test_foundation_config_auth.py +0 -0
  41. {tests/foundation/config/cors → foundation/config/cache}/__init__.py +0 -0
  42. {tests/foundation → foundation}/config/cache/test_foundation_config_cache.py +0 -0
  43. {tests/foundation → foundation}/config/cache/test_foundation_config_cache_file.py +0 -0
  44. {tests/foundation → foundation}/config/cache/test_foundation_config_cache_stores.py +0 -0
  45. {tests/foundation/config/database → foundation/config/cors}/__init__.py +0 -0
  46. {tests/foundation → foundation}/config/cors/test_foundation_config_cors.py +0 -0
  47. {tests/foundation/config/filesystems → foundation/config/database}/__init__.py +0 -0
  48. {tests/foundation → foundation}/config/database/test_foundation_config_database.py +0 -0
  49. {tests/foundation → foundation}/config/database/test_foundation_config_database_connections.py +0 -0
  50. {tests/foundation → foundation}/config/database/test_foundation_config_database_mysql.py +0 -0
  51. {tests/foundation → foundation}/config/database/test_foundation_config_database_oracle.py +0 -0
  52. {tests/foundation → foundation}/config/database/test_foundation_config_database_pgsql.py +0 -0
  53. {tests/foundation → foundation}/config/database/test_foundation_config_database_sqlite.py +0 -0
  54. {tests/foundation/config/logging → foundation/config/filesystems}/__init__.py +0 -0
  55. {tests/foundation → foundation}/config/filesystems/test_foundation_config_filesystems.py +0 -0
  56. {tests/foundation → foundation}/config/filesystems/test_foundation_config_filesystems_aws.py +0 -0
  57. {tests/foundation → foundation}/config/filesystems/test_foundation_config_filesystems_disks.py +0 -0
  58. {tests/foundation → foundation}/config/filesystems/test_foundation_config_filesystems_local.py +0 -0
  59. {tests/foundation → foundation}/config/filesystems/test_foundation_config_filesystems_public.py +0 -0
  60. {tests/foundation/config/mail → foundation/config/logging}/__init__.py +0 -0
  61. {tests/foundation → foundation}/config/logging/test_foundation_config_logging.py +0 -0
  62. {tests/foundation → foundation}/config/logging/test_foundation_config_logging_channels.py +0 -0
  63. {tests/foundation → foundation}/config/logging/test_foundation_config_logging_chunked.py +0 -0
  64. {tests/foundation → foundation}/config/logging/test_foundation_config_logging_daily.py +0 -0
  65. {tests/foundation → foundation}/config/logging/test_foundation_config_logging_hourly.py +0 -0
  66. {tests/foundation → foundation}/config/logging/test_foundation_config_logging_monthly.py +0 -0
  67. {tests/foundation → foundation}/config/logging/test_foundation_config_logging_stack.py +0 -0
  68. {tests/foundation → foundation}/config/logging/test_foundation_config_logging_weekly.py +0 -0
  69. {tests/foundation/config/queue → foundation/config/mail}/__init__.py +0 -0
  70. {tests/foundation → foundation}/config/mail/test_foundation_config_mail.py +0 -0
  71. {tests/foundation → foundation}/config/mail/test_foundation_config_mail_file.py +0 -0
  72. {tests/foundation → foundation}/config/mail/test_foundation_config_mail_mailers.py +0 -0
  73. {tests/foundation → foundation}/config/mail/test_foundation_config_mail_smtp.py +0 -0
  74. {tests/foundation/config/root → foundation/config/queue}/__init__.py +0 -0
  75. {tests/foundation → foundation}/config/queue/test_foundation_config_queue.py +0 -0
  76. {tests/foundation → foundation}/config/queue/test_foundation_config_queue_brokers.py +0 -0
  77. {tests/foundation → foundation}/config/queue/test_foundation_config_queue_database.py +0 -0
  78. {tests/foundation/config/session → foundation/config/root}/__init__.py +0 -0
  79. {tests/foundation → foundation}/config/root/test_foundation_config_root_paths.py +0 -0
  80. {tests/foundation/config/startup → foundation/config/session}/__init__.py +0 -0
  81. {tests/foundation → foundation}/config/session/test_foundation_config_session.py +0 -0
  82. {tests/foundation/config/testing → foundation/config/startup}/__init__.py +0 -0
  83. {tests/foundation → foundation}/config/startup/test_foundation_config_startup.py +0 -0
  84. {tests/foundation/exceptions → foundation/config/testing}/__init__.py +0 -0
  85. {tests/foundation → foundation}/config/testing/test_foundation_config_testing.py +0 -0
  86. {tests/services/environment → foundation/exceptions}/__init__.py +0 -0
  87. {tests/foundation → foundation}/exceptions/test_foundation_config_exceptions.py +0 -0
  88. {orionis-0.413.0.dist-info → orionis-0.415.0.dist-info}/WHEEL +0 -0
  89. {orionis-0.413.0.dist-info → orionis-0.415.0.dist-info}/licenses/LICENCE +0 -0
  90. {orionis-0.413.0.dist-info → orionis-0.415.0.dist-info}/zip-safe +0 -0
@@ -0,0 +1,185 @@
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 optional fields in a TestResult instance are set to None when not provided during initialization.
10
+
11
+ This test checks the default behavior for the following optional fields:
12
+ - error_message
13
+ - traceback
14
+ - class_name
15
+ - method
16
+ - module
17
+ - file_path
18
+
19
+ The method asserts that each of these fields is None after instantiating TestResult with only required arguments.
20
+
21
+ Parameters
22
+ ----------
23
+ self : TestTestingResult
24
+ The test case instance.
25
+
26
+ Returns
27
+ -------
28
+ None
29
+ This method does not return any value. It performs assertions to validate default field values.
30
+
31
+ Notes
32
+ -----
33
+ This test verifies that the TestResult dataclass correctly initializes optional fields to None when they are omitted.
34
+ """
35
+ # Create a TestResult instance with only required fields
36
+ result = TestResult(
37
+ id=1,
38
+ name="Sample Test",
39
+ status=TestStatus.PASSED,
40
+ execution_time=0.5
41
+ )
42
+ # Assert that all optional fields are set to None by default
43
+ self.assertIsNone(result.error_message)
44
+ self.assertIsNone(result.traceback)
45
+ self.assertIsNone(result.class_name)
46
+ self.assertIsNone(result.method)
47
+ self.assertIsNone(result.module)
48
+ self.assertIsNone(result.file_path)
49
+
50
+ async def testRequiredFields(self) -> None:
51
+ """
52
+ Validates that TestResult enforces the presence of all required fields during initialization.
53
+
54
+ This test attempts to instantiate TestResult without required fields and expects a TypeError to be raised.
55
+
56
+ Parameters
57
+ ----------
58
+ self : TestTestingResult
59
+ The test case instance.
60
+
61
+ Returns
62
+ -------
63
+ None
64
+ This method does not return any value. It performs assertions to validate required field enforcement.
65
+
66
+ Notes
67
+ -----
68
+ - Attempts to instantiate TestResult with no arguments.
69
+ - Attempts to instantiate TestResult missing the 'id' field.
70
+ - Expects a TypeError to be raised in both cases.
71
+ """
72
+ # Attempt to create TestResult with no arguments; should raise TypeError
73
+ with self.assertRaises(TypeError):
74
+ TestResult() # Missing all required fields
75
+
76
+ # Attempt to create TestResult missing the 'id' field; should raise TypeError
77
+ with self.assertRaises(TypeError):
78
+ TestResult(
79
+ name="Sample Test",
80
+ status=TestStatus.PASSED,
81
+ execution_time=0.5
82
+ )
83
+
84
+ async def testImmutable(self) -> None:
85
+ """
86
+ Tests the immutability of TestResult instances.
87
+
88
+ Ensures that TestResult, implemented as a frozen dataclass, does not allow modification of its attributes after instantiation.
89
+
90
+ Parameters
91
+ ----------
92
+ self : TestTestingResult
93
+ The test case instance.
94
+
95
+ Returns
96
+ -------
97
+ None
98
+ This method does not return any value. It performs assertions to validate immutability.
99
+
100
+ Raises
101
+ ------
102
+ Exception
103
+ If an attempt is made to modify an attribute of a frozen TestResult instance.
104
+
105
+ Notes
106
+ -----
107
+ Attempts to modify the 'name' attribute of a TestResult instance and expects an exception to be raised.
108
+ """
109
+ # Create a TestResult instance
110
+ result = TestResult(
111
+ id=1,
112
+ name="Sample Test",
113
+ status=TestStatus.PASSED,
114
+ execution_time=0.5
115
+ )
116
+ # Attempt to modify an attribute; should raise an exception due to immutability
117
+ with self.assertRaises(Exception):
118
+ result.name = "Modified Name"
119
+
120
+ async def testStatusValues(self) -> None:
121
+ """
122
+ Verifies that all possible values of the TestStatus enum can be assigned to the status field of a TestResult instance.
123
+
124
+ Iterates over each TestStatus value, assigns it to a TestResult, and asserts that the status is set correctly.
125
+
126
+ Parameters
127
+ ----------
128
+ self : TestTestingResult
129
+ The test case instance.
130
+
131
+ Returns
132
+ -------
133
+ None
134
+ This method does not return any value. It performs assertions to validate status assignment.
135
+
136
+ Notes
137
+ -----
138
+ This test ensures that the status field in TestResult supports all enum values defined in TestStatus.
139
+ """
140
+ # Iterate through all possible TestStatus values
141
+ for status in TestStatus:
142
+ # Create a TestResult instance with the current status
143
+ result = TestResult(
144
+ id=1,
145
+ name="Status Test",
146
+ status=status,
147
+ execution_time=0.1
148
+ )
149
+ # Assert that the status field matches the assigned value
150
+ self.assertEqual(result.status, status)
151
+
152
+ async def testErrorFields(self) -> None:
153
+ """
154
+ Verifies that the error_message and traceback fields are correctly stored in the TestResult object when provided.
155
+
156
+ This test initializes a TestResult with error_message and traceback values and asserts that they are set as expected.
157
+
158
+ Parameters
159
+ ----------
160
+ self : TestTestingResult
161
+ The test case instance.
162
+
163
+ Returns
164
+ -------
165
+ None
166
+ This method does not return any value. It performs assertions to validate error field assignment.
167
+
168
+ Notes
169
+ -----
170
+ This test ensures that error-related fields are properly assigned and retrievable from the TestResult instance.
171
+ """
172
+ error_msg = "Test failed"
173
+ traceback = "Traceback info"
174
+ # Create a TestResult instance with error fields
175
+ result = TestResult(
176
+ id=1,
177
+ name="Failing Test",
178
+ status=TestStatus.FAILED,
179
+ execution_time=0.2,
180
+ error_message=error_msg,
181
+ traceback=traceback
182
+ )
183
+ # Assert that error_message and traceback fields are set correctly
184
+ self.assertEqual(result.error_message, error_msg)
185
+ self.assertEqual(result.traceback, traceback)
File without changes
@@ -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
- # 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
+ 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,2 +0,0 @@
1
- orionis
2
- tests