orionis 0.546.0__py3-none-any.whl → 0.548.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 (160) hide show
  1. orionis/console/base/scheduler_event_listener.py +0 -17
  2. orionis/console/contracts/schedule_event_listener.py +0 -18
  3. orionis/foundation/config/app/entities/app.py +3 -2
  4. orionis/foundation/config/app/enums/ciphers.py +5 -19
  5. orionis/foundation/config/session/entities/session.py +2 -2
  6. orionis/metadata/framework.py +1 -1
  7. orionis/services/encrypter/encrypter.py +115 -0
  8. orionis/services/environment/dynamic/caster.py +35 -27
  9. orionis/services/environment/key/key_generator.py +32 -11
  10. {orionis-0.546.0.dist-info → orionis-0.548.0.dist-info}/METADATA +1 -1
  11. {orionis-0.546.0.dist-info → orionis-0.548.0.dist-info}/RECORD +14 -159
  12. {orionis-0.546.0.dist-info → orionis-0.548.0.dist-info}/top_level.txt +0 -1
  13. orionis-0.546.0.dist-info/zip-safe +0 -1
  14. tests/container/__init__.py +0 -0
  15. tests/container/context/__init__.py +0 -0
  16. tests/container/context/test_manager.py +0 -38
  17. tests/container/context/test_scope.py +0 -32
  18. tests/container/core/__init__.py +0 -0
  19. tests/container/core/test_advanced_async.py +0 -234
  20. tests/container/core/test_async_optimizations.py +0 -268
  21. tests/container/core/test_container.py +0 -453
  22. tests/container/core/test_singleton.py +0 -122
  23. tests/container/core/test_thread_safety.py +0 -90
  24. tests/container/entities/__init__.py +0 -0
  25. tests/container/entities/test_binding.py +0 -242
  26. tests/container/enums/__init__.py +0 -0
  27. tests/container/enums/test_lifetimes.py +0 -97
  28. tests/container/facades/__init__.py +0 -0
  29. tests/container/facades/test_facade.py +0 -78
  30. tests/container/mocks/__init__.py +0 -0
  31. tests/container/mocks/mock_advanced_async.py +0 -332
  32. tests/container/mocks/mock_async_optimizations.py +0 -407
  33. tests/container/mocks/mock_auto_resolution.py +0 -192
  34. tests/container/mocks/mock_complex_classes.py +0 -792
  35. tests/container/mocks/mock_simple_classes.py +0 -98
  36. tests/container/providers/__init__.py +0 -0
  37. tests/container/providers/test_providers.py +0 -55
  38. tests/container/validators/__init__.py +0 -0
  39. tests/container/validators/test_implements.py +0 -186
  40. tests/container/validators/test_is_abstract_class.py +0 -147
  41. tests/container/validators/test_is_callable.py +0 -102
  42. tests/container/validators/test_is_concrete_class.py +0 -160
  43. tests/container/validators/test_is_instance.py +0 -150
  44. tests/container/validators/test_is_not_subclass.py +0 -49
  45. tests/container/validators/test_is_subclass.py +0 -178
  46. tests/container/validators/test_is_valid_alias.py +0 -147
  47. tests/container/validators/test_lifetime.py +0 -106
  48. tests/example/__init__.py +0 -0
  49. tests/example/test_example.py +0 -725
  50. tests/foundation/__init__.py +0 -0
  51. tests/foundation/config/__init__.py +0 -0
  52. tests/foundation/config/app/__init__.py +0 -0
  53. tests/foundation/config/app/test_foundation_config_app.py +0 -262
  54. tests/foundation/config/auth/__init__.py +0 -0
  55. tests/foundation/config/auth/test_foundation_config_auth.py +0 -29
  56. tests/foundation/config/cache/__init__.py +0 -0
  57. tests/foundation/config/cache/test_foundation_config_cache.py +0 -143
  58. tests/foundation/config/cache/test_foundation_config_cache_file.py +0 -126
  59. tests/foundation/config/cache/test_foundation_config_cache_stores.py +0 -156
  60. tests/foundation/config/cors/__init__.py +0 -0
  61. tests/foundation/config/cors/test_foundation_config_cors.py +0 -190
  62. tests/foundation/config/database/__init__.py +0 -0
  63. tests/foundation/config/database/test_foundation_config_database.py +0 -158
  64. tests/foundation/config/database/test_foundation_config_database_connections.py +0 -203
  65. tests/foundation/config/database/test_foundation_config_database_mysql.py +0 -354
  66. tests/foundation/config/database/test_foundation_config_database_oracle.py +0 -288
  67. tests/foundation/config/database/test_foundation_config_database_pgsql.py +0 -257
  68. tests/foundation/config/database/test_foundation_config_database_sqlite.py +0 -207
  69. tests/foundation/config/filesystems/__init__.py +0 -0
  70. tests/foundation/config/filesystems/test_foundation_config_filesystems.py +0 -160
  71. tests/foundation/config/filesystems/test_foundation_config_filesystems_aws.py +0 -189
  72. tests/foundation/config/filesystems/test_foundation_config_filesystems_disks.py +0 -184
  73. tests/foundation/config/filesystems/test_foundation_config_filesystems_local.py +0 -143
  74. tests/foundation/config/filesystems/test_foundation_config_filesystems_public.py +0 -184
  75. tests/foundation/config/logging/__init__.py +0 -0
  76. tests/foundation/config/logging/test_foundation_config_logging.py +0 -112
  77. tests/foundation/config/logging/test_foundation_config_logging_channels.py +0 -246
  78. tests/foundation/config/logging/test_foundation_config_logging_chunked.py +0 -217
  79. tests/foundation/config/logging/test_foundation_config_logging_daily.py +0 -220
  80. tests/foundation/config/logging/test_foundation_config_logging_hourly.py +0 -196
  81. tests/foundation/config/logging/test_foundation_config_logging_monthly.py +0 -214
  82. tests/foundation/config/logging/test_foundation_config_logging_stack.py +0 -178
  83. tests/foundation/config/logging/test_foundation_config_logging_weekly.py +0 -224
  84. tests/foundation/config/mail/__init__.py +0 -0
  85. tests/foundation/config/mail/test_foundation_config_mail.py +0 -145
  86. tests/foundation/config/mail/test_foundation_config_mail_file.py +0 -97
  87. tests/foundation/config/mail/test_foundation_config_mail_mailers.py +0 -106
  88. tests/foundation/config/mail/test_foundation_config_mail_smtp.py +0 -146
  89. tests/foundation/config/queue/__init__.py +0 -0
  90. tests/foundation/config/queue/test_foundation_config_queue.py +0 -88
  91. tests/foundation/config/queue/test_foundation_config_queue_brokers.py +0 -72
  92. tests/foundation/config/queue/test_foundation_config_queue_database.py +0 -134
  93. tests/foundation/config/root/__init__.py +0 -0
  94. tests/foundation/config/root/test_foundation_config_root_paths.py +0 -112
  95. tests/foundation/config/session/__init__.py +0 -0
  96. tests/foundation/config/session/test_foundation_config_session.py +0 -213
  97. tests/foundation/config/startup/__init__.py +0 -0
  98. tests/foundation/config/startup/test_foundation_config_startup.py +0 -202
  99. tests/foundation/config/testing/__init__.py +0 -0
  100. tests/foundation/config/testing/test_foundation_config_testing.py +0 -235
  101. tests/metadata/__init__.py +0 -0
  102. tests/metadata/test_metadata_framework.py +0 -140
  103. tests/metadata/test_metadata_package.py +0 -139
  104. tests/services/__init__.py +0 -0
  105. tests/services/asynchrony/__init__.py +0 -0
  106. tests/services/asynchrony/test_services_asynchrony_coroutine.py +0 -85
  107. tests/services/environment/__init__.py +0 -0
  108. tests/services/environment/test_services_environment.py +0 -226
  109. tests/services/introspection/__init__.py +0 -0
  110. tests/services/introspection/dependencies/__init__.py +0 -0
  111. tests/services/introspection/dependencies/mocks/__init__.py +0 -0
  112. tests/services/introspection/dependencies/mocks/mock_user.py +0 -30
  113. tests/services/introspection/dependencies/mocks/mock_user_controller.py +0 -27
  114. tests/services/introspection/dependencies/mocks/mock_users_permissions.py +0 -41
  115. tests/services/introspection/dependencies/test_reflect_dependencies.py +0 -261
  116. tests/services/introspection/reflection/__init__.py +0 -0
  117. tests/services/introspection/reflection/mock/__init__.py +0 -0
  118. tests/services/introspection/reflection/mock/fake_reflect_instance.py +0 -1115
  119. tests/services/introspection/reflection/test_reflection_abstract.py +0 -1011
  120. tests/services/introspection/reflection/test_reflection_callable.py +0 -206
  121. tests/services/introspection/reflection/test_reflection_concrete.py +0 -952
  122. tests/services/introspection/reflection/test_reflection_instance.py +0 -1233
  123. tests/services/introspection/reflection/test_reflection_module.py +0 -567
  124. tests/services/introspection/test_reflection.py +0 -462
  125. tests/services/log/__init__.py +0 -0
  126. tests/services/log/test_log.py +0 -97
  127. tests/services/system/__init__.py +0 -0
  128. tests/services/system/test_services_system_imports.py +0 -204
  129. tests/services/system/test_services_system_workers.py +0 -131
  130. tests/support/__init__.py +0 -0
  131. tests/support/entities/__init__.py +0 -0
  132. tests/support/entities/mock_dataclass.py +0 -40
  133. tests/support/entities/test_base.py +0 -64
  134. tests/support/patterns/__init__.py +0 -0
  135. tests/support/patterns/singleton/__init__.py +0 -0
  136. tests/support/patterns/singleton/test_patterns_singleton.py +0 -39
  137. tests/support/standard/__init__.py +0 -0
  138. tests/support/standard/test_services_std.py +0 -226
  139. tests/support/wrapper/__init__.py +0 -0
  140. tests/support/wrapper/test_services_wrapper_docdict.py +0 -202
  141. tests/testing/__init__.py +0 -0
  142. tests/testing/cases/__init__.py +0 -0
  143. tests/testing/cases/test_testing_asynchronous.py +0 -63
  144. tests/testing/cases/test_testing_synchronous.py +0 -57
  145. tests/testing/entities/__init__.py +0 -0
  146. tests/testing/entities/test_testing_result.py +0 -146
  147. tests/testing/enums/__init__.py +0 -0
  148. tests/testing/enums/test_testing_status.py +0 -63
  149. tests/testing/output/__init__.py +0 -0
  150. tests/testing/output/test_testing_dumper.py +0 -29
  151. tests/testing/output/test_testing_printer.py +0 -42
  152. tests/testing/records/__init__.py +0 -0
  153. tests/testing/records/test_testing_records.py +0 -171
  154. tests/testing/test_testing_unit.py +0 -164
  155. tests/testing/validators/__init__.py +0 -0
  156. tests/testing/validators/test_testing_validators.py +0 -392
  157. tests/testing/view/__init__.py +0 -0
  158. tests/testing/view/test_render.py +0 -30
  159. {orionis-0.546.0.dist-info → orionis-0.548.0.dist-info}/WHEEL +0 -0
  160. {orionis-0.546.0.dist-info → orionis-0.548.0.dist-info}/licenses/LICENCE +0 -0
@@ -1,63 +0,0 @@
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
- Test that the TestStatus enum contains the expected members.
10
-
11
- Checks for the presence of the 'PASSED', 'FAILED', 'ERRORED', and 'SKIPPED' members in the TestStatus enum.
12
-
13
- Returns
14
- -------
15
- None
16
- """
17
- # Assert that each expected member exists in TestStatus
18
- self.assertTrue(hasattr(TestStatus, "PASSED"))
19
- self.assertTrue(hasattr(TestStatus, "FAILED"))
20
- self.assertTrue(hasattr(TestStatus, "ERRORED"))
21
- self.assertTrue(hasattr(TestStatus, "SKIPPED"))
22
-
23
- async def testEnumValuesAreUnique(self):
24
- """
25
- Test that all TestStatus enum member values are unique.
26
-
27
- Collects all values from the TestStatus enum and asserts that there are no duplicate values.
28
-
29
- Returns
30
- -------
31
- None
32
- """
33
- # Gather all enum values
34
- values = [status.value for status in TestStatus]
35
- # Assert that the number of values equals the number of unique values
36
- self.assertEqual(len(values), len(set(values)))
37
-
38
- async def testEnumIsInstanceOfEnum(self):
39
- """
40
- Test that TestStatus is a subclass of Enum.
41
-
42
- Asserts that TestStatus inherits from the Enum base class.
43
-
44
- Returns
45
- -------
46
- None
47
- """
48
- # Assert that TestStatus inherits from Enum
49
- self.assertTrue(issubclass(TestStatus, Enum))
50
-
51
- async def testEnumMembersType(self):
52
- """
53
- Test that each member of TestStatus is an instance of TestStatus.
54
-
55
- Iterates through all members of TestStatus and asserts their type.
56
-
57
- Returns
58
- -------
59
- None
60
- """
61
- # Assert that each enum member is an instance of TestStatus
62
- for status in TestStatus:
63
- self.assertIsInstance(status, TestStatus)
File without changes
@@ -1,29 +0,0 @@
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
- Verify the presence of required methods in the TestDumper class.
9
-
10
- This asynchronous test checks whether the TestDumper class implements all methods listed in `required_methods`.
11
- An assertion error is raised if any required method is missing.
12
-
13
- Returns
14
- -------
15
- None
16
- """
17
- required_methods = [
18
- "dd",
19
- "dump"
20
- ]
21
-
22
- # Iterate over the list of required method names
23
- for method_name in required_methods:
24
-
25
- # Assert that each required method exists in TestDumper
26
- self.assertTrue(
27
- hasattr(TestDumper, method_name),
28
- f"{method_name} does not exist"
29
- )
@@ -1,42 +0,0 @@
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
- Verify that all required methods are present in the TestPrinter class.
9
-
10
- This asynchronous test checks whether each method listed in `required_methods`
11
- exists as an attribute of the TestPrinter class. An assertion error is raised
12
- if any required method is missing.
13
-
14
- Parameters
15
- ----------
16
- self : TestTestingPrinter
17
- Instance of the test case.
18
-
19
- Returns
20
- -------
21
- None
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
- )
File without changes
@@ -1,171 +0,0 @@
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
- Test the creation and retrieval of a test report.
12
-
13
- Creates a test report with all required fields, stores it using the
14
- TestLogs class, and retrieves the most recent report to verify its
15
- contents.
16
-
17
- Returns
18
- -------
19
- None
20
- """
21
- with tempfile.TemporaryDirectory() as tmpdir:
22
- logs = TestLogs(tmpdir)
23
-
24
- # Prepare a complete test report dictionary
25
- report = {
26
- "total_tests": 5,
27
- "passed": 4,
28
- "failed": 1,
29
- "errors": 0,
30
- "skipped": 0,
31
- "total_time": 1.23,
32
- "success_rate": 0.8,
33
- "timestamp": "2024-06-01T12:00:00"
34
- }
35
-
36
- # Serialize the report to JSON and add to the dictionary
37
- report["json"] = json.dumps(report)
38
-
39
- # Store the report in the logs
40
- result = logs.create(report)
41
- self.assertTrue(result)
42
-
43
- # Retrieve the most recent report
44
- reports = logs.get(first=1)
45
- self.assertEqual(len(reports), 1)
46
-
47
- # Validate the contents of the retrieved report
48
- self.assertEqual(json.loads(reports[0][1])["total_tests"], 5)
49
-
50
- async def testCreateMissingFields(self):
51
- """
52
- Test error handling for missing required fields in report creation.
53
-
54
- Attempts to create a report without the required 'timestamp' field and
55
- expects an OrionisTestValueError to be raised.
56
-
57
- Returns
58
- -------
59
- None
60
- """
61
- with tempfile.TemporaryDirectory() as tmpdir:
62
- logs = TestLogs(tmpdir)
63
-
64
- # Prepare a report missing the 'timestamp' field
65
- report = {
66
- "total_tests": 5,
67
- "passed": 4,
68
- "failed": 1,
69
- "errors": 0,
70
- "skipped": 0,
71
- "total_time": 1.23,
72
- "success_rate": 0.8,
73
- }
74
- report["json"] = json.dumps(report)
75
-
76
- # Expect an error when creating the report
77
- with self.assertRaises(OrionisTestValueError):
78
- logs.create(report)
79
-
80
- async def testResetDatabase(self):
81
- """
82
- Test the reset functionality of the test logs database.
83
-
84
- Creates a report, stores it, and then resets the logs database.
85
- Verifies that the reset operation returns True.
86
-
87
- Returns
88
- -------
89
- None
90
- """
91
- with tempfile.TemporaryDirectory() as tmpdir:
92
- logs = TestLogs(tmpdir)
93
-
94
- # Create and store a single report
95
- report = {
96
- "total_tests": 1,
97
- "passed": 1,
98
- "failed": 0,
99
- "errors": 0,
100
- "skipped": 0,
101
- "total_time": 0.1,
102
- "success_rate": 1.0,
103
- "timestamp": "2024-06-01T12:00:00"
104
- }
105
- report["json"] = json.dumps(report)
106
- logs.create(report)
107
-
108
- # Reset the logs database and verify success
109
- self.assertTrue(logs.reset())
110
-
111
- async def testGetReportsInvalidParams(self):
112
- """
113
- Test error handling for invalid parameters in TestLogs.get().
114
-
115
- Checks that passing mutually exclusive or invalid values to get()
116
- raises an OrionisTestValueError.
117
-
118
- Returns
119
- -------
120
- None
121
- """
122
- with tempfile.TemporaryDirectory() as tmpdir:
123
- logs = TestLogs(tmpdir)
124
-
125
- # Both 'first' and 'last' should not be provided together
126
- with self.assertRaises(OrionisTestValueError):
127
- logs.get(first=1, last=1)
128
-
129
- # 'first' must be greater than zero
130
- with self.assertRaises(OrionisTestValueError):
131
- logs.get(first=0)
132
-
133
- # 'last' must be greater than zero
134
- with self.assertRaises(OrionisTestValueError):
135
- logs.get(last=-1)
136
-
137
- async def testGetLastReports(self):
138
- """
139
- Test retrieval of the last N reports and their order.
140
-
141
- Creates multiple reports, retrieves the last two, and checks that the
142
- reports are returned in descending order by their identifier.
143
-
144
- Returns
145
- -------
146
- None
147
- """
148
- with tempfile.TemporaryDirectory() as tmpdir:
149
- logs = TestLogs(tmpdir)
150
-
151
- # Create and store three reports with increasing 'total_tests'
152
- for i in range(3):
153
- report = {
154
- "total_tests": i+1,
155
- "passed": i,
156
- "failed": 1,
157
- "errors": 0,
158
- "skipped": 0,
159
- "total_time": 0.1 * (i+1),
160
- "success_rate": 0.5,
161
- "timestamp": f"2024-06-01T12:00:0{i}"
162
- }
163
- report["json"] = json.dumps(report)
164
- logs.create(report)
165
-
166
- # Retrieve the last two reports
167
- reports = logs.get(last=2)
168
- self.assertEqual(len(reports), 2)
169
-
170
- # Ensure the reports are ordered by descending identifier
171
- self.assertTrue(reports[0][0] > reports[1][0])
@@ -1,164 +0,0 @@
1
- import unittest
2
- from unittest.mock import MagicMock
3
- from orionis.app import Orionis
4
- from orionis.foundation.config.testing.enums.drivers import PersistentDrivers
5
- from orionis.foundation.config.testing.enums.mode import ExecutionMode
6
- from orionis.test.cases.asynchronous import AsyncTestCase
7
- from orionis.test.core.unit_test import UnitTest
8
-
9
- class TestTestingUnit(AsyncTestCase):
10
-
11
- async def testDefaultConfiguration(self) -> None:
12
- """
13
- Test that the `UnitTest` class initializes with the correct default configuration values and internal attributes.
14
-
15
- Returns
16
- -------
17
- None
18
- """
19
- unit_test = UnitTest(Orionis())
20
- # Assert that the loader is correctly initialized as a TestLoader
21
- self.assertIsInstance(unit_test._UnitTest__loader, unittest.TestLoader)
22
- # Assert that the suite is correctly initialized as a TestSuite
23
- self.assertIsInstance(unit_test._UnitTest__suite, unittest.TestSuite)
24
-
25
- async def testConfigureMethod(self) -> None:
26
- """
27
- Test that the `configure` method of `UnitTest` updates internal configuration attributes as expected.
28
-
29
- Returns
30
- -------
31
- None
32
- """
33
- unit_test = UnitTest(Orionis())
34
- # Configure the UnitTest instance with custom parameters
35
- configured = unit_test.configure(
36
- verbosity=1,
37
- execution_mode=ExecutionMode.PARALLEL,
38
- max_workers=4,
39
- fail_fast=True,
40
- print_result=False,
41
- throw_exception=True,
42
- persistent=False,
43
- persistent_driver=PersistentDrivers.JSON,
44
- web_report=False
45
- )
46
- # Assert that each internal attribute matches the configured value
47
- self.assertEqual(unit_test._UnitTest__verbosity, 1)
48
- self.assertEqual(unit_test._UnitTest__execution_mode, ExecutionMode.PARALLEL.value)
49
- self.assertEqual(unit_test._UnitTest__max_workers, 4)
50
- self.assertTrue(unit_test._UnitTest__fail_fast)
51
- self.assertTrue(unit_test._UnitTest__throw_exception)
52
- self.assertFalse(unit_test._UnitTest__persistent)
53
- self.assertEqual(unit_test._UnitTest__persistent_driver, PersistentDrivers.JSON.value)
54
- self.assertFalse(unit_test._UnitTest__web_report)
55
- # Ensure the configure method returns the same instance for chaining
56
- self.assertIs(configured, unit_test)
57
-
58
- async def testFlattenTestSuite(self) -> None:
59
- """
60
- Test that the `_flattenTestSuite` method of `UnitTest` flattens nested `TestSuite` instances into a list of test cases.
61
-
62
- Returns
63
- -------
64
- None
65
- """
66
- unit_test = UnitTest(Orionis())
67
- # Create mock test cases
68
- test_case1 = MagicMock()
69
- test_case2 = MagicMock()
70
- # Create a nested TestSuite containing the mock test cases
71
- nested_suite = unittest.TestSuite()
72
- nested_suite.addTest(test_case1)
73
- nested_suite.addTest(test_case2)
74
- # Create the main TestSuite and add the nested suite to it
75
- main_suite = unittest.TestSuite()
76
- main_suite.addTest(nested_suite)
77
- # Flatten the main suite using the method under test
78
- flattened = unit_test._UnitTest__flattenTestSuite(main_suite)
79
- # Assert that the flattened list contains both test cases
80
- self.assertEqual(len(flattened), 2)
81
- self.assertIn(test_case1, flattened)
82
- self.assertIn(test_case2, flattened)
83
-
84
- async def testMergeTestResults(self) -> None:
85
- """
86
- Test that the `_mergeTestResults` method of `UnitTest` correctly aggregates results from an individual `TestResult` into a combined `TestResult`.
87
-
88
- Returns
89
- -------
90
- None
91
- """
92
- unit_test = UnitTest(Orionis())
93
- # Create a combined TestResult to aggregate results into
94
- combined = unittest.TestResult()
95
- # Create an individual TestResult with sample data
96
- individual = unittest.TestResult()
97
- individual.testsRun = 2
98
- individual.failures = [('test1', 'failure')]
99
- individual.errors = [('test2', 'error')]
100
- individual.skipped = []
101
- individual.expectedFailures = []
102
- individual.unexpectedSuccesses = []
103
- # Merge the individual results into the combined result
104
- unit_test._UnitTest__mergeTestResults(combined, individual)
105
- # Assert that the combined result reflects the merged data
106
- self.assertEqual(combined.testsRun, 2)
107
- self.assertEqual(len(combined.failures), 1)
108
- self.assertEqual(len(combined.errors), 1)
109
-
110
- async def testClearTests(self) -> None:
111
- """
112
- Test that the `clearTests` method of `UnitTest` resets the test suite, removing all test cases.
113
-
114
- Returns
115
- -------
116
- None
117
- """
118
- unit_test = UnitTest(Orionis())
119
- # Add a mock test case to the suite
120
- mock_test = MagicMock()
121
- unit_test._UnitTest__suite.addTest(mock_test)
122
- # Clear all tests from the suite
123
- unit_test.clearTests()
124
- # Assert that the suite is now empty
125
- self.assertEqual(len(unit_test._UnitTest__suite._tests), 0)
126
-
127
- async def testGetTestNames(self) -> None:
128
- """
129
- Test that the `getTestNames` method of `UnitTest` returns a list of identifiers for all test cases in the suite.
130
-
131
- Returns
132
- -------
133
- None
134
- """
135
- unit_test = UnitTest(Orionis())
136
- # Create a mock test case and set its id() method to return a specific identifier
137
- mock_test = MagicMock()
138
- mock_test.id.return_value = 'test_id'
139
- # Add the mock test case to the UnitTest's internal suite
140
- unit_test._UnitTest__suite.addTest(mock_test)
141
- # Retrieve the list of test names using the method under test
142
- names = unit_test.getTestNames()
143
- # Assert that the returned list contains the expected test identifier
144
- self.assertEqual(names, ['test_id'])
145
-
146
- async def testGetTestCount(self) -> None:
147
- """
148
- Test that the `getTestCount` method of `UnitTest` returns the correct number of test cases in the suite.
149
-
150
- Returns
151
- -------
152
- None
153
- """
154
- unit_test = UnitTest(Orionis())
155
- # Create two mock test cases
156
- mock_test1 = MagicMock()
157
- mock_test2 = MagicMock()
158
- # Add the mock test cases to the UnitTest's internal suite
159
- unit_test._UnitTest__suite.addTest(mock_test1)
160
- unit_test._UnitTest__suite.addTest(mock_test2)
161
- # Retrieve the count of test cases using the method under test
162
- count = unit_test.getTestCount()
163
- # Assert that the returned count matches the number of test cases added
164
- self.assertEqual(count, 2)
File without changes