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
|
@@ -1,246 +0,0 @@
|
|
|
1
|
-
from orionis.foundation.config.logging.entities.channels import Channels
|
|
2
|
-
from orionis.foundation.config.logging.entities.stack import Stack
|
|
3
|
-
from orionis.foundation.config.logging.entities.hourly import Hourly
|
|
4
|
-
from orionis.foundation.config.logging.entities.daily import Daily
|
|
5
|
-
from orionis.foundation.config.logging.entities.weekly import Weekly
|
|
6
|
-
from orionis.foundation.config.logging.entities.monthly import Monthly
|
|
7
|
-
from orionis.foundation.config.logging.entities.chunked import Chunked
|
|
8
|
-
from orionis.foundation.exceptions.integrity import OrionisIntegrityException
|
|
9
|
-
from orionis.test.cases.asynchronous import AsyncTestCase
|
|
10
|
-
|
|
11
|
-
class TestFoundationConfigLoggingChannels(AsyncTestCase):
|
|
12
|
-
"""
|
|
13
|
-
Unit tests for the `Channels` logging configuration class.
|
|
14
|
-
|
|
15
|
-
This test class validates the correct initialization, type enforcement,
|
|
16
|
-
custom configuration, dictionary conversion, hashability, and keyword-only
|
|
17
|
-
initialization of the `Channels` class.
|
|
18
|
-
|
|
19
|
-
Methods
|
|
20
|
-
-------
|
|
21
|
-
testDefaultValues()
|
|
22
|
-
Verify that a Channels instance is initialized with the correct default values.
|
|
23
|
-
testStackValidation()
|
|
24
|
-
Ensure that only Stack instances are accepted for the stack attribute.
|
|
25
|
-
testHourlyValidation()
|
|
26
|
-
Ensure that only Hourly instances are accepted for the hourly attribute.
|
|
27
|
-
testDailyValidation()
|
|
28
|
-
Ensure that only Daily instances are accepted for the daily attribute.
|
|
29
|
-
testWeeklyValidation()
|
|
30
|
-
Ensure that only Weekly instances are accepted for the weekly attribute.
|
|
31
|
-
testMonthlyValidation()
|
|
32
|
-
Ensure that only Monthly instances are accepted for the monthly attribute.
|
|
33
|
-
testChunkedValidation()
|
|
34
|
-
Ensure that only Chunked instances are accepted for the chunked attribute.
|
|
35
|
-
testCustomConfigurations()
|
|
36
|
-
Validate that custom channel configurations are correctly assigned and validated.
|
|
37
|
-
testToDictMethod()
|
|
38
|
-
Check that the toDict method returns the correct dictionary representation.
|
|
39
|
-
testHashability()
|
|
40
|
-
Confirm that Channels instances are hashable due to unsafe_hash=True.
|
|
41
|
-
testKwOnlyInitialization()
|
|
42
|
-
Ensure that Channels enforces keyword-only initialization.
|
|
43
|
-
"""
|
|
44
|
-
|
|
45
|
-
async def testDefaultValues(self):
|
|
46
|
-
"""
|
|
47
|
-
Verify that a Channels instance is initialized with the correct default values.
|
|
48
|
-
|
|
49
|
-
Ensures that all channel configuration attributes are instances of their
|
|
50
|
-
respective classes upon default initialization.
|
|
51
|
-
|
|
52
|
-
Returns
|
|
53
|
-
-------
|
|
54
|
-
None
|
|
55
|
-
"""
|
|
56
|
-
channels = Channels()
|
|
57
|
-
self.assertIsInstance(channels.stack, Stack)
|
|
58
|
-
self.assertIsInstance(channels.hourly, Hourly)
|
|
59
|
-
self.assertIsInstance(channels.daily, Daily)
|
|
60
|
-
self.assertIsInstance(channels.weekly, Weekly)
|
|
61
|
-
self.assertIsInstance(channels.monthly, Monthly)
|
|
62
|
-
self.assertIsInstance(channels.chunked, Chunked)
|
|
63
|
-
|
|
64
|
-
async def testStackValidation(self):
|
|
65
|
-
"""
|
|
66
|
-
Ensure that only Stack instances are accepted for the stack attribute.
|
|
67
|
-
|
|
68
|
-
Raises
|
|
69
|
-
------
|
|
70
|
-
OrionisIntegrityException
|
|
71
|
-
If the stack attribute is not a Stack instance.
|
|
72
|
-
"""
|
|
73
|
-
with self.assertRaises(OrionisIntegrityException):
|
|
74
|
-
Channels(stack="not_a_stack_instance")
|
|
75
|
-
with self.assertRaises(OrionisIntegrityException):
|
|
76
|
-
Channels(stack=123)
|
|
77
|
-
try:
|
|
78
|
-
Channels(stack=Stack())
|
|
79
|
-
except OrionisIntegrityException:
|
|
80
|
-
self.fail("Valid Stack instance should not raise exception")
|
|
81
|
-
|
|
82
|
-
async def testHourlyValidation(self):
|
|
83
|
-
"""
|
|
84
|
-
Ensure that only Hourly instances are accepted for the hourly attribute.
|
|
85
|
-
|
|
86
|
-
Raises
|
|
87
|
-
------
|
|
88
|
-
OrionisIntegrityException
|
|
89
|
-
If the hourly attribute is not an Hourly instance.
|
|
90
|
-
"""
|
|
91
|
-
with self.assertRaises(OrionisIntegrityException):
|
|
92
|
-
Channels(hourly="not_an_hourly_instance")
|
|
93
|
-
try:
|
|
94
|
-
Channels(hourly=Hourly())
|
|
95
|
-
except OrionisIntegrityException:
|
|
96
|
-
self.fail("Valid Hourly instance should not raise exception")
|
|
97
|
-
|
|
98
|
-
async def testDailyValidation(self):
|
|
99
|
-
"""
|
|
100
|
-
Ensure that only Daily instances are accepted for the daily attribute.
|
|
101
|
-
|
|
102
|
-
Raises
|
|
103
|
-
------
|
|
104
|
-
OrionisIntegrityException
|
|
105
|
-
If the daily attribute is not a Daily instance.
|
|
106
|
-
"""
|
|
107
|
-
with self.assertRaises(OrionisIntegrityException):
|
|
108
|
-
Channels(daily="not_a_daily_instance")
|
|
109
|
-
try:
|
|
110
|
-
Channels(daily=Daily())
|
|
111
|
-
except OrionisIntegrityException:
|
|
112
|
-
self.fail("Valid Daily instance should not raise exception")
|
|
113
|
-
|
|
114
|
-
async def testWeeklyValidation(self):
|
|
115
|
-
"""
|
|
116
|
-
Ensure that only Weekly instances are accepted for the weekly attribute.
|
|
117
|
-
|
|
118
|
-
Raises
|
|
119
|
-
------
|
|
120
|
-
OrionisIntegrityException
|
|
121
|
-
If the weekly attribute is not a Weekly instance.
|
|
122
|
-
"""
|
|
123
|
-
with self.assertRaises(OrionisIntegrityException):
|
|
124
|
-
Channels(weekly="not_a_weekly_instance")
|
|
125
|
-
try:
|
|
126
|
-
Channels(weekly=Weekly())
|
|
127
|
-
except OrionisIntegrityException:
|
|
128
|
-
self.fail("Valid Weekly instance should not raise exception")
|
|
129
|
-
|
|
130
|
-
async def testMonthlyValidation(self):
|
|
131
|
-
"""
|
|
132
|
-
Ensure that only Monthly instances are accepted for the monthly attribute.
|
|
133
|
-
|
|
134
|
-
Raises
|
|
135
|
-
------
|
|
136
|
-
OrionisIntegrityException
|
|
137
|
-
If the monthly attribute is not a Monthly instance.
|
|
138
|
-
"""
|
|
139
|
-
with self.assertRaises(OrionisIntegrityException):
|
|
140
|
-
Channels(monthly="not_a_monthly_instance")
|
|
141
|
-
try:
|
|
142
|
-
Channels(monthly=Monthly())
|
|
143
|
-
except OrionisIntegrityException:
|
|
144
|
-
self.fail("Valid Monthly instance should not raise exception")
|
|
145
|
-
|
|
146
|
-
async def testChunkedValidation(self):
|
|
147
|
-
"""
|
|
148
|
-
Ensure that only Chunked instances are accepted for the chunked attribute.
|
|
149
|
-
|
|
150
|
-
Raises
|
|
151
|
-
------
|
|
152
|
-
OrionisIntegrityException
|
|
153
|
-
If the chunked attribute is not a Chunked instance.
|
|
154
|
-
"""
|
|
155
|
-
with self.assertRaises(OrionisIntegrityException):
|
|
156
|
-
Channels(chunked="not_a_chunked_instance")
|
|
157
|
-
try:
|
|
158
|
-
Channels(chunked=Chunked())
|
|
159
|
-
except OrionisIntegrityException:
|
|
160
|
-
self.fail("Valid Chunked instance should not raise exception")
|
|
161
|
-
|
|
162
|
-
async def testCustomConfigurations(self):
|
|
163
|
-
"""
|
|
164
|
-
Validate that custom channel configurations are correctly assigned and validated.
|
|
165
|
-
|
|
166
|
-
Ensures that custom channel instances are properly set and their properties
|
|
167
|
-
are accurately assigned.
|
|
168
|
-
|
|
169
|
-
Returns
|
|
170
|
-
-------
|
|
171
|
-
None
|
|
172
|
-
"""
|
|
173
|
-
custom_stack = Stack(path="custom/stack.log")
|
|
174
|
-
custom_hourly = Hourly(path="custom/hourly.log")
|
|
175
|
-
custom_daily = Daily(path="custom/daily.log")
|
|
176
|
-
custom_weekly = Weekly(path="custom/weekly.log")
|
|
177
|
-
custom_monthly = Monthly(path="custom/monthly.log")
|
|
178
|
-
custom_chunked = Chunked(path="custom/chunked.log")
|
|
179
|
-
|
|
180
|
-
channels = Channels(
|
|
181
|
-
stack=custom_stack,
|
|
182
|
-
hourly=custom_hourly,
|
|
183
|
-
daily=custom_daily,
|
|
184
|
-
weekly=custom_weekly,
|
|
185
|
-
monthly=custom_monthly,
|
|
186
|
-
chunked=custom_chunked
|
|
187
|
-
)
|
|
188
|
-
self.assertEqual(channels.stack.path, "custom/stack.log")
|
|
189
|
-
self.assertEqual(channels.hourly.path, "custom/hourly.log")
|
|
190
|
-
self.assertEqual(channels.daily.path, "custom/daily.log")
|
|
191
|
-
self.assertEqual(channels.weekly.path, "custom/weekly.log")
|
|
192
|
-
self.assertEqual(channels.monthly.path, "custom/monthly.log")
|
|
193
|
-
self.assertEqual(channels.chunked.path, "custom/chunked.log")
|
|
194
|
-
|
|
195
|
-
async def testToDictMethod(self):
|
|
196
|
-
"""
|
|
197
|
-
Check that the toDict method returns the correct dictionary representation.
|
|
198
|
-
|
|
199
|
-
Ensures that the `toDict` method produces a dictionary with the expected
|
|
200
|
-
structure and types for each channel.
|
|
201
|
-
|
|
202
|
-
Returns
|
|
203
|
-
-------
|
|
204
|
-
None
|
|
205
|
-
"""
|
|
206
|
-
channels = Channels()
|
|
207
|
-
channels_dict = channels.toDict()
|
|
208
|
-
self.assertIsInstance(channels_dict, dict)
|
|
209
|
-
self.assertIsInstance(channels_dict['stack'], dict)
|
|
210
|
-
self.assertIsInstance(channels_dict['hourly'], dict)
|
|
211
|
-
self.assertIsInstance(channels_dict['daily'], dict)
|
|
212
|
-
self.assertIsInstance(channels_dict['weekly'], dict)
|
|
213
|
-
self.assertIsInstance(channels_dict['monthly'], dict)
|
|
214
|
-
self.assertIsInstance(channels_dict['chunked'], dict)
|
|
215
|
-
|
|
216
|
-
async def testHashability(self):
|
|
217
|
-
"""
|
|
218
|
-
Confirm that Channels instances are hashable due to unsafe_hash=True.
|
|
219
|
-
|
|
220
|
-
Ensures that Channels objects can be used in sets and as dictionary keys.
|
|
221
|
-
|
|
222
|
-
Returns
|
|
223
|
-
-------
|
|
224
|
-
None
|
|
225
|
-
"""
|
|
226
|
-
channels1 = Channels()
|
|
227
|
-
channels2 = Channels()
|
|
228
|
-
channels_set = {channels1, channels2}
|
|
229
|
-
|
|
230
|
-
self.assertEqual(len(channels_set), 1)
|
|
231
|
-
|
|
232
|
-
custom_channels = Channels(stack=Stack(path="custom.log"))
|
|
233
|
-
channels_set.add(custom_channels)
|
|
234
|
-
self.assertEqual(len(channels_set), 2)
|
|
235
|
-
|
|
236
|
-
async def testKwOnlyInitialization(self):
|
|
237
|
-
"""
|
|
238
|
-
Ensure that Channels enforces keyword-only initialization.
|
|
239
|
-
|
|
240
|
-
Raises
|
|
241
|
-
------
|
|
242
|
-
TypeError
|
|
243
|
-
If positional arguments are used instead of keyword arguments.
|
|
244
|
-
"""
|
|
245
|
-
with self.assertRaises(TypeError):
|
|
246
|
-
Channels(Stack(), Hourly(), Daily(), Weekly(), Monthly(), Chunked())
|
|
@@ -1,217 +0,0 @@
|
|
|
1
|
-
from orionis.foundation.config.logging.entities.chunked import Chunked
|
|
2
|
-
from orionis.foundation.config.logging.enums.levels import Level
|
|
3
|
-
from orionis.foundation.exceptions.integrity import OrionisIntegrityException
|
|
4
|
-
from orionis.test.cases.asynchronous import AsyncTestCase
|
|
5
|
-
|
|
6
|
-
class TestFoundationConfigLoggingChunked(AsyncTestCase):
|
|
7
|
-
"""
|
|
8
|
-
Test cases for the Chunked logging configuration class.
|
|
9
|
-
|
|
10
|
-
Notes
|
|
11
|
-
-----
|
|
12
|
-
These tests validate the integrity, default values, and behavior of the
|
|
13
|
-
`Chunked` logging configuration entity, including its attributes and methods.
|
|
14
|
-
"""
|
|
15
|
-
|
|
16
|
-
async def testDefaultValues(self):
|
|
17
|
-
"""
|
|
18
|
-
Test default values of Chunked instance.
|
|
19
|
-
|
|
20
|
-
Ensures that a `Chunked` instance is created with the correct default values
|
|
21
|
-
for `path`, `level`, `mb_size`, and `files`.
|
|
22
|
-
|
|
23
|
-
Returns
|
|
24
|
-
-------
|
|
25
|
-
None
|
|
26
|
-
"""
|
|
27
|
-
chunked = Chunked()
|
|
28
|
-
self.assertEqual(chunked.path, "storage/log/chunked.log")
|
|
29
|
-
self.assertEqual(chunked.level, Level.INFO.value)
|
|
30
|
-
self.assertEqual(chunked.mb_size, 10)
|
|
31
|
-
self.assertEqual(chunked.files, 5)
|
|
32
|
-
|
|
33
|
-
async def testPathValidation(self):
|
|
34
|
-
"""
|
|
35
|
-
Test validation of the `path` attribute.
|
|
36
|
-
|
|
37
|
-
Verifies that empty or non-string paths raise `OrionisIntegrityException`.
|
|
38
|
-
Also checks that a valid path does not raise an exception.
|
|
39
|
-
|
|
40
|
-
Returns
|
|
41
|
-
-------
|
|
42
|
-
None
|
|
43
|
-
"""
|
|
44
|
-
with self.assertRaises(OrionisIntegrityException):
|
|
45
|
-
Chunked(path="")
|
|
46
|
-
with self.assertRaises(OrionisIntegrityException):
|
|
47
|
-
Chunked(path=123)
|
|
48
|
-
try:
|
|
49
|
-
Chunked(path="custom/log/path.log")
|
|
50
|
-
except OrionisIntegrityException:
|
|
51
|
-
self.fail("Valid path should not raise exception")
|
|
52
|
-
|
|
53
|
-
async def testLevelValidation(self):
|
|
54
|
-
"""
|
|
55
|
-
Test validation of the `level` attribute.
|
|
56
|
-
|
|
57
|
-
Checks that the `level` can be set using a string, integer, or enum,
|
|
58
|
-
and that invalid values raise `OrionisIntegrityException`.
|
|
59
|
-
|
|
60
|
-
Returns
|
|
61
|
-
-------
|
|
62
|
-
None
|
|
63
|
-
"""
|
|
64
|
-
# Test string level
|
|
65
|
-
chunked = Chunked(level="debug")
|
|
66
|
-
self.assertEqual(chunked.level, Level.DEBUG.value)
|
|
67
|
-
|
|
68
|
-
# Test int level
|
|
69
|
-
chunked = Chunked(level=Level.WARNING.value)
|
|
70
|
-
self.assertEqual(chunked.level, Level.WARNING.value)
|
|
71
|
-
|
|
72
|
-
# Test enum level
|
|
73
|
-
chunked = Chunked(level=Level.ERROR)
|
|
74
|
-
self.assertEqual(chunked.level, Level.ERROR.value)
|
|
75
|
-
|
|
76
|
-
# Test invalid cases
|
|
77
|
-
with self.assertRaises(OrionisIntegrityException):
|
|
78
|
-
Chunked(level="invalid")
|
|
79
|
-
with self.assertRaises(OrionisIntegrityException):
|
|
80
|
-
Chunked(level=999)
|
|
81
|
-
with self.assertRaises(OrionisIntegrityException):
|
|
82
|
-
Chunked(level=[])
|
|
83
|
-
|
|
84
|
-
async def testMbSizeValidation(self):
|
|
85
|
-
"""
|
|
86
|
-
Test validation of the `mb_size` attribute.
|
|
87
|
-
|
|
88
|
-
Returns
|
|
89
|
-
-------
|
|
90
|
-
None
|
|
91
|
-
"""
|
|
92
|
-
chunked = Chunked(mb_size=10)
|
|
93
|
-
self.assertEqual(chunked.mb_size, 10)
|
|
94
|
-
|
|
95
|
-
chunked = Chunked(mb_size=1000)
|
|
96
|
-
self.assertEqual(chunked.mb_size, 1000)
|
|
97
|
-
|
|
98
|
-
with self.assertRaises(OrionisIntegrityException):
|
|
99
|
-
chunked = Chunked(mb_size=2048)
|
|
100
|
-
self.assertEqual(chunked.mb_size, 2048)
|
|
101
|
-
|
|
102
|
-
async def testFilesValidation(self):
|
|
103
|
-
"""
|
|
104
|
-
Test validation of the `files` attribute.
|
|
105
|
-
|
|
106
|
-
Ensures that valid integer values are accepted, and invalid values raise
|
|
107
|
-
`OrionisIntegrityException`.
|
|
108
|
-
|
|
109
|
-
Returns
|
|
110
|
-
-------
|
|
111
|
-
None
|
|
112
|
-
"""
|
|
113
|
-
# Test valid values
|
|
114
|
-
try:
|
|
115
|
-
Chunked(files=1)
|
|
116
|
-
Chunked(files=10)
|
|
117
|
-
except OrionisIntegrityException:
|
|
118
|
-
self.fail("Valid files count should not raise exception")
|
|
119
|
-
|
|
120
|
-
# Test invalid values
|
|
121
|
-
with self.assertRaises(OrionisIntegrityException):
|
|
122
|
-
Chunked(files=0)
|
|
123
|
-
with self.assertRaises(OrionisIntegrityException):
|
|
124
|
-
Chunked(files=-1)
|
|
125
|
-
with self.assertRaises(OrionisIntegrityException):
|
|
126
|
-
Chunked(files="5")
|
|
127
|
-
|
|
128
|
-
async def testWhitespaceHandling(self):
|
|
129
|
-
"""
|
|
130
|
-
Test handling of whitespace in `path` and `level` attributes.
|
|
131
|
-
|
|
132
|
-
Returns
|
|
133
|
-
-------
|
|
134
|
-
None
|
|
135
|
-
"""
|
|
136
|
-
with self.assertRaises(OrionisIntegrityException):
|
|
137
|
-
chunked = Chunked(path=" logs/app.log ", level=" debug ")
|
|
138
|
-
self.assertEqual(chunked.path, " logs/app.log ")
|
|
139
|
-
self.assertEqual(chunked.level, Level.DEBUG.value)
|
|
140
|
-
|
|
141
|
-
async def testToDictMethod(self):
|
|
142
|
-
"""
|
|
143
|
-
Test the `toDict` method.
|
|
144
|
-
|
|
145
|
-
Ensures that `toDict` returns a dictionary representation of the instance
|
|
146
|
-
with correct values.
|
|
147
|
-
|
|
148
|
-
Returns
|
|
149
|
-
-------
|
|
150
|
-
None
|
|
151
|
-
"""
|
|
152
|
-
chunked = Chunked()
|
|
153
|
-
chunked_dict = chunked.toDict()
|
|
154
|
-
|
|
155
|
-
self.assertIsInstance(chunked_dict, dict)
|
|
156
|
-
self.assertEqual(chunked_dict['path'], "storage/log/chunked.log")
|
|
157
|
-
self.assertEqual(chunked_dict['level'], Level.INFO.value)
|
|
158
|
-
self.assertEqual(chunked_dict['mb_size'], 10)
|
|
159
|
-
self.assertEqual(chunked_dict['files'], 5)
|
|
160
|
-
|
|
161
|
-
async def testCustomValuesToDict(self):
|
|
162
|
-
"""
|
|
163
|
-
Test `toDict` with custom values.
|
|
164
|
-
|
|
165
|
-
Ensures that custom values provided to the constructor are correctly
|
|
166
|
-
reflected in the dictionary representation.
|
|
167
|
-
|
|
168
|
-
Returns
|
|
169
|
-
-------
|
|
170
|
-
None
|
|
171
|
-
"""
|
|
172
|
-
custom_chunked = Chunked(
|
|
173
|
-
path="custom/logs/app.log",
|
|
174
|
-
level="warning",
|
|
175
|
-
mb_size=20,
|
|
176
|
-
files=10
|
|
177
|
-
)
|
|
178
|
-
chunked_dict = custom_chunked.toDict()
|
|
179
|
-
self.assertEqual(chunked_dict['path'], "custom/logs/app.log")
|
|
180
|
-
self.assertEqual(chunked_dict['level'], 30)
|
|
181
|
-
self.assertEqual(chunked_dict['mb_size'], 20)
|
|
182
|
-
self.assertEqual(chunked_dict['files'], 10)
|
|
183
|
-
|
|
184
|
-
async def testHashability(self):
|
|
185
|
-
"""
|
|
186
|
-
Test hashability of Chunked instances.
|
|
187
|
-
|
|
188
|
-
Ensures that `Chunked` instances are hashable and can be used in sets,
|
|
189
|
-
due to `unsafe_hash=True`.
|
|
190
|
-
|
|
191
|
-
Returns
|
|
192
|
-
-------
|
|
193
|
-
None
|
|
194
|
-
"""
|
|
195
|
-
chunked1 = Chunked()
|
|
196
|
-
chunked2 = Chunked()
|
|
197
|
-
chunked_set = {chunked1, chunked2}
|
|
198
|
-
|
|
199
|
-
self.assertEqual(len(chunked_set), 1)
|
|
200
|
-
|
|
201
|
-
custom_chunked = Chunked(path="custom.log")
|
|
202
|
-
chunked_set.add(custom_chunked)
|
|
203
|
-
self.assertEqual(len(chunked_set), 2)
|
|
204
|
-
|
|
205
|
-
async def testKwOnlyInitialization(self):
|
|
206
|
-
"""
|
|
207
|
-
Test enforcement of keyword-only initialization.
|
|
208
|
-
|
|
209
|
-
Ensures that `Chunked` cannot be initialized with positional arguments,
|
|
210
|
-
and raises a `TypeError` if attempted.
|
|
211
|
-
|
|
212
|
-
Returns
|
|
213
|
-
-------
|
|
214
|
-
None
|
|
215
|
-
"""
|
|
216
|
-
with self.assertRaises(TypeError):
|
|
217
|
-
Chunked("path.log", "info", 10, 5)
|
|
@@ -1,220 +0,0 @@
|
|
|
1
|
-
from datetime import time
|
|
2
|
-
from orionis.foundation.config.logging.entities.daily import Daily
|
|
3
|
-
from orionis.foundation.config.logging.enums.levels import Level
|
|
4
|
-
from orionis.foundation.exceptions.integrity import OrionisIntegrityException
|
|
5
|
-
from orionis.test.cases.asynchronous import AsyncTestCase
|
|
6
|
-
|
|
7
|
-
class TestFoundationConfigLoggingDaily(AsyncTestCase):
|
|
8
|
-
"""
|
|
9
|
-
Test cases for the Daily logging configuration class.
|
|
10
|
-
|
|
11
|
-
This class contains unit tests for the `Daily` logging configuration entity,
|
|
12
|
-
validating its default values, attribute validation, dictionary conversion,
|
|
13
|
-
hashability, and keyword-only initialization.
|
|
14
|
-
"""
|
|
15
|
-
|
|
16
|
-
async def testDefaultValues(self):
|
|
17
|
-
"""
|
|
18
|
-
Test creation of Daily instance with default values.
|
|
19
|
-
|
|
20
|
-
Ensures that the default path, level, retention_days, and at time
|
|
21
|
-
are set as expected.
|
|
22
|
-
|
|
23
|
-
Returns
|
|
24
|
-
-------
|
|
25
|
-
None
|
|
26
|
-
"""
|
|
27
|
-
daily = Daily()
|
|
28
|
-
self.assertEqual(daily.path, "storage/log/daily.log")
|
|
29
|
-
self.assertEqual(daily.level, Level.INFO.value)
|
|
30
|
-
self.assertEqual(daily.retention_days, 7)
|
|
31
|
-
self.assertEqual(daily.at, "00:00")
|
|
32
|
-
|
|
33
|
-
async def testPathValidation(self):
|
|
34
|
-
"""
|
|
35
|
-
Test validation of the path attribute.
|
|
36
|
-
|
|
37
|
-
Verifies that empty or non-string paths raise exceptions, and that
|
|
38
|
-
valid paths are accepted.
|
|
39
|
-
|
|
40
|
-
Returns
|
|
41
|
-
-------
|
|
42
|
-
None
|
|
43
|
-
"""
|
|
44
|
-
with self.assertRaises(OrionisIntegrityException):
|
|
45
|
-
Daily(path="")
|
|
46
|
-
with self.assertRaises(OrionisIntegrityException):
|
|
47
|
-
Daily(path=123)
|
|
48
|
-
try:
|
|
49
|
-
Daily(path="custom/log/path.log")
|
|
50
|
-
except OrionisIntegrityException:
|
|
51
|
-
self.fail("Valid path should not raise exception")
|
|
52
|
-
|
|
53
|
-
async def testLevelValidation(self):
|
|
54
|
-
"""
|
|
55
|
-
Test validation of the level attribute.
|
|
56
|
-
|
|
57
|
-
Checks that string, integer, and enum values are accepted for level,
|
|
58
|
-
and that invalid values raise exceptions.
|
|
59
|
-
|
|
60
|
-
Returns
|
|
61
|
-
-------
|
|
62
|
-
None
|
|
63
|
-
"""
|
|
64
|
-
# Test string level
|
|
65
|
-
daily = Daily(level="debug")
|
|
66
|
-
self.assertEqual(daily.level, Level.DEBUG.value)
|
|
67
|
-
|
|
68
|
-
# Test int level
|
|
69
|
-
daily = Daily(level=Level.WARNING.value)
|
|
70
|
-
self.assertEqual(daily.level, Level.WARNING.value)
|
|
71
|
-
|
|
72
|
-
# Test enum level
|
|
73
|
-
daily = Daily(level=Level.ERROR)
|
|
74
|
-
self.assertEqual(daily.level, Level.ERROR.value)
|
|
75
|
-
|
|
76
|
-
# Test invalid cases
|
|
77
|
-
with self.assertRaises(OrionisIntegrityException):
|
|
78
|
-
Daily(level="invalid")
|
|
79
|
-
with self.assertRaises(OrionisIntegrityException):
|
|
80
|
-
Daily(level=999)
|
|
81
|
-
with self.assertRaises(OrionisIntegrityException):
|
|
82
|
-
Daily(level=[])
|
|
83
|
-
|
|
84
|
-
async def testRetentionDaysValidation(self):
|
|
85
|
-
"""
|
|
86
|
-
Test validation of the retention_days attribute.
|
|
87
|
-
|
|
88
|
-
Ensures that valid values are accepted and invalid values raise exceptions.
|
|
89
|
-
|
|
90
|
-
Returns
|
|
91
|
-
-------
|
|
92
|
-
None
|
|
93
|
-
"""
|
|
94
|
-
# Test valid values
|
|
95
|
-
try:
|
|
96
|
-
Daily(retention_days=1)
|
|
97
|
-
Daily(retention_days=90)
|
|
98
|
-
Daily(retention_days=30)
|
|
99
|
-
except OrionisIntegrityException:
|
|
100
|
-
self.fail("Valid retention_days should not raise exception")
|
|
101
|
-
|
|
102
|
-
# Test invalid values
|
|
103
|
-
with self.assertRaises(OrionisIntegrityException):
|
|
104
|
-
Daily(retention_days=0)
|
|
105
|
-
with self.assertRaises(OrionisIntegrityException):
|
|
106
|
-
Daily(retention_days=91)
|
|
107
|
-
with self.assertRaises(OrionisIntegrityException):
|
|
108
|
-
Daily(retention_days=-1)
|
|
109
|
-
with self.assertRaises(OrionisIntegrityException):
|
|
110
|
-
Daily(retention_days="7")
|
|
111
|
-
|
|
112
|
-
async def testAtTimeValidation(self):
|
|
113
|
-
"""
|
|
114
|
-
Test validation and conversion of the at attribute.
|
|
115
|
-
|
|
116
|
-
Checks that a `datetime.time` object is properly converted and that
|
|
117
|
-
invalid types raise exceptions.
|
|
118
|
-
|
|
119
|
-
Returns
|
|
120
|
-
-------
|
|
121
|
-
None
|
|
122
|
-
"""
|
|
123
|
-
# Test time object
|
|
124
|
-
daily = Daily(at=time(12, 30))
|
|
125
|
-
self.assertEqual(daily.at, "12:30")
|
|
126
|
-
|
|
127
|
-
# Test invalid type
|
|
128
|
-
with self.assertRaises(OrionisIntegrityException):
|
|
129
|
-
Daily(at="12:00:00")
|
|
130
|
-
with self.assertRaises(OrionisIntegrityException):
|
|
131
|
-
Daily(at=1200)
|
|
132
|
-
|
|
133
|
-
async def testWhitespaceHandling(self):
|
|
134
|
-
"""
|
|
135
|
-
Test handling of whitespace in path and level attributes.
|
|
136
|
-
|
|
137
|
-
Returns
|
|
138
|
-
-------
|
|
139
|
-
None
|
|
140
|
-
"""
|
|
141
|
-
|
|
142
|
-
with self.assertRaises(OrionisIntegrityException):
|
|
143
|
-
daily = Daily(path=" logs/app.log ", level=" debug ")
|
|
144
|
-
self.assertEqual(daily.path, " logs/app.log ")
|
|
145
|
-
self.assertEqual(daily.level, Level.DEBUG.value)
|
|
146
|
-
|
|
147
|
-
async def testToDictMethod(self):
|
|
148
|
-
"""
|
|
149
|
-
Test the toDict method for correct dictionary representation.
|
|
150
|
-
|
|
151
|
-
Ensures that the dictionary returned by toDict contains the correct
|
|
152
|
-
default values.
|
|
153
|
-
|
|
154
|
-
Returns
|
|
155
|
-
-------
|
|
156
|
-
None
|
|
157
|
-
"""
|
|
158
|
-
daily = Daily()
|
|
159
|
-
daily_dict = daily.toDict()
|
|
160
|
-
|
|
161
|
-
self.assertIsInstance(daily_dict, dict)
|
|
162
|
-
self.assertEqual(daily_dict['path'], "storage/log/daily.log")
|
|
163
|
-
self.assertEqual(daily_dict['level'], Level.INFO.value)
|
|
164
|
-
self.assertEqual(daily_dict['retention_days'], 7)
|
|
165
|
-
self.assertEqual(daily_dict['at'], "00:00")
|
|
166
|
-
|
|
167
|
-
async def testCustomValuesToDict(self):
|
|
168
|
-
"""
|
|
169
|
-
Test toDict method with custom values.
|
|
170
|
-
|
|
171
|
-
Ensures that custom values are correctly represented in the dictionary.
|
|
172
|
-
|
|
173
|
-
Returns
|
|
174
|
-
-------
|
|
175
|
-
None
|
|
176
|
-
"""
|
|
177
|
-
custom_daily = Daily(
|
|
178
|
-
path="custom/logs/app.log",
|
|
179
|
-
level="warning",
|
|
180
|
-
retention_days=14,
|
|
181
|
-
at=time(23, 59)
|
|
182
|
-
)
|
|
183
|
-
daily_dict = custom_daily.toDict()
|
|
184
|
-
self.assertEqual(daily_dict['path'], "custom/logs/app.log")
|
|
185
|
-
self.assertEqual(daily_dict['level'], Level.WARNING.value)
|
|
186
|
-
self.assertEqual(daily_dict['retention_days'], 14)
|
|
187
|
-
self.assertEqual(daily_dict['at'], "23:59")
|
|
188
|
-
|
|
189
|
-
async def testHashability(self):
|
|
190
|
-
"""
|
|
191
|
-
Test hashability of Daily instances.
|
|
192
|
-
|
|
193
|
-
Ensures that Daily instances are hashable and can be used in sets.
|
|
194
|
-
|
|
195
|
-
Returns
|
|
196
|
-
-------
|
|
197
|
-
None
|
|
198
|
-
"""
|
|
199
|
-
daily1 = Daily()
|
|
200
|
-
daily2 = Daily()
|
|
201
|
-
daily_set = {daily1, daily2}
|
|
202
|
-
|
|
203
|
-
self.assertEqual(len(daily_set), 1)
|
|
204
|
-
|
|
205
|
-
custom_daily = Daily(path="custom.log")
|
|
206
|
-
daily_set.add(custom_daily)
|
|
207
|
-
self.assertEqual(len(daily_set), 2)
|
|
208
|
-
|
|
209
|
-
async def testKwOnlyInitialization(self):
|
|
210
|
-
"""
|
|
211
|
-
Test enforcement of keyword-only initialization.
|
|
212
|
-
|
|
213
|
-
Ensures that positional arguments raise a TypeError.
|
|
214
|
-
|
|
215
|
-
Returns
|
|
216
|
-
-------
|
|
217
|
-
None
|
|
218
|
-
"""
|
|
219
|
-
with self.assertRaises(TypeError):
|
|
220
|
-
Daily("path.log", "info", 7, time(0, 0))
|