orionis 0.286.0__py3-none-any.whl → 0.288.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/services/environment/contracts/env.py +45 -50
- orionis/services/environment/contracts/types.py +70 -0
- orionis/services/environment/dot_env.py +204 -182
- orionis/services/environment/env.py +68 -85
- orionis/services/{standard/exceptions/path_value_exceptions.py → environment/exceptions/environment_value_error.py} +2 -12
- orionis/services/environment/exceptions/environment_value_exception.py +23 -0
- orionis/services/environment/types.py +578 -0
- orionis/services/paths/exceptions/not_found_exceptions.py +15 -12
- orionis/services/paths/exceptions/path_value_exceptions.py +13 -10
- orionis/services/standard/contracts/std.py +1 -1
- orionis/services/standard/exceptions/std_value_exception.py +23 -0
- orionis/services/standard/std.py +2 -2
- orionis/services/system/contracts/imports.py +27 -7
- orionis/services/system/contracts/workers.py +8 -3
- orionis/services/system/imports.py +31 -12
- orionis/services/system/runtime_imports.py +33 -23
- orionis/services/system/workers.py +6 -8
- orionis/services/wrapper/dicts/dot_dict.py +82 -41
- orionis/test/logs/history.py +3 -5
- orionis/unittesting.py +12 -12
- {orionis-0.286.0.dist-info → orionis-0.288.0.dist-info}/METADATA +1 -1
- {orionis-0.286.0.dist-info → orionis-0.288.0.dist-info}/RECORD +76 -70
- tests/example/test_example.py +5 -2
- tests/foundation/config/app/{test_app.py → test_foundation_config_app.py} +14 -4
- tests/foundation/config/auth/{test_auth.py → test_foundation_config_auth.py} +10 -5
- tests/foundation/config/cache/{test_cache.py → test_foundation_config_cache.py} +61 -16
- tests/foundation/config/cache/test_foundation_config_cache_file.py +126 -0
- tests/foundation/config/cache/test_foundation_config_cache_stores.py +148 -0
- tests/foundation/config/cors/test_foundation_config_cors.py +190 -0
- tests/foundation/config/database/{test_database.py → test_foundation_config_database.py} +39 -15
- tests/foundation/config/database/{test_database_connections.py → test_foundation_config_database_connections.py} +80 -6
- tests/foundation/config/database/{test_database_mysql.py → test_foundation_config_database_mysql.py} +139 -16
- tests/foundation/config/database/{test_database_oracle.py → test_foundation_config_database_oracle.py} +111 -27
- tests/foundation/config/database/{test_database_pgsql.py → test_foundation_config_database_pgsql.py} +97 -27
- tests/foundation/config/database/{test_database_sqlite.py → test_foundation_config_database_sqlite.py} +57 -3
- tests/foundation/config/exceptions/{test_exceptions_integrity.py → test_foundation_config_exceptions.py} +45 -11
- tests/foundation/config/filesystems/{test_filesystems.py → test_foundation_config_filesystems.py} +65 -15
- tests/foundation/config/filesystems/{test_filesystems_aws.py → test_foundation_config_filesystems_aws.py} +46 -8
- tests/foundation/config/filesystems/{test_filesystems_disks.py → test_foundation_config_filesystems_disks.py} +79 -9
- tests/foundation/config/filesystems/{test_filesystems_local.py → test_foundation_config_filesystems_local.py} +67 -19
- tests/foundation/config/filesystems/{test_filesystems_public.py → test_foundation_config_filesystems_public.py} +38 -1
- tests/foundation/config/logging/test_foundation_config_logging.py +112 -0
- tests/foundation/config/logging/{test_logging_channels.py → test_foundation_config_logging_channels.py} +80 -3
- tests/foundation/config/logging/{test_logging_chunked.py → test_foundation_config_logging_chunked.py} +86 -13
- tests/foundation/config/logging/{test_logging_daily.py → test_foundation_config_logging_daily.py} +80 -13
- tests/foundation/config/logging/{test_logging_hourly.py → test_foundation_config_logging_hourly.py} +69 -3
- tests/foundation/config/logging/{test_logging_monthly.py → test_foundation_config_logging_monthly.py} +49 -3
- tests/foundation/config/logging/{test_logging_stack.py → test_foundation_config_logging_stack.py} +50 -15
- tests/foundation/config/logging/{test_logging_weekly.py → test_foundation_config_logging_weekly.py} +93 -3
- tests/foundation/config/mail/test_foundation_config_mail.py +145 -0
- tests/foundation/config/mail/{test_mail_file.py → test_foundation_config_mail_file.py} +41 -5
- tests/foundation/config/mail/test_foundation_config_mail_mailers.py +106 -0
- tests/foundation/config/mail/{test_mail_smtp.py → test_foundation_config_mail_smtp.py} +59 -15
- tests/foundation/config/queue/test_foundation_config_queue.py +111 -0
- tests/foundation/config/queue/{test_queue_brokers.py → test_foundation_config_queue_brokers.py} +28 -11
- tests/foundation/config/queue/{test_queue_database.py → test_foundation_config_queue_database.py} +54 -16
- tests/foundation/config/root/{test_root_paths.py → test_foundation_config_root_paths.py} +70 -3
- tests/foundation/config/session/{test_session.py → test_foundation_config_session.py} +31 -2
- tests/foundation/config/startup/{test_config_startup.py → test_foundation_config_startup.py} +91 -21
- tests/foundation/config/testing/{test_testing.py → test_foundation_config_testing.py} +69 -1
- tests/patterns/singleton/test_patterns_singleton.py +27 -0
- tests/services/asynchrony/{test_async_io.py → test_services_asynchrony_coroutine.py} +1 -1
- tests/services/environment/test_services_environment.py +93 -0
- tests/services/path/{test_resolver.py → test_services_resolver.py} +51 -12
- tests/services/standard/{test_std.py → test_services_std.py} +45 -22
- tests/services/system/__init__.py +0 -0
- tests/services/system/test_services_system_imports.py +101 -0
- tests/services/system/test_services_system_workers.py +89 -0
- tests/services/wrapper/{test_wrapper_doc_dict.py → test_services_wrapper_docdict.py} +28 -16
- tests/testing/test_testing_result.py +57 -20
- tests/testing/test_testing_unit.py +110 -41
- orionis/services/environment/exceptions/value_exception.py +0 -27
- tests/foundation/config/cache/test_cache_file.py +0 -78
- tests/foundation/config/cache/test_cache_stores.py +0 -88
- tests/foundation/config/cors/test_cors.py +0 -121
- tests/foundation/config/logging/test_logging.py +0 -48
- tests/foundation/config/mail/test_mail.py +0 -73
- tests/foundation/config/mail/test_mail_mailers.py +0 -58
- tests/foundation/config/queue/test_queue.py +0 -58
- tests/patterns/singleton/test_singleton.py +0 -18
- tests/services/environment/test_env.py +0 -155
- {orionis-0.286.0.dist-info → orionis-0.288.0.dist-info}/WHEEL +0 -0
- {orionis-0.286.0.dist-info → orionis-0.288.0.dist-info}/licenses/LICENCE +0 -0
- {orionis-0.286.0.dist-info → orionis-0.288.0.dist-info}/top_level.txt +0 -0
- {orionis-0.286.0.dist-info → orionis-0.288.0.dist-info}/zip-safe +0 -0
@@ -1,14 +1,14 @@
|
|
1
1
|
from orionis.test.cases.test_case import TestCase
|
2
|
-
from orionis.unittesting import UnitTest, ExecutionMode,
|
2
|
+
from orionis.unittesting import UnitTest, ExecutionMode, TestLoader, StandardTestSuite, patch, MagicMock, StandardTestResult
|
3
3
|
|
4
|
-
class
|
5
|
-
"""
|
6
|
-
Test cases for the UnitTest class which handles test discovery and execution.
|
7
|
-
"""
|
4
|
+
class TestTestingUnit(TestCase):
|
8
5
|
|
9
|
-
async def testDefaultConfiguration(self):
|
6
|
+
async def testDefaultConfiguration(self) -> None:
|
10
7
|
"""
|
11
8
|
Test that UnitTest initializes with correct default configuration values.
|
9
|
+
|
10
|
+
Notes
|
11
|
+
-----
|
12
12
|
Verifies that all default attributes are set as expected upon initialization.
|
13
13
|
"""
|
14
14
|
unit_test = UnitTest()
|
@@ -17,13 +17,31 @@ class TestUnitTest(TestCase):
|
|
17
17
|
self.assertEqual(unit_test.max_workers, 4)
|
18
18
|
self.assertFalse(unit_test.fail_fast)
|
19
19
|
self.assertTrue(unit_test.print_result)
|
20
|
-
self.assertIsInstance(unit_test.loader,
|
21
|
-
self.assertIsInstance(unit_test.suite,
|
22
|
-
|
23
|
-
async def testConfigureMethod(self):
|
24
|
-
"""
|
25
|
-
Test
|
26
|
-
|
20
|
+
self.assertIsInstance(unit_test.loader, TestLoader)
|
21
|
+
self.assertIsInstance(unit_test.suite, StandardTestSuite)
|
22
|
+
|
23
|
+
async def testConfigureMethod(self) -> None:
|
24
|
+
"""
|
25
|
+
Test the `configure` method for correct configuration updates.
|
26
|
+
This test verifies that all configuration parameters of the `UnitTest` class
|
27
|
+
can be updated through the `configure` method and that the changes are
|
28
|
+
reflected in the instance attributes.
|
29
|
+
|
30
|
+
Parameters
|
31
|
+
----------
|
32
|
+
self : TestCase
|
33
|
+
The test case instance.
|
34
|
+
|
35
|
+
Notes
|
36
|
+
-----
|
37
|
+
The test checks the following configuration parameters:
|
38
|
+
- verbosity
|
39
|
+
- execution_mode
|
40
|
+
- max_workers
|
41
|
+
- fail_fast
|
42
|
+
- print_result
|
43
|
+
- throw_exception
|
44
|
+
It also asserts that the `configure` method returns the instance itself.
|
27
45
|
"""
|
28
46
|
unit_test = UnitTest()
|
29
47
|
configured = unit_test.configure(
|
@@ -43,35 +61,53 @@ class TestUnitTest(TestCase):
|
|
43
61
|
self.assertTrue(unit_test.throw_exception)
|
44
62
|
self.assertEqual(configured, unit_test)
|
45
63
|
|
46
|
-
async def testDiscoverTestsInModule(self):
|
64
|
+
async def testDiscoverTestsInModule(self) -> None:
|
47
65
|
"""
|
48
|
-
Test that discoverTestsInModule correctly loads tests from a module.
|
66
|
+
Test that `discoverTestsInModule` correctly loads tests from a module.
|
67
|
+
|
49
68
|
Verifies that tests can be discovered from a module and added to the test suite.
|
69
|
+
|
70
|
+
Notes
|
71
|
+
-----
|
72
|
+
This test mocks the loader's `loadTestsFromName` method to ensure that
|
73
|
+
`discoverTestsInModule` calls it with the correct arguments and that the
|
74
|
+
returned suite is handled as expected.
|
50
75
|
"""
|
51
76
|
unit_test = UnitTest()
|
52
|
-
with
|
53
|
-
mock_load.return_value =
|
77
|
+
with patch.object(unit_test.loader, 'loadTestsFromName') as mock_load:
|
78
|
+
mock_load.return_value = StandardTestSuite()
|
54
79
|
result = unit_test.discoverTestsInModule('test_module')
|
55
80
|
|
56
81
|
mock_load.assert_called_once_with('test_module')
|
57
82
|
self.assertEqual(result, unit_test)
|
58
83
|
self.assertEqual(len(unit_test.suite._tests), 0)
|
59
84
|
|
60
|
-
async def testFlattenTestSuite(self):
|
85
|
+
async def testFlattenTestSuite(self) -> None:
|
61
86
|
"""
|
62
|
-
Test
|
87
|
+
Test the _flattenTestSuite method for correct flattening of nested test suites.
|
88
|
+
This test verifies that the _flattenTestSuite method of the UnitTest class
|
89
|
+
correctly flattens both simple and nested unittest suites into a single list
|
90
|
+
of test cases.
|
91
|
+
|
92
|
+
Parameters
|
93
|
+
----------
|
94
|
+
self : TestCase
|
95
|
+
The test case instance.
|
63
96
|
|
64
|
-
|
97
|
+
Notes
|
98
|
+
-----
|
99
|
+
- Ensures that nested suites are recursively flattened.
|
100
|
+
- Asserts that all test cases from nested suites are present in the flattened result.
|
65
101
|
"""
|
66
102
|
unit_test = UnitTest()
|
67
|
-
test_case1 =
|
68
|
-
test_case2 =
|
103
|
+
test_case1 = MagicMock()
|
104
|
+
test_case2 = MagicMock()
|
69
105
|
|
70
|
-
nested_suite =
|
106
|
+
nested_suite = StandardTestSuite()
|
71
107
|
nested_suite.addTest(test_case1)
|
72
108
|
nested_suite.addTest(test_case2)
|
73
109
|
|
74
|
-
main_suite =
|
110
|
+
main_suite = StandardTestSuite()
|
75
111
|
main_suite.addTest(nested_suite)
|
76
112
|
|
77
113
|
flattened = unit_test._flattenTestSuite(main_suite)
|
@@ -79,15 +115,20 @@ class TestUnitTest(TestCase):
|
|
79
115
|
self.assertIn(test_case1, flattened)
|
80
116
|
self.assertIn(test_case2, flattened)
|
81
117
|
|
82
|
-
async def testMergeTestResults(self):
|
118
|
+
async def testMergeTestResults(self) -> None:
|
83
119
|
"""
|
84
|
-
Test
|
120
|
+
Test the _mergeTestResults method for correct merging of test results.
|
121
|
+
Ensures that the method accurately combines the number of tests run,
|
122
|
+
as well as the lists of failures and errors from individual test results.
|
85
123
|
|
86
|
-
|
124
|
+
Notes
|
125
|
+
-----
|
126
|
+
- Verifies that the total number of tests run is updated correctly.
|
127
|
+
- Checks that failures and errors are merged without loss of information.
|
87
128
|
"""
|
88
129
|
unit_test = UnitTest()
|
89
|
-
combined =
|
90
|
-
individual =
|
130
|
+
combined = StandardTestResult()
|
131
|
+
individual = StandardTestResult()
|
91
132
|
|
92
133
|
individual.testsRun = 2
|
93
134
|
individual.failures = [('test1', 'failure')]
|
@@ -98,39 +139,67 @@ class TestUnitTest(TestCase):
|
|
98
139
|
self.assertEqual(len(combined.failures), 1)
|
99
140
|
self.assertEqual(len(combined.errors), 1)
|
100
141
|
|
101
|
-
async def testClearTests(self):
|
142
|
+
async def testClearTests(self) -> None:
|
102
143
|
"""
|
103
|
-
Test
|
104
|
-
|
144
|
+
Test the clearTests method to ensure it resets the test suite.
|
145
|
+
This test verifies that after adding a mock test to the suite and calling
|
146
|
+
the clearTests method, the suite is emptied as expected.
|
147
|
+
|
148
|
+
Steps
|
149
|
+
-----
|
150
|
+
1. Create an instance of UnitTest.
|
151
|
+
2. Add a mock test to the test suite.
|
152
|
+
3. Call the clearTests method.
|
153
|
+
4. Assert that the test suite is empty.
|
154
|
+
|
155
|
+
Assertions
|
156
|
+
----------
|
157
|
+
- The length of the test suite should be zero after calling clearTests.
|
105
158
|
"""
|
106
159
|
unit_test = UnitTest()
|
107
|
-
mock_test =
|
160
|
+
mock_test = MagicMock()
|
108
161
|
unit_test.suite.addTest(mock_test)
|
109
162
|
|
110
163
|
unit_test.clearTests()
|
111
164
|
self.assertEqual(len(unit_test.suite._tests), 0)
|
112
165
|
|
113
|
-
async def testGetTestNames(self):
|
166
|
+
async def testGetTestNames(self) -> None:
|
114
167
|
"""
|
115
|
-
|
116
|
-
|
168
|
+
This test verifies that the `getTestNames` method of the `UnitTest` class
|
169
|
+
correctly extracts and returns the identifiers of tests present in the test suite.
|
170
|
+
|
171
|
+
Notes
|
172
|
+
-----
|
173
|
+
- Mocks a test case with a predefined identifier.
|
174
|
+
- Adds the mock test to the test suite.
|
175
|
+
- Asserts that the returned list of test names matches the expected value.
|
117
176
|
"""
|
118
177
|
unit_test = UnitTest()
|
119
|
-
mock_test =
|
178
|
+
mock_test = MagicMock()
|
120
179
|
mock_test.id.return_value = 'test_id'
|
121
180
|
unit_test.suite.addTest(mock_test)
|
122
181
|
|
123
182
|
names = unit_test.getTestNames()
|
124
183
|
self.assertEqual(names, ['test_id'])
|
125
184
|
|
126
|
-
async def testGetTestCount(self):
|
185
|
+
async def testGetTestCount(self) -> None:
|
127
186
|
"""
|
128
|
-
Test that getTestCount returns the correct number of tests.
|
187
|
+
Test that `getTestCount` returns the correct number of tests.
|
188
|
+
|
129
189
|
Verifies that the count matches the number of tests in the suite.
|
190
|
+
|
191
|
+
Notes
|
192
|
+
-----
|
193
|
+
- Adds two mock tests to the suite.
|
194
|
+
- Asserts that `getTestCount` returns 2.
|
195
|
+
|
196
|
+
Returns
|
197
|
+
-------
|
198
|
+
None
|
130
199
|
"""
|
131
200
|
unit_test = UnitTest()
|
132
|
-
mock_test1 =
|
133
|
-
mock_test2 =
|
201
|
+
mock_test1 = MagicMock()
|
202
|
+
mock_test2 = MagicMock()
|
134
203
|
unit_test.suite.addTest(mock_test1)
|
135
204
|
unit_test.suite.addTest(mock_test2)
|
136
205
|
|
@@ -1,27 +0,0 @@
|
|
1
|
-
class OrionisEnvironmentValueException(Exception):
|
2
|
-
"""
|
3
|
-
Exception raised for invalid or unexpected environment values within the Orionis framework.
|
4
|
-
This exception is intended to signal issues encountered when an environment variable,
|
5
|
-
configuration value, or similar parameter does not meet the expected criteria or format.
|
6
|
-
It provides a clear and descriptive error message to facilitate debugging and error handling.
|
7
|
-
Attributes:
|
8
|
-
raise OrionisEnvironmentValueException("Invalid value for ORIONIS_MODE: expected 'production' or 'development'.")
|
9
|
-
msg (str): The error message describing the specific value-related exception.
|
10
|
-
"""
|
11
|
-
|
12
|
-
def __init__(self, msg: str):
|
13
|
-
"""
|
14
|
-
Initializes the exception with a custom error message.
|
15
|
-
Args:
|
16
|
-
msg (str): The error message describing the exception.
|
17
|
-
"""
|
18
|
-
super().__init__(msg)
|
19
|
-
|
20
|
-
def __str__(self) -> str:
|
21
|
-
"""
|
22
|
-
Return a string representation of the exception, including the class name and the first argument.
|
23
|
-
|
24
|
-
Returns:
|
25
|
-
str: A formatted string with the exception class name and its first argument.
|
26
|
-
"""
|
27
|
-
return f"{self.__class__.__name__}: {self.args[0]}"
|
@@ -1,78 +0,0 @@
|
|
1
|
-
from orionis.foundation.config.cache.entities.file import File
|
2
|
-
from orionis.foundation.config.exceptions.integrity import OrionisIntegrityException
|
3
|
-
from orionis.unittesting import TestCase
|
4
|
-
|
5
|
-
class TestConfigFile(TestCase):
|
6
|
-
"""
|
7
|
-
Test cases for the File cache configuration entity.
|
8
|
-
"""
|
9
|
-
|
10
|
-
async def testDefaultPath(self):
|
11
|
-
"""
|
12
|
-
Test that the File instance is created with the correct default path.
|
13
|
-
Verifies that the default path matches the expected value from the class definition.
|
14
|
-
"""
|
15
|
-
file_config = File()
|
16
|
-
self.assertEqual(file_config.path, 'storage/framework/cache/data')
|
17
|
-
|
18
|
-
async def testCustomPath(self):
|
19
|
-
"""
|
20
|
-
Test that a custom path can be set during initialization.
|
21
|
-
Verifies that the path attribute accepts and stores valid custom paths.
|
22
|
-
"""
|
23
|
-
custom_path = 'custom/cache/path'
|
24
|
-
file_config = File(path=custom_path)
|
25
|
-
self.assertEqual(file_config.path, custom_path)
|
26
|
-
|
27
|
-
async def testEmptyPathValidation(self):
|
28
|
-
"""
|
29
|
-
Test that empty paths are rejected.
|
30
|
-
Verifies that an empty path raises an OrionisIntegrityException.
|
31
|
-
"""
|
32
|
-
with self.assertRaises(OrionisIntegrityException):
|
33
|
-
File(path="")
|
34
|
-
|
35
|
-
async def testPathTypeValidation(self):
|
36
|
-
"""
|
37
|
-
Test that non-string paths are rejected.
|
38
|
-
Verifies that non-string path values raise an OrionisIntegrityException.
|
39
|
-
"""
|
40
|
-
with self.assertRaises(OrionisIntegrityException):
|
41
|
-
File(path=123)
|
42
|
-
|
43
|
-
with self.assertRaises(OrionisIntegrityException):
|
44
|
-
File(path=None)
|
45
|
-
|
46
|
-
with self.assertRaises(OrionisIntegrityException):
|
47
|
-
File(path=[])
|
48
|
-
|
49
|
-
async def testToDictMethod(self):
|
50
|
-
"""
|
51
|
-
Test that the toDict method returns a proper dictionary representation.
|
52
|
-
Verifies that the returned dictionary contains the expected path value.
|
53
|
-
"""
|
54
|
-
file_config = File()
|
55
|
-
config_dict = file_config.toDict()
|
56
|
-
|
57
|
-
self.assertIsInstance(config_dict, dict)
|
58
|
-
self.assertEqual(config_dict['path'], 'storage/framework/cache/data')
|
59
|
-
|
60
|
-
async def testCustomPathToDict(self):
|
61
|
-
"""
|
62
|
-
Test that custom paths are properly included in the dictionary representation.
|
63
|
-
Verifies that toDict() includes custom path values when specified.
|
64
|
-
"""
|
65
|
-
custom_path = 'another/cache/location'
|
66
|
-
file_config = File(path=custom_path)
|
67
|
-
config_dict = file_config.toDict()
|
68
|
-
|
69
|
-
self.assertEqual(config_dict['path'], custom_path)
|
70
|
-
|
71
|
-
async def testWhitespacePathHandling(self):
|
72
|
-
"""
|
73
|
-
Test that paths with whitespace are accepted but not automatically trimmed.
|
74
|
-
Verifies that the validation allows paths containing whitespace characters.
|
75
|
-
"""
|
76
|
-
spaced_path = ' storage/cache/with/space '
|
77
|
-
file_config = File(path=spaced_path)
|
78
|
-
self.assertEqual(file_config.path, spaced_path)
|
@@ -1,88 +0,0 @@
|
|
1
|
-
from orionis.foundation.config.cache.entities.stores import Stores
|
2
|
-
from orionis.foundation.config.cache.entities.file import File
|
3
|
-
from orionis.foundation.config.exceptions.integrity import OrionisIntegrityException
|
4
|
-
from orionis.unittesting import TestCase
|
5
|
-
|
6
|
-
class TestConfigStores(TestCase):
|
7
|
-
"""
|
8
|
-
Test cases for the Stores cache configuration entity.
|
9
|
-
"""
|
10
|
-
|
11
|
-
async def testDefaultFileStore(self):
|
12
|
-
"""
|
13
|
-
Test that Stores initializes with a default File instance.
|
14
|
-
Verifies that the file attribute is properly initialized with default File configuration.
|
15
|
-
"""
|
16
|
-
stores = Stores()
|
17
|
-
self.assertIsInstance(stores.file, File)
|
18
|
-
self.assertEqual(stores.file.path, 'storage/framework/cache/data')
|
19
|
-
|
20
|
-
async def testCustomFileStore(self):
|
21
|
-
"""
|
22
|
-
Test that Stores accepts a custom File configuration.
|
23
|
-
Verifies that a custom File instance can be provided during initialization.
|
24
|
-
"""
|
25
|
-
custom_file = File(path='custom/cache/path')
|
26
|
-
stores = Stores(file=custom_file)
|
27
|
-
self.assertIsInstance(stores.file, File)
|
28
|
-
self.assertEqual(stores.file.path, 'custom/cache/path')
|
29
|
-
|
30
|
-
async def testFileTypeValidation(self):
|
31
|
-
"""
|
32
|
-
Test that Stores validates the file attribute type.
|
33
|
-
Verifies that non-File instances raise OrionisIntegrityException.
|
34
|
-
"""
|
35
|
-
with self.assertRaises(OrionisIntegrityException):
|
36
|
-
Stores(file="not_a_file_instance")
|
37
|
-
|
38
|
-
with self.assertRaises(OrionisIntegrityException):
|
39
|
-
Stores(file=123)
|
40
|
-
|
41
|
-
with self.assertRaises(OrionisIntegrityException):
|
42
|
-
Stores(file=None)
|
43
|
-
|
44
|
-
async def testToDictMethodWithDefaults(self):
|
45
|
-
"""
|
46
|
-
Test that toDict returns proper dictionary with default values.
|
47
|
-
Verifies the dictionary representation contains the correct default file path.
|
48
|
-
"""
|
49
|
-
stores = Stores()
|
50
|
-
stores_dict = stores.toDict()
|
51
|
-
|
52
|
-
self.assertIsInstance(stores_dict, dict)
|
53
|
-
self.assertIsInstance(stores_dict['file'], dict)
|
54
|
-
self.assertEqual(stores_dict['file']['path'], 'storage/framework/cache/data')
|
55
|
-
|
56
|
-
async def testToDictMethodWithCustomFile(self):
|
57
|
-
"""
|
58
|
-
Test that toDict includes custom file configurations.
|
59
|
-
Verifies the dictionary representation reflects custom file paths.
|
60
|
-
"""
|
61
|
-
custom_file = File(path='alternate/cache/location')
|
62
|
-
stores = Stores(file=custom_file)
|
63
|
-
stores_dict = stores.toDict()
|
64
|
-
|
65
|
-
self.assertEqual(stores_dict['file']['path'], 'alternate/cache/location')
|
66
|
-
|
67
|
-
async def testHashability(self):
|
68
|
-
"""
|
69
|
-
Test that Stores maintains hashability due to unsafe_hash=True.
|
70
|
-
Verifies that Stores instances can be used in sets and as dictionary keys.
|
71
|
-
"""
|
72
|
-
store1 = Stores()
|
73
|
-
store2 = Stores()
|
74
|
-
store_set = {store1, store2}
|
75
|
-
|
76
|
-
self.assertEqual(len(store_set), 1)
|
77
|
-
|
78
|
-
custom_store = Stores(file=File(path='custom/path'))
|
79
|
-
store_set.add(custom_store)
|
80
|
-
self.assertEqual(len(store_set), 2)
|
81
|
-
|
82
|
-
async def testKwOnlyInitialization(self):
|
83
|
-
"""
|
84
|
-
Test that Stores enforces keyword-only initialization.
|
85
|
-
Verifies that positional arguments are not allowed for initialization.
|
86
|
-
"""
|
87
|
-
with self.assertRaises(TypeError):
|
88
|
-
Stores(File())
|
@@ -1,121 +0,0 @@
|
|
1
|
-
|
2
|
-
from orionis.foundation.config.cors.entities.cors import Cors
|
3
|
-
from orionis.foundation.config.exceptions.integrity import OrionisIntegrityException
|
4
|
-
from orionis.unittesting import TestCase
|
5
|
-
|
6
|
-
class TestCorsConfig(TestCase):
|
7
|
-
"""
|
8
|
-
Unit tests for Cors configuration defaults and validation.
|
9
|
-
"""
|
10
|
-
|
11
|
-
async def testDefaultValues(self):
|
12
|
-
"""
|
13
|
-
Test the default values of the Cors configuration.
|
14
|
-
|
15
|
-
This test verifies that a newly instantiated Cors object has the following default settings:
|
16
|
-
- allow_origins: ["*"]
|
17
|
-
- allow_origin_regex: None
|
18
|
-
- allow_methods: ["*"]
|
19
|
-
- allow_headers: ["*"]
|
20
|
-
- expose_headers: []
|
21
|
-
- allow_credentials: False
|
22
|
-
- max_age: 600
|
23
|
-
"""
|
24
|
-
cors = Cors()
|
25
|
-
self.assertEqual(cors.allow_origins, ["*"])
|
26
|
-
self.assertIsNone(cors.allow_origin_regex)
|
27
|
-
self.assertEqual(cors.allow_methods, ["*"])
|
28
|
-
self.assertEqual(cors.allow_headers, ["*"])
|
29
|
-
self.assertEqual(cors.expose_headers, [])
|
30
|
-
self.assertFalse(cors.allow_credentials)
|
31
|
-
self.assertEqual(cors.max_age, 600)
|
32
|
-
|
33
|
-
async def testCustomValues(self):
|
34
|
-
"""
|
35
|
-
Test that the Cors configuration correctly sets custom values for all parameters.
|
36
|
-
|
37
|
-
This test verifies that:
|
38
|
-
- `allow_origins` is set to the provided list of origins.
|
39
|
-
- `allow_origin_regex` is set to the provided regex pattern.
|
40
|
-
- `allow_methods` is set to the provided list of HTTP methods.
|
41
|
-
- `allow_headers` is set to the provided list of headers.
|
42
|
-
- `expose_headers` is set to the provided list of exposed headers.
|
43
|
-
- `allow_credentials` is set to True.
|
44
|
-
- `max_age` is set to the provided integer value.
|
45
|
-
|
46
|
-
Ensures that the Cors object accurately reflects the custom configuration values.
|
47
|
-
"""
|
48
|
-
cors = Cors(
|
49
|
-
allow_origins=["https://example.com"],
|
50
|
-
allow_origin_regex="^https://.*\\.example\\.com$",
|
51
|
-
allow_methods=["GET", "POST"],
|
52
|
-
allow_headers=["Authorization", "Content-Type"],
|
53
|
-
expose_headers=["X-Custom-Header"],
|
54
|
-
allow_credentials=True,
|
55
|
-
max_age=3600
|
56
|
-
)
|
57
|
-
self.assertEqual(cors.allow_origins, ["https://example.com"])
|
58
|
-
self.assertEqual(cors.allow_origin_regex, "^https://.*\\.example\\.com$")
|
59
|
-
self.assertEqual(cors.allow_methods, ["GET", "POST"])
|
60
|
-
self.assertEqual(cors.allow_headers, ["Authorization", "Content-Type"])
|
61
|
-
self.assertEqual(cors.expose_headers, ["X-Custom-Header"])
|
62
|
-
self.assertTrue(cors.allow_credentials)
|
63
|
-
self.assertEqual(cors.max_age, 3600)
|
64
|
-
|
65
|
-
async def testInvalidAllowOriginsType(self):
|
66
|
-
"""
|
67
|
-
Test that passing a string instead of a list to the 'allow_origins' parameter of the Cors class
|
68
|
-
raises an OrionisIntegrityException.
|
69
|
-
"""
|
70
|
-
with self.assertRaises(OrionisIntegrityException):
|
71
|
-
Cors(allow_origins="*")
|
72
|
-
|
73
|
-
async def testInvalidAllowOriginRegexType(self):
|
74
|
-
"""
|
75
|
-
Test that passing a non-string, non-None value (specifically an integer) to the
|
76
|
-
`allow_origin_regex` parameter of the `Cors` class raises an OrionisIntegrityException.
|
77
|
-
"""
|
78
|
-
with self.assertRaises(OrionisIntegrityException):
|
79
|
-
Cors(allow_origin_regex=123)
|
80
|
-
|
81
|
-
async def testInvalidAllowMethodsType(self):
|
82
|
-
"""
|
83
|
-
Test that initializing the Cors class with an invalid type for 'allow_methods' raises an OrionisIntegrityException.
|
84
|
-
|
85
|
-
This test verifies that passing a string instead of a list to the 'allow_methods' parameter
|
86
|
-
of the Cors class triggers the expected exception, ensuring type validation is enforced.
|
87
|
-
"""
|
88
|
-
with self.assertRaises(OrionisIntegrityException):
|
89
|
-
Cors(allow_methods="GET")
|
90
|
-
|
91
|
-
async def testInvalidAllowHeadersType(self):
|
92
|
-
"""
|
93
|
-
Test that initializing the Cors class with a non-list type for 'allow_headers' (specifically a string)
|
94
|
-
raises an OrionisIntegrityException, ensuring type validation for the 'allow_headers' parameter.
|
95
|
-
"""
|
96
|
-
with self.assertRaises(OrionisIntegrityException):
|
97
|
-
Cors(allow_headers="Authorization")
|
98
|
-
|
99
|
-
async def testInvalidExposeHeadersType(self):
|
100
|
-
"""
|
101
|
-
Test that initializing the Cors class with a non-list type for 'expose_headers'
|
102
|
-
raises an OrionisIntegrityException. Ensures type validation for the 'expose_headers' parameter.
|
103
|
-
"""
|
104
|
-
with self.assertRaises(OrionisIntegrityException):
|
105
|
-
Cors(expose_headers="X-Custom-Header")
|
106
|
-
|
107
|
-
async def testInvalidAllowCredentialsType(self):
|
108
|
-
"""
|
109
|
-
Test that initializing the Cors class with a non-boolean value for 'allow_credentials'
|
110
|
-
raises an OrionisIntegrityException, ensuring type validation for the parameter.
|
111
|
-
"""
|
112
|
-
with self.assertRaises(OrionisIntegrityException):
|
113
|
-
Cors(allow_credentials="yes")
|
114
|
-
|
115
|
-
async def testInvalidMaxAgeType(self):
|
116
|
-
"""
|
117
|
-
Test that passing a non-integer value (specifically a string) to the `max_age` parameter of the `Cors` class
|
118
|
-
raises an `OrionisIntegrityException`. This ensures that `max_age` only accepts integer or None values.
|
119
|
-
"""
|
120
|
-
with self.assertRaises(OrionisIntegrityException):
|
121
|
-
Cors(max_age="3600")
|
@@ -1,48 +0,0 @@
|
|
1
|
-
from orionis.foundation.config.logging.entities.logging import Logging
|
2
|
-
from orionis.foundation.config.logging.entities.channels import Channels
|
3
|
-
from orionis.foundation.config.exceptions.integrity import OrionisIntegrityException
|
4
|
-
from orionis.unittesting import TestCase
|
5
|
-
|
6
|
-
class TestLogging(TestCase):
|
7
|
-
|
8
|
-
async def testDefaultValues(self):
|
9
|
-
"""
|
10
|
-
Test that the Logging instance is initialized with correct default values.
|
11
|
-
Verifies that a new Logging object has 'stack' as default channel
|
12
|
-
and an instance of Channels as channels attribute.
|
13
|
-
"""
|
14
|
-
logging = Logging()
|
15
|
-
self.assertEqual(logging.default, "stack")
|
16
|
-
self.assertIsInstance(logging.channels, Channels)
|
17
|
-
|
18
|
-
async def testToDictMethod(self):
|
19
|
-
"""
|
20
|
-
Test the toDict method returns a proper dictionary representation.
|
21
|
-
Checks that the toDict method converts the Logging instance
|
22
|
-
into a dictionary with all expected fields.
|
23
|
-
"""
|
24
|
-
logging = Logging()
|
25
|
-
result = logging.toDict()
|
26
|
-
self.assertIsInstance(result, dict)
|
27
|
-
self.assertIn("default", result)
|
28
|
-
self.assertIn("channels", result)
|
29
|
-
|
30
|
-
async def testPostInitValidation(self):
|
31
|
-
"""
|
32
|
-
Test the __post_init__ validation works correctly.
|
33
|
-
Verifies that invalid default channel or channels type
|
34
|
-
raises OrionisIntegrityException.
|
35
|
-
"""
|
36
|
-
with self.assertRaises(OrionisIntegrityException):
|
37
|
-
Logging(default="invalid_channel")
|
38
|
-
|
39
|
-
with self.assertRaises(OrionisIntegrityException):
|
40
|
-
Logging(channels="invalid_channels")
|
41
|
-
|
42
|
-
async def testKwOnlyInitialization(self):
|
43
|
-
"""
|
44
|
-
Test that Logging requires keyword arguments for initialization.
|
45
|
-
Verifies that the class enforces kw_only=True in its dataclass decorator.
|
46
|
-
"""
|
47
|
-
with self.assertRaises(TypeError):
|
48
|
-
Logging("stack", Channels())
|
@@ -1,73 +0,0 @@
|
|
1
|
-
from orionis.foundation.config.mail.entities.mail import Mail
|
2
|
-
from orionis.foundation.config.mail.entities.mailers import Mailers
|
3
|
-
from orionis.foundation.config.exceptions.integrity import OrionisIntegrityException
|
4
|
-
from orionis.unittesting import TestCase
|
5
|
-
|
6
|
-
class TestMail(TestCase):
|
7
|
-
|
8
|
-
async def testDefaultInitialization(self):
|
9
|
-
"""
|
10
|
-
Test that Mail instance is initialized with correct default values.
|
11
|
-
Verifies that default mailer is 'smtp' and mailers is an instance of Mailers.
|
12
|
-
"""
|
13
|
-
mail = Mail()
|
14
|
-
self.assertEqual(mail.default, "smtp")
|
15
|
-
self.assertIsInstance(mail.mailers, Mailers)
|
16
|
-
|
17
|
-
async def testDefaultValidation(self):
|
18
|
-
"""
|
19
|
-
Test validation of default mailer against available options.
|
20
|
-
Verifies that invalid default mailer raises OrionisIntegrityException.
|
21
|
-
"""
|
22
|
-
with self.assertRaises(OrionisIntegrityException):
|
23
|
-
Mail(default="invalid_mailer")
|
24
|
-
with self.assertRaises(OrionisIntegrityException):
|
25
|
-
Mail(default=123)
|
26
|
-
|
27
|
-
async def testMailersTypeValidation(self):
|
28
|
-
"""
|
29
|
-
Test validation of mailers attribute type.
|
30
|
-
Verifies that non-Mailers objects raise OrionisIntegrityException.
|
31
|
-
"""
|
32
|
-
with self.assertRaises(OrionisIntegrityException):
|
33
|
-
Mail(mailers="invalid_mailers_object")
|
34
|
-
|
35
|
-
async def testToDictMethod(self):
|
36
|
-
"""
|
37
|
-
Test the toDict method returns proper dictionary representation.
|
38
|
-
Verifies the method returns a dict containing all fields.
|
39
|
-
"""
|
40
|
-
mail = Mail()
|
41
|
-
result = mail.toDict()
|
42
|
-
self.assertIsInstance(result, dict)
|
43
|
-
self.assertIn("default", result)
|
44
|
-
self.assertIn("mailers", result)
|
45
|
-
self.assertEqual(result["default"], "smtp")
|
46
|
-
|
47
|
-
async def testHashability(self):
|
48
|
-
"""
|
49
|
-
Test that Mail instances are hashable due to unsafe_hash=True.
|
50
|
-
Verifies instances can be used in sets or as dictionary keys.
|
51
|
-
"""
|
52
|
-
mail1 = Mail()
|
53
|
-
mail2 = Mail(default="smtp")
|
54
|
-
test_set = {mail1, mail2}
|
55
|
-
self.assertEqual(len(test_set), 1)
|
56
|
-
|
57
|
-
async def testKwOnlyInitialization(self):
|
58
|
-
"""
|
59
|
-
Test that Mail requires keyword arguments for initialization.
|
60
|
-
Verifies the class enforces kw_only=True in its dataclass decorator.
|
61
|
-
"""
|
62
|
-
with self.assertRaises(TypeError):
|
63
|
-
Mail("smtp", Mailers())
|
64
|
-
|
65
|
-
async def testValidCustomInitialization(self):
|
66
|
-
"""
|
67
|
-
Test valid custom initialization with proper values.
|
68
|
-
Verifies instance can be created with valid non-default values.
|
69
|
-
"""
|
70
|
-
# Assuming 'smtp' is a valid mailer option from Mailers
|
71
|
-
mail = Mail(default="smtp", mailers=Mailers())
|
72
|
-
self.assertEqual(mail.default, "smtp")
|
73
|
-
self.assertIsInstance(mail.mailers, Mailers)
|