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.
- orionis/console/base/scheduler_event_listener.py +0 -17
- orionis/console/contracts/schedule_event_listener.py +0 -18
- orionis/foundation/config/app/entities/app.py +3 -2
- orionis/foundation/config/app/enums/ciphers.py +5 -19
- orionis/foundation/config/session/entities/session.py +2 -2
- orionis/metadata/framework.py +1 -1
- orionis/services/encrypter/encrypter.py +115 -0
- orionis/services/environment/dynamic/caster.py +35 -27
- orionis/services/environment/key/key_generator.py +32 -11
- {orionis-0.546.0.dist-info → orionis-0.548.0.dist-info}/METADATA +1 -1
- {orionis-0.546.0.dist-info → orionis-0.548.0.dist-info}/RECORD +14 -159
- {orionis-0.546.0.dist-info → orionis-0.548.0.dist-info}/top_level.txt +0 -1
- orionis-0.546.0.dist-info/zip-safe +0 -1
- tests/container/__init__.py +0 -0
- tests/container/context/__init__.py +0 -0
- tests/container/context/test_manager.py +0 -38
- tests/container/context/test_scope.py +0 -32
- tests/container/core/__init__.py +0 -0
- tests/container/core/test_advanced_async.py +0 -234
- tests/container/core/test_async_optimizations.py +0 -268
- tests/container/core/test_container.py +0 -453
- tests/container/core/test_singleton.py +0 -122
- tests/container/core/test_thread_safety.py +0 -90
- tests/container/entities/__init__.py +0 -0
- tests/container/entities/test_binding.py +0 -242
- tests/container/enums/__init__.py +0 -0
- tests/container/enums/test_lifetimes.py +0 -97
- tests/container/facades/__init__.py +0 -0
- tests/container/facades/test_facade.py +0 -78
- tests/container/mocks/__init__.py +0 -0
- tests/container/mocks/mock_advanced_async.py +0 -332
- tests/container/mocks/mock_async_optimizations.py +0 -407
- tests/container/mocks/mock_auto_resolution.py +0 -192
- tests/container/mocks/mock_complex_classes.py +0 -792
- tests/container/mocks/mock_simple_classes.py +0 -98
- tests/container/providers/__init__.py +0 -0
- tests/container/providers/test_providers.py +0 -55
- tests/container/validators/__init__.py +0 -0
- tests/container/validators/test_implements.py +0 -186
- tests/container/validators/test_is_abstract_class.py +0 -147
- tests/container/validators/test_is_callable.py +0 -102
- tests/container/validators/test_is_concrete_class.py +0 -160
- tests/container/validators/test_is_instance.py +0 -150
- tests/container/validators/test_is_not_subclass.py +0 -49
- tests/container/validators/test_is_subclass.py +0 -178
- tests/container/validators/test_is_valid_alias.py +0 -147
- tests/container/validators/test_lifetime.py +0 -106
- tests/example/__init__.py +0 -0
- tests/example/test_example.py +0 -725
- tests/foundation/__init__.py +0 -0
- tests/foundation/config/__init__.py +0 -0
- tests/foundation/config/app/__init__.py +0 -0
- tests/foundation/config/app/test_foundation_config_app.py +0 -262
- tests/foundation/config/auth/__init__.py +0 -0
- tests/foundation/config/auth/test_foundation_config_auth.py +0 -29
- tests/foundation/config/cache/__init__.py +0 -0
- tests/foundation/config/cache/test_foundation_config_cache.py +0 -143
- tests/foundation/config/cache/test_foundation_config_cache_file.py +0 -126
- tests/foundation/config/cache/test_foundation_config_cache_stores.py +0 -156
- tests/foundation/config/cors/__init__.py +0 -0
- tests/foundation/config/cors/test_foundation_config_cors.py +0 -190
- tests/foundation/config/database/__init__.py +0 -0
- tests/foundation/config/database/test_foundation_config_database.py +0 -158
- tests/foundation/config/database/test_foundation_config_database_connections.py +0 -203
- tests/foundation/config/database/test_foundation_config_database_mysql.py +0 -354
- tests/foundation/config/database/test_foundation_config_database_oracle.py +0 -288
- tests/foundation/config/database/test_foundation_config_database_pgsql.py +0 -257
- tests/foundation/config/database/test_foundation_config_database_sqlite.py +0 -207
- tests/foundation/config/filesystems/__init__.py +0 -0
- tests/foundation/config/filesystems/test_foundation_config_filesystems.py +0 -160
- tests/foundation/config/filesystems/test_foundation_config_filesystems_aws.py +0 -189
- tests/foundation/config/filesystems/test_foundation_config_filesystems_disks.py +0 -184
- tests/foundation/config/filesystems/test_foundation_config_filesystems_local.py +0 -143
- tests/foundation/config/filesystems/test_foundation_config_filesystems_public.py +0 -184
- tests/foundation/config/logging/__init__.py +0 -0
- tests/foundation/config/logging/test_foundation_config_logging.py +0 -112
- tests/foundation/config/logging/test_foundation_config_logging_channels.py +0 -246
- tests/foundation/config/logging/test_foundation_config_logging_chunked.py +0 -217
- tests/foundation/config/logging/test_foundation_config_logging_daily.py +0 -220
- tests/foundation/config/logging/test_foundation_config_logging_hourly.py +0 -196
- tests/foundation/config/logging/test_foundation_config_logging_monthly.py +0 -214
- tests/foundation/config/logging/test_foundation_config_logging_stack.py +0 -178
- tests/foundation/config/logging/test_foundation_config_logging_weekly.py +0 -224
- tests/foundation/config/mail/__init__.py +0 -0
- tests/foundation/config/mail/test_foundation_config_mail.py +0 -145
- tests/foundation/config/mail/test_foundation_config_mail_file.py +0 -97
- tests/foundation/config/mail/test_foundation_config_mail_mailers.py +0 -106
- tests/foundation/config/mail/test_foundation_config_mail_smtp.py +0 -146
- tests/foundation/config/queue/__init__.py +0 -0
- tests/foundation/config/queue/test_foundation_config_queue.py +0 -88
- tests/foundation/config/queue/test_foundation_config_queue_brokers.py +0 -72
- tests/foundation/config/queue/test_foundation_config_queue_database.py +0 -134
- tests/foundation/config/root/__init__.py +0 -0
- tests/foundation/config/root/test_foundation_config_root_paths.py +0 -112
- tests/foundation/config/session/__init__.py +0 -0
- tests/foundation/config/session/test_foundation_config_session.py +0 -213
- tests/foundation/config/startup/__init__.py +0 -0
- tests/foundation/config/startup/test_foundation_config_startup.py +0 -202
- tests/foundation/config/testing/__init__.py +0 -0
- tests/foundation/config/testing/test_foundation_config_testing.py +0 -235
- tests/metadata/__init__.py +0 -0
- tests/metadata/test_metadata_framework.py +0 -140
- tests/metadata/test_metadata_package.py +0 -139
- tests/services/__init__.py +0 -0
- tests/services/asynchrony/__init__.py +0 -0
- tests/services/asynchrony/test_services_asynchrony_coroutine.py +0 -85
- tests/services/environment/__init__.py +0 -0
- tests/services/environment/test_services_environment.py +0 -226
- tests/services/introspection/__init__.py +0 -0
- tests/services/introspection/dependencies/__init__.py +0 -0
- tests/services/introspection/dependencies/mocks/__init__.py +0 -0
- tests/services/introspection/dependencies/mocks/mock_user.py +0 -30
- tests/services/introspection/dependencies/mocks/mock_user_controller.py +0 -27
- tests/services/introspection/dependencies/mocks/mock_users_permissions.py +0 -41
- tests/services/introspection/dependencies/test_reflect_dependencies.py +0 -261
- tests/services/introspection/reflection/__init__.py +0 -0
- tests/services/introspection/reflection/mock/__init__.py +0 -0
- tests/services/introspection/reflection/mock/fake_reflect_instance.py +0 -1115
- tests/services/introspection/reflection/test_reflection_abstract.py +0 -1011
- tests/services/introspection/reflection/test_reflection_callable.py +0 -206
- tests/services/introspection/reflection/test_reflection_concrete.py +0 -952
- tests/services/introspection/reflection/test_reflection_instance.py +0 -1233
- tests/services/introspection/reflection/test_reflection_module.py +0 -567
- tests/services/introspection/test_reflection.py +0 -462
- tests/services/log/__init__.py +0 -0
- tests/services/log/test_log.py +0 -97
- tests/services/system/__init__.py +0 -0
- tests/services/system/test_services_system_imports.py +0 -204
- tests/services/system/test_services_system_workers.py +0 -131
- tests/support/__init__.py +0 -0
- tests/support/entities/__init__.py +0 -0
- tests/support/entities/mock_dataclass.py +0 -40
- tests/support/entities/test_base.py +0 -64
- tests/support/patterns/__init__.py +0 -0
- tests/support/patterns/singleton/__init__.py +0 -0
- tests/support/patterns/singleton/test_patterns_singleton.py +0 -39
- tests/support/standard/__init__.py +0 -0
- tests/support/standard/test_services_std.py +0 -226
- tests/support/wrapper/__init__.py +0 -0
- tests/support/wrapper/test_services_wrapper_docdict.py +0 -202
- tests/testing/__init__.py +0 -0
- tests/testing/cases/__init__.py +0 -0
- tests/testing/cases/test_testing_asynchronous.py +0 -63
- tests/testing/cases/test_testing_synchronous.py +0 -57
- tests/testing/entities/__init__.py +0 -0
- tests/testing/entities/test_testing_result.py +0 -146
- tests/testing/enums/__init__.py +0 -0
- tests/testing/enums/test_testing_status.py +0 -63
- tests/testing/output/__init__.py +0 -0
- tests/testing/output/test_testing_dumper.py +0 -29
- tests/testing/output/test_testing_printer.py +0 -42
- tests/testing/records/__init__.py +0 -0
- tests/testing/records/test_testing_records.py +0 -171
- tests/testing/test_testing_unit.py +0 -164
- tests/testing/validators/__init__.py +0 -0
- tests/testing/validators/test_testing_validators.py +0 -392
- tests/testing/view/__init__.py +0 -0
- tests/testing/view/test_render.py +0 -30
- {orionis-0.546.0.dist-info → orionis-0.548.0.dist-info}/WHEEL +0 -0
- {orionis-0.546.0.dist-info → orionis-0.548.0.dist-info}/licenses/LICENCE +0 -0
tests/foundation/__init__.py
DELETED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -1,262 +0,0 @@
|
|
|
1
|
-
from orionis.foundation.config.app.entities.app import App
|
|
2
|
-
from orionis.foundation.config.app.enums.ciphers import Cipher
|
|
3
|
-
from orionis.foundation.config.app.enums.environments import Environments
|
|
4
|
-
from orionis.foundation.exceptions.integrity import OrionisIntegrityException
|
|
5
|
-
from orionis.test.cases.asynchronous import AsyncTestCase
|
|
6
|
-
from orionis.services.system.workers import Workers
|
|
7
|
-
|
|
8
|
-
class TestFoundationConfigApp(AsyncTestCase):
|
|
9
|
-
|
|
10
|
-
async def testDefaultValues(self):
|
|
11
|
-
"""
|
|
12
|
-
Tests that the App class initializes with the correct default values for all attributes.
|
|
13
|
-
|
|
14
|
-
This method creates an instance of the App class without passing any arguments and
|
|
15
|
-
verifies that each attribute is set to its expected default value. It also checks that
|
|
16
|
-
the generated key is a non-empty string.
|
|
17
|
-
|
|
18
|
-
Returns
|
|
19
|
-
-------
|
|
20
|
-
None
|
|
21
|
-
This method does not return any value. It performs assertions to validate default values.
|
|
22
|
-
"""
|
|
23
|
-
app = App() # Create App instance with default parameters
|
|
24
|
-
|
|
25
|
-
# Assert default name
|
|
26
|
-
self.assertEqual(app.name, 'Orionis Application')
|
|
27
|
-
|
|
28
|
-
# Assert default environment
|
|
29
|
-
self.assertEqual(app.env, Environments.DEVELOPMENT.value)
|
|
30
|
-
|
|
31
|
-
# Assert default debug mode is enabled
|
|
32
|
-
self.assertTrue(app.debug)
|
|
33
|
-
|
|
34
|
-
# Assert default URL
|
|
35
|
-
self.assertEqual(app.url, 'http://127.0.0.1')
|
|
36
|
-
|
|
37
|
-
# Assert default port
|
|
38
|
-
self.assertEqual(app.port, 8000)
|
|
39
|
-
|
|
40
|
-
# Assert default timezone
|
|
41
|
-
self.assertEqual(app.timezone, 'UTC')
|
|
42
|
-
|
|
43
|
-
# Assert default locale
|
|
44
|
-
self.assertEqual(app.locale, 'en')
|
|
45
|
-
|
|
46
|
-
# Assert default fallback locale
|
|
47
|
-
self.assertEqual(app.fallback_locale, 'en')
|
|
48
|
-
|
|
49
|
-
# Assert default cipher
|
|
50
|
-
self.assertEqual(app.cipher, Cipher.AES_256_CBC.value)
|
|
51
|
-
|
|
52
|
-
# Assert key is a non-empty string
|
|
53
|
-
self.assertIsInstance(app.key, str)
|
|
54
|
-
self.assertTrue(app.key) # key is never None or empty
|
|
55
|
-
self.assertEqual(app.maintenance, '/maintenance')
|
|
56
|
-
|
|
57
|
-
async def testEnvironmentValidation(self):
|
|
58
|
-
"""
|
|
59
|
-
Validates that the App class correctly handles environment values.
|
|
60
|
-
|
|
61
|
-
This method tests the initialization of the App class with different environment values,
|
|
62
|
-
ensuring that valid environments are accepted and set correctly, while invalid values
|
|
63
|
-
raise an OrionisIntegrityException.
|
|
64
|
-
|
|
65
|
-
Parameters
|
|
66
|
-
----------
|
|
67
|
-
None
|
|
68
|
-
|
|
69
|
-
Returns
|
|
70
|
-
-------
|
|
71
|
-
None
|
|
72
|
-
This method does not return any value. It performs assertions to validate environment handling.
|
|
73
|
-
"""
|
|
74
|
-
# Test with a valid environment string
|
|
75
|
-
app = App(env="PRODUCTION")
|
|
76
|
-
self.assertEqual(app.env, Environments.PRODUCTION.value)
|
|
77
|
-
|
|
78
|
-
# Test with a valid Environments enum
|
|
79
|
-
app = App(env=Environments.TESTING)
|
|
80
|
-
self.assertEqual(app.env, Environments.TESTING.value)
|
|
81
|
-
|
|
82
|
-
# Test with an invalid environment value, expecting an exception
|
|
83
|
-
with self.assertRaises(OrionisIntegrityException):
|
|
84
|
-
App(env="INVALID_ENV")
|
|
85
|
-
|
|
86
|
-
async def testCipherValidation(self):
|
|
87
|
-
"""
|
|
88
|
-
Validates that the App class correctly handles cipher values.
|
|
89
|
-
|
|
90
|
-
This method tests the initialization of the App class with different cipher values,
|
|
91
|
-
ensuring that valid ciphers are accepted and set correctly, while invalid values
|
|
92
|
-
raise an OrionisIntegrityException.
|
|
93
|
-
|
|
94
|
-
Parameters
|
|
95
|
-
----------
|
|
96
|
-
None
|
|
97
|
-
|
|
98
|
-
Returns
|
|
99
|
-
-------
|
|
100
|
-
None
|
|
101
|
-
This method does not return any value. It performs assertions to validate cipher handling.
|
|
102
|
-
"""
|
|
103
|
-
# Test with a valid cipher string
|
|
104
|
-
app = App(cipher="AES_128_CBC")
|
|
105
|
-
self.assertEqual(app.cipher, Cipher.AES_128_CBC.value)
|
|
106
|
-
|
|
107
|
-
# Test with a valid Cipher enum
|
|
108
|
-
app = App(cipher=Cipher.AES_192_CBC)
|
|
109
|
-
self.assertEqual(app.cipher, Cipher.AES_192_CBC.value)
|
|
110
|
-
|
|
111
|
-
# Test with an invalid cipher value, expecting an exception
|
|
112
|
-
with self.assertRaises(OrionisIntegrityException):
|
|
113
|
-
App(cipher="INVALID_CIPHER")
|
|
114
|
-
|
|
115
|
-
async def testTypeValidation(self):
|
|
116
|
-
"""
|
|
117
|
-
Validates that the App class enforces correct types for its attributes.
|
|
118
|
-
|
|
119
|
-
This method attempts to initialize the App class with incorrect types for various attributes.
|
|
120
|
-
It asserts that an OrionisIntegrityException is raised for each case, ensuring that type validation
|
|
121
|
-
is properly enforced for all relevant parameters.
|
|
122
|
-
|
|
123
|
-
Parameters
|
|
124
|
-
----------
|
|
125
|
-
None
|
|
126
|
-
|
|
127
|
-
Returns
|
|
128
|
-
-------
|
|
129
|
-
None
|
|
130
|
-
This method does not return any value. It performs assertions to verify type validation.
|
|
131
|
-
"""
|
|
132
|
-
# Name must be a string, not an integer
|
|
133
|
-
with self.assertRaises(OrionisIntegrityException):
|
|
134
|
-
App(name=123)
|
|
135
|
-
|
|
136
|
-
# Debug must be a boolean, not a string
|
|
137
|
-
with self.assertRaises(OrionisIntegrityException):
|
|
138
|
-
App(debug="true")
|
|
139
|
-
|
|
140
|
-
# URL must be a string, not an integer
|
|
141
|
-
with self.assertRaises(OrionisIntegrityException):
|
|
142
|
-
App(url=123)
|
|
143
|
-
|
|
144
|
-
# Port must be an integer, not a string
|
|
145
|
-
with self.assertRaises(OrionisIntegrityException):
|
|
146
|
-
App(port="8000")
|
|
147
|
-
|
|
148
|
-
# Workers must be an integer, not a string
|
|
149
|
-
with self.assertRaises(OrionisIntegrityException):
|
|
150
|
-
App(workers="4")
|
|
151
|
-
|
|
152
|
-
# Reload must be a boolean, not a string
|
|
153
|
-
with self.assertRaises(OrionisIntegrityException):
|
|
154
|
-
App(reload="true")
|
|
155
|
-
|
|
156
|
-
async def testWorkersRangeValidation(self):
|
|
157
|
-
"""
|
|
158
|
-
Tests the validation of the workers parameter range for the App class.
|
|
159
|
-
|
|
160
|
-
This method verifies that the App class raises an OrionisIntegrityException
|
|
161
|
-
when initialized with an invalid number of workers. Specifically, it checks
|
|
162
|
-
for two cases:
|
|
163
|
-
- When the number of workers is set to 0 (below the minimum allowed).
|
|
164
|
-
- When the number of workers exceeds the maximum allowed, as calculated
|
|
165
|
-
by Workers().calculate().
|
|
166
|
-
|
|
167
|
-
Comments are provided within the code to clarify the purpose of each assertion.
|
|
168
|
-
|
|
169
|
-
Returns
|
|
170
|
-
-------
|
|
171
|
-
None
|
|
172
|
-
This test method does not return any value. It asserts that exceptions
|
|
173
|
-
are raised for invalid worker counts.
|
|
174
|
-
"""
|
|
175
|
-
max_workers = Workers().calculate()
|
|
176
|
-
with self.assertRaises(OrionisIntegrityException):
|
|
177
|
-
App(workers=0)
|
|
178
|
-
with self.assertRaises(OrionisIntegrityException):
|
|
179
|
-
App(workers=max_workers + 1)
|
|
180
|
-
|
|
181
|
-
async def testToDictMethod(self):
|
|
182
|
-
"""
|
|
183
|
-
Tests the `toDict` method of the App class to ensure it returns a dictionary
|
|
184
|
-
representation of the application's configuration with correct values.
|
|
185
|
-
|
|
186
|
-
This method creates an instance of the App class using default parameters,
|
|
187
|
-
invokes the `toDict` method, and verifies that the returned dictionary contains
|
|
188
|
-
all expected keys and values matching the default configuration. It also checks
|
|
189
|
-
that the key attribute is a non-empty string.
|
|
190
|
-
|
|
191
|
-
Returns
|
|
192
|
-
-------
|
|
193
|
-
None
|
|
194
|
-
This method does not return any value. It performs assertions to validate
|
|
195
|
-
the correctness of the dictionary returned by `toDict`.
|
|
196
|
-
"""
|
|
197
|
-
app = App() # Create App instance with default parameters
|
|
198
|
-
|
|
199
|
-
app_dict = app.toDict() # Get dictionary representation of the app configuration
|
|
200
|
-
|
|
201
|
-
# Assert that the returned value is a dictionary
|
|
202
|
-
self.assertIsInstance(app_dict, dict)
|
|
203
|
-
|
|
204
|
-
# Assert each key in the dictionary matches the expected default value
|
|
205
|
-
self.assertEqual(app_dict['name'], 'Orionis Application')
|
|
206
|
-
self.assertEqual(app_dict['env'], Environments.DEVELOPMENT.value)
|
|
207
|
-
self.assertTrue(app_dict['debug'])
|
|
208
|
-
self.assertEqual(app_dict['url'], 'http://127.0.0.1')
|
|
209
|
-
self.assertEqual(app_dict['port'], 8000)
|
|
210
|
-
self.assertEqual(app_dict['timezone'], 'UTC')
|
|
211
|
-
self.assertEqual(app_dict['locale'], 'en')
|
|
212
|
-
self.assertEqual(app_dict['fallback_locale'], 'en')
|
|
213
|
-
self.assertEqual(app_dict['cipher'], Cipher.AES_256_CBC.value)
|
|
214
|
-
|
|
215
|
-
# Assert that the key is a non-empty string
|
|
216
|
-
self.assertIsInstance(app_dict['key'], str)
|
|
217
|
-
self.assertTrue(app_dict['key'])
|
|
218
|
-
|
|
219
|
-
self.assertEqual(app_dict['maintenance'], '/maintenance')
|
|
220
|
-
|
|
221
|
-
async def testNonEmptyStringValidation(self):
|
|
222
|
-
"""
|
|
223
|
-
Validates that the App class enforces non-empty string constraints for specific attributes.
|
|
224
|
-
|
|
225
|
-
This method attempts to initialize the App class with empty strings for attributes that require
|
|
226
|
-
non-empty values, such as `name`, `url`, `timezone`, `locale`, `fallback_locale`, and `maintenance`.
|
|
227
|
-
It asserts that an OrionisIntegrityException is raised for each case, ensuring that the class
|
|
228
|
-
properly enforces non-empty string validation. Additionally, it checks that the `maintenance`
|
|
229
|
-
attribute must start with a forward slash (`/`).
|
|
230
|
-
|
|
231
|
-
Returns
|
|
232
|
-
-------
|
|
233
|
-
None
|
|
234
|
-
This method does not return any value. It performs assertions to verify non-empty string validation.
|
|
235
|
-
"""
|
|
236
|
-
# Name must not be an empty string
|
|
237
|
-
with self.assertRaises(OrionisIntegrityException):
|
|
238
|
-
App(name="")
|
|
239
|
-
|
|
240
|
-
# URL must not be an empty string
|
|
241
|
-
with self.assertRaises(OrionisIntegrityException):
|
|
242
|
-
App(url="")
|
|
243
|
-
|
|
244
|
-
# Timezone must not be an empty string
|
|
245
|
-
with self.assertRaises(OrionisIntegrityException):
|
|
246
|
-
App(timezone="")
|
|
247
|
-
|
|
248
|
-
# Locale must not be an empty string
|
|
249
|
-
with self.assertRaises(OrionisIntegrityException):
|
|
250
|
-
App(locale="")
|
|
251
|
-
|
|
252
|
-
# Fallback locale must not be an empty string
|
|
253
|
-
with self.assertRaises(OrionisIntegrityException):
|
|
254
|
-
App(fallback_locale="")
|
|
255
|
-
|
|
256
|
-
# Maintenance must not be an empty string
|
|
257
|
-
with self.assertRaises(OrionisIntegrityException):
|
|
258
|
-
App(maintenance="")
|
|
259
|
-
|
|
260
|
-
# Maintenance must start with a forward slash ('/')
|
|
261
|
-
with self.assertRaises(OrionisIntegrityException):
|
|
262
|
-
App(maintenance="maintenance")
|
|
File without changes
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
from orionis.foundation.config.auth.entities.auth import Auth
|
|
2
|
-
from orionis.test.cases.asynchronous import AsyncTestCase
|
|
3
|
-
|
|
4
|
-
class TestFoundationConfigAuth(AsyncTestCase):
|
|
5
|
-
"""
|
|
6
|
-
Test suite for verifying the behavior of the Auth configuration within the application.
|
|
7
|
-
|
|
8
|
-
This class contains asynchronous test cases to ensure that the Auth object
|
|
9
|
-
correctly handles the assignment and retrieval of new attribute values.
|
|
10
|
-
"""
|
|
11
|
-
|
|
12
|
-
async def testNewValue(self):
|
|
13
|
-
"""
|
|
14
|
-
Test assignment and retrieval of new attribute values in Auth.
|
|
15
|
-
|
|
16
|
-
This test creates a new Auth object and assigns values to new attributes.
|
|
17
|
-
It then asserts that these attributes hold the expected values.
|
|
18
|
-
|
|
19
|
-
Returns
|
|
20
|
-
-------
|
|
21
|
-
None
|
|
22
|
-
This method does not return a value.
|
|
23
|
-
"""
|
|
24
|
-
auth = Auth()
|
|
25
|
-
auth.new_value = 'new_value'
|
|
26
|
-
auth.new_value2 = 'new_value2'
|
|
27
|
-
|
|
28
|
-
self.assertEqual(auth.new_value, 'new_value')
|
|
29
|
-
self.assertEqual(auth.new_value2, 'new_value2')
|
|
File without changes
|
|
@@ -1,143 +0,0 @@
|
|
|
1
|
-
from orionis.test.cases.asynchronous import AsyncTestCase
|
|
2
|
-
from orionis.foundation.config.cache.entities.cache import Cache
|
|
3
|
-
from orionis.foundation.config.cache.enums.drivers import Drivers
|
|
4
|
-
from orionis.foundation.exceptions.integrity import OrionisIntegrityException
|
|
5
|
-
from orionis.foundation.config.cache.entities.stores import Stores
|
|
6
|
-
|
|
7
|
-
class TestFoundationConfigCache(AsyncTestCase):
|
|
8
|
-
"""
|
|
9
|
-
Test suite for the Cache configuration entity.
|
|
10
|
-
|
|
11
|
-
This class contains asynchronous unit tests for the Cache entity,
|
|
12
|
-
validating default values, driver validation, type checking,
|
|
13
|
-
dictionary conversion, and Stores instance validation.
|
|
14
|
-
"""
|
|
15
|
-
|
|
16
|
-
async def testDefaultValues(self):
|
|
17
|
-
"""
|
|
18
|
-
Test that the Cache instance is created with the correct default values.
|
|
19
|
-
|
|
20
|
-
Ensures that the default values of the Cache instance match the expected
|
|
21
|
-
defaults from the class definition.
|
|
22
|
-
|
|
23
|
-
Returns
|
|
24
|
-
-------
|
|
25
|
-
None
|
|
26
|
-
"""
|
|
27
|
-
cache = Cache()
|
|
28
|
-
self.assertEqual(cache.default, Drivers.MEMORY.value)
|
|
29
|
-
self.assertIsInstance(cache.stores, Stores)
|
|
30
|
-
|
|
31
|
-
async def testDriverValidation(self):
|
|
32
|
-
"""
|
|
33
|
-
Test validation and conversion of the default driver attribute.
|
|
34
|
-
|
|
35
|
-
Verifies that string drivers are converted to enum values and that
|
|
36
|
-
invalid drivers raise exceptions.
|
|
37
|
-
|
|
38
|
-
Returns
|
|
39
|
-
-------
|
|
40
|
-
None
|
|
41
|
-
"""
|
|
42
|
-
# Test valid string driver
|
|
43
|
-
cache = Cache(default="FILE")
|
|
44
|
-
self.assertEqual(cache.default, Drivers.FILE.value)
|
|
45
|
-
|
|
46
|
-
# Test invalid driver
|
|
47
|
-
with self.assertRaises(OrionisIntegrityException):
|
|
48
|
-
Cache(default="INVALID_DRIVER")
|
|
49
|
-
|
|
50
|
-
async def testDriverCaseInsensitivity(self):
|
|
51
|
-
"""
|
|
52
|
-
Test case insensitivity of driver names provided as strings.
|
|
53
|
-
|
|
54
|
-
Ensures that different case variations of driver names are properly
|
|
55
|
-
normalized to the correct enum value.
|
|
56
|
-
|
|
57
|
-
Returns
|
|
58
|
-
-------
|
|
59
|
-
None
|
|
60
|
-
"""
|
|
61
|
-
# Test lowercase
|
|
62
|
-
cache = Cache(default="file")
|
|
63
|
-
self.assertEqual(cache.default, Drivers.FILE.value)
|
|
64
|
-
|
|
65
|
-
# Test mixed case
|
|
66
|
-
cache = Cache(default="FiLe")
|
|
67
|
-
self.assertEqual(cache.default, Drivers.FILE.value)
|
|
68
|
-
|
|
69
|
-
# Test uppercase
|
|
70
|
-
cache = Cache(default="FILE")
|
|
71
|
-
self.assertEqual(cache.default, Drivers.FILE.value)
|
|
72
|
-
|
|
73
|
-
async def testTypeValidation(self):
|
|
74
|
-
"""
|
|
75
|
-
Test type validation for all attributes.
|
|
76
|
-
|
|
77
|
-
Ensures that invalid types for each attribute raise
|
|
78
|
-
OrionisIntegrityException.
|
|
79
|
-
|
|
80
|
-
Returns
|
|
81
|
-
-------
|
|
82
|
-
None
|
|
83
|
-
"""
|
|
84
|
-
# Test invalid default type
|
|
85
|
-
with self.assertRaises(OrionisIntegrityException):
|
|
86
|
-
Cache(default=123)
|
|
87
|
-
|
|
88
|
-
# Test invalid stores type
|
|
89
|
-
with self.assertRaises(OrionisIntegrityException):
|
|
90
|
-
Cache(stores="invalid_stores")
|
|
91
|
-
|
|
92
|
-
async def testToDictMethod(self):
|
|
93
|
-
"""
|
|
94
|
-
Test the toDict method for dictionary representation.
|
|
95
|
-
|
|
96
|
-
Ensures that the toDict method returns a dictionary containing all
|
|
97
|
-
expected keys and values.
|
|
98
|
-
|
|
99
|
-
Returns
|
|
100
|
-
-------
|
|
101
|
-
None
|
|
102
|
-
"""
|
|
103
|
-
cache = Cache()
|
|
104
|
-
cache_dict = cache.toDict()
|
|
105
|
-
|
|
106
|
-
self.assertIsInstance(cache_dict, dict)
|
|
107
|
-
self.assertEqual(cache_dict['default'], Drivers.MEMORY.value)
|
|
108
|
-
self.assertIsInstance(cache_dict['stores'], dict)
|
|
109
|
-
|
|
110
|
-
async def testStoresInstanceValidation(self):
|
|
111
|
-
"""
|
|
112
|
-
Test that the stores attribute must be an instance of Stores.
|
|
113
|
-
|
|
114
|
-
Ensures that only Stores instances are accepted for the stores
|
|
115
|
-
attribute and invalid types raise exceptions.
|
|
116
|
-
|
|
117
|
-
Returns
|
|
118
|
-
-------
|
|
119
|
-
None
|
|
120
|
-
"""
|
|
121
|
-
# Test with proper Stores instance
|
|
122
|
-
stores = Stores() # Assuming Stores has a default constructor
|
|
123
|
-
cache = Cache(stores=stores)
|
|
124
|
-
self.assertIsInstance(cache.stores, Stores)
|
|
125
|
-
|
|
126
|
-
# Test with invalid stores type
|
|
127
|
-
with self.assertRaises(OrionisIntegrityException):
|
|
128
|
-
Cache(stores={"file": "some_path"})
|
|
129
|
-
|
|
130
|
-
async def testDriverEnumConversion(self):
|
|
131
|
-
"""
|
|
132
|
-
Test conversion of Drivers enum values to string representations.
|
|
133
|
-
|
|
134
|
-
Ensures that enum members are converted to their value representations
|
|
135
|
-
when used as the default driver.
|
|
136
|
-
|
|
137
|
-
Returns
|
|
138
|
-
-------
|
|
139
|
-
None
|
|
140
|
-
"""
|
|
141
|
-
# Test with enum member
|
|
142
|
-
cache = Cache(default=Drivers.MEMORY)
|
|
143
|
-
self.assertEqual(cache.default, Drivers.MEMORY.value)
|
|
@@ -1,126 +0,0 @@
|
|
|
1
|
-
from orionis.foundation.config.cache.entities.file import File
|
|
2
|
-
from orionis.foundation.exceptions.integrity import OrionisIntegrityException
|
|
3
|
-
from orionis.test.cases.asynchronous import AsyncTestCase
|
|
4
|
-
|
|
5
|
-
class TestFoundationConfigCacheFile(AsyncTestCase):
|
|
6
|
-
"""
|
|
7
|
-
Unit tests for the File cache configuration dataclass.
|
|
8
|
-
|
|
9
|
-
These tests validate the initialization, attribute validation, and dictionary representation
|
|
10
|
-
of the File cache configuration entity.
|
|
11
|
-
"""
|
|
12
|
-
|
|
13
|
-
async def testDefaultPath(self):
|
|
14
|
-
"""
|
|
15
|
-
Test default path initialization.
|
|
16
|
-
|
|
17
|
-
Ensures that a File instance is created with the correct default path.
|
|
18
|
-
|
|
19
|
-
Returns
|
|
20
|
-
-------
|
|
21
|
-
None
|
|
22
|
-
"""
|
|
23
|
-
file_config = File()
|
|
24
|
-
self.assertEqual(file_config.path, 'storage/framework/cache/data')
|
|
25
|
-
|
|
26
|
-
async def testCustomPath(self):
|
|
27
|
-
"""
|
|
28
|
-
Test custom path initialization.
|
|
29
|
-
|
|
30
|
-
Ensures that a custom path can be set during initialization and is stored correctly.
|
|
31
|
-
|
|
32
|
-
Returns
|
|
33
|
-
-------
|
|
34
|
-
None
|
|
35
|
-
"""
|
|
36
|
-
custom_path = 'custom/cache/path'
|
|
37
|
-
file_config = File(path=custom_path)
|
|
38
|
-
self.assertEqual(file_config.path, custom_path)
|
|
39
|
-
|
|
40
|
-
async def testEmptyPathValidation(self):
|
|
41
|
-
"""
|
|
42
|
-
Test validation for empty path.
|
|
43
|
-
|
|
44
|
-
Ensures that providing an empty path raises an OrionisIntegrityException.
|
|
45
|
-
|
|
46
|
-
Returns
|
|
47
|
-
-------
|
|
48
|
-
None
|
|
49
|
-
|
|
50
|
-
Raises
|
|
51
|
-
------
|
|
52
|
-
OrionisIntegrityException
|
|
53
|
-
If the path is empty.
|
|
54
|
-
"""
|
|
55
|
-
with self.assertRaises(OrionisIntegrityException):
|
|
56
|
-
File(path="")
|
|
57
|
-
|
|
58
|
-
async def testPathTypeValidation(self):
|
|
59
|
-
"""
|
|
60
|
-
Test validation for path type.
|
|
61
|
-
|
|
62
|
-
Ensures that non-string path values raise an OrionisIntegrityException.
|
|
63
|
-
|
|
64
|
-
Returns
|
|
65
|
-
-------
|
|
66
|
-
None
|
|
67
|
-
|
|
68
|
-
Raises
|
|
69
|
-
------
|
|
70
|
-
OrionisIntegrityException
|
|
71
|
-
If the path is not a string.
|
|
72
|
-
"""
|
|
73
|
-
with self.assertRaises(OrionisIntegrityException):
|
|
74
|
-
File(path=123)
|
|
75
|
-
|
|
76
|
-
with self.assertRaises(OrionisIntegrityException):
|
|
77
|
-
File(path=None)
|
|
78
|
-
|
|
79
|
-
with self.assertRaises(OrionisIntegrityException):
|
|
80
|
-
File(path=[])
|
|
81
|
-
|
|
82
|
-
async def testToDictMethod(self):
|
|
83
|
-
"""
|
|
84
|
-
Test dictionary representation.
|
|
85
|
-
|
|
86
|
-
Ensures that the toDict method returns a dictionary with the expected path value.
|
|
87
|
-
|
|
88
|
-
Returns
|
|
89
|
-
-------
|
|
90
|
-
None
|
|
91
|
-
"""
|
|
92
|
-
file_config = File()
|
|
93
|
-
config_dict = file_config.toDict()
|
|
94
|
-
|
|
95
|
-
self.assertIsInstance(config_dict, dict)
|
|
96
|
-
self.assertEqual(config_dict['path'], 'storage/framework/cache/data')
|
|
97
|
-
|
|
98
|
-
async def testCustomPathToDict(self):
|
|
99
|
-
"""
|
|
100
|
-
Test custom path in dictionary representation.
|
|
101
|
-
|
|
102
|
-
Ensures that custom paths are properly included in the dictionary returned by toDict.
|
|
103
|
-
|
|
104
|
-
Returns
|
|
105
|
-
-------
|
|
106
|
-
None
|
|
107
|
-
"""
|
|
108
|
-
custom_path = 'another/cache/location'
|
|
109
|
-
file_config = File(path=custom_path)
|
|
110
|
-
config_dict = file_config.toDict()
|
|
111
|
-
|
|
112
|
-
self.assertEqual(config_dict['path'], custom_path)
|
|
113
|
-
|
|
114
|
-
async def testWhitespacePathHandling(self):
|
|
115
|
-
"""
|
|
116
|
-
Test handling of paths with whitespace.
|
|
117
|
-
|
|
118
|
-
Ensures that paths containing whitespace are accepted and not automatically trimmed.
|
|
119
|
-
|
|
120
|
-
Returns
|
|
121
|
-
-------
|
|
122
|
-
None
|
|
123
|
-
"""
|
|
124
|
-
spaced_path = ' storage/cache/with/space '
|
|
125
|
-
file_config = File(path=spaced_path)
|
|
126
|
-
self.assertEqual(file_config.path, spaced_path)
|