orionis 0.545.0__py3-none-any.whl → 0.547.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/console/request/cli_request.py +2 -2
- 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/foundation/providers/cli_request_provider.py +44 -0
- 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.545.0.dist-info → orionis-0.547.0.dist-info}/METADATA +1 -1
- {orionis-0.545.0.dist-info → orionis-0.547.0.dist-info}/RECORD +17 -160
- {orionis-0.545.0.dist-info → orionis-0.547.0.dist-info}/top_level.txt +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.545.0.dist-info → orionis-0.547.0.dist-info}/WHEEL +0 -0
- {orionis-0.545.0.dist-info → orionis-0.547.0.dist-info}/licenses/LICENCE +0 -0
- {orionis-0.545.0.dist-info → orionis-0.547.0.dist-info}/zip-safe +0 -0
|
@@ -1,196 +0,0 @@
|
|
|
1
|
-
from orionis.foundation.config.logging.entities.hourly import Hourly
|
|
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 TestFoundationConfigLoggingHourly(AsyncTestCase):
|
|
7
|
-
"""
|
|
8
|
-
Test cases for the Hourly logging configuration class.
|
|
9
|
-
|
|
10
|
-
This class contains unit tests for the `Hourly` logging configuration entity,
|
|
11
|
-
verifying its default values, attribute validation, dictionary representation,
|
|
12
|
-
hashability, and keyword-only initialization enforcement.
|
|
13
|
-
"""
|
|
14
|
-
|
|
15
|
-
async def testDefaultValues(self):
|
|
16
|
-
"""
|
|
17
|
-
Test that Hourly instance is created with correct default values.
|
|
18
|
-
|
|
19
|
-
Verifies that the default `path`, `level`, and `retention_hours` attributes
|
|
20
|
-
of the Hourly instance match the expected values.
|
|
21
|
-
|
|
22
|
-
Returns
|
|
23
|
-
-------
|
|
24
|
-
None
|
|
25
|
-
"""
|
|
26
|
-
hourly = Hourly()
|
|
27
|
-
self.assertEqual(hourly.path, "storage/log/hourly.log")
|
|
28
|
-
self.assertEqual(hourly.level, Level.INFO.value)
|
|
29
|
-
self.assertEqual(hourly.retention_hours, 24)
|
|
30
|
-
|
|
31
|
-
async def testPathValidation(self):
|
|
32
|
-
"""
|
|
33
|
-
Test path attribute validation.
|
|
34
|
-
|
|
35
|
-
Ensures that invalid values for the `path` attribute, such as empty strings
|
|
36
|
-
or non-string types, raise an `OrionisIntegrityException`. Also verifies that
|
|
37
|
-
valid paths do not raise exceptions.
|
|
38
|
-
|
|
39
|
-
Returns
|
|
40
|
-
-------
|
|
41
|
-
None
|
|
42
|
-
"""
|
|
43
|
-
with self.assertRaises(OrionisIntegrityException):
|
|
44
|
-
Hourly(path="")
|
|
45
|
-
with self.assertRaises(OrionisIntegrityException):
|
|
46
|
-
Hourly(path=123)
|
|
47
|
-
try:
|
|
48
|
-
Hourly(path="custom/log/path.log")
|
|
49
|
-
except OrionisIntegrityException:
|
|
50
|
-
self.fail("Valid path should not raise exception")
|
|
51
|
-
|
|
52
|
-
async def testLevelValidation(self):
|
|
53
|
-
"""
|
|
54
|
-
Test level attribute validation with different input types.
|
|
55
|
-
|
|
56
|
-
Checks that the `level` attribute accepts string, integer, and enum values,
|
|
57
|
-
and that invalid values raise an `OrionisIntegrityException`.
|
|
58
|
-
|
|
59
|
-
Returns
|
|
60
|
-
-------
|
|
61
|
-
None
|
|
62
|
-
"""
|
|
63
|
-
# Test string level
|
|
64
|
-
hourly = Hourly(level="debug")
|
|
65
|
-
self.assertEqual(hourly.level, Level.DEBUG.value)
|
|
66
|
-
|
|
67
|
-
# Test int level
|
|
68
|
-
hourly = Hourly(level=Level.WARNING.value)
|
|
69
|
-
self.assertEqual(hourly.level, Level.WARNING.value)
|
|
70
|
-
|
|
71
|
-
# Test enum level
|
|
72
|
-
hourly = Hourly(level=Level.ERROR)
|
|
73
|
-
self.assertEqual(hourly.level, Level.ERROR.value)
|
|
74
|
-
|
|
75
|
-
# Test invalid cases
|
|
76
|
-
with self.assertRaises(OrionisIntegrityException):
|
|
77
|
-
Hourly(level="invalid")
|
|
78
|
-
with self.assertRaises(OrionisIntegrityException):
|
|
79
|
-
Hourly(level=999)
|
|
80
|
-
with self.assertRaises(OrionisIntegrityException):
|
|
81
|
-
Hourly(level=[])
|
|
82
|
-
|
|
83
|
-
async def testRetentionHoursValidation(self):
|
|
84
|
-
"""
|
|
85
|
-
Test retention_hours attribute validation.
|
|
86
|
-
|
|
87
|
-
Ensures that valid values for `retention_hours` are accepted and invalid
|
|
88
|
-
values raise an `OrionisIntegrityException`.
|
|
89
|
-
|
|
90
|
-
Returns
|
|
91
|
-
-------
|
|
92
|
-
None
|
|
93
|
-
"""
|
|
94
|
-
# Test valid values
|
|
95
|
-
try:
|
|
96
|
-
Hourly(retention_hours=1)
|
|
97
|
-
Hourly(retention_hours=168)
|
|
98
|
-
Hourly(retention_hours=72)
|
|
99
|
-
except OrionisIntegrityException:
|
|
100
|
-
self.fail("Valid retention_hours should not raise exception")
|
|
101
|
-
|
|
102
|
-
# Test invalid values
|
|
103
|
-
with self.assertRaises(OrionisIntegrityException):
|
|
104
|
-
Hourly(retention_hours=0)
|
|
105
|
-
with self.assertRaises(OrionisIntegrityException):
|
|
106
|
-
Hourly(retention_hours=169)
|
|
107
|
-
with self.assertRaises(OrionisIntegrityException):
|
|
108
|
-
Hourly(retention_hours=-1)
|
|
109
|
-
with self.assertRaises(OrionisIntegrityException):
|
|
110
|
-
Hourly(retention_hours="24")
|
|
111
|
-
|
|
112
|
-
async def testWhitespaceHandling(self):
|
|
113
|
-
"""
|
|
114
|
-
Test whitespace handling in path and level attributes.
|
|
115
|
-
|
|
116
|
-
Returns
|
|
117
|
-
-------
|
|
118
|
-
None
|
|
119
|
-
"""
|
|
120
|
-
|
|
121
|
-
with self.assertRaises(OrionisIntegrityException):
|
|
122
|
-
hourly = Hourly(path=" logs/app.log ", level=" debug ")
|
|
123
|
-
self.assertEqual(hourly.path, " logs/app.log ")
|
|
124
|
-
self.assertEqual(hourly.level, Level.DEBUG.value)
|
|
125
|
-
|
|
126
|
-
async def testToDictMethod(self):
|
|
127
|
-
"""
|
|
128
|
-
Test that toDict returns proper dictionary representation.
|
|
129
|
-
|
|
130
|
-
Ensures that the `toDict` method returns a dictionary with the correct
|
|
131
|
-
attribute values.
|
|
132
|
-
|
|
133
|
-
Returns
|
|
134
|
-
-------
|
|
135
|
-
None
|
|
136
|
-
"""
|
|
137
|
-
hourly = Hourly()
|
|
138
|
-
hourly_dict = hourly.toDict()
|
|
139
|
-
self.assertIsInstance(hourly_dict, dict)
|
|
140
|
-
self.assertEqual(hourly_dict['path'], "storage/log/hourly.log")
|
|
141
|
-
self.assertEqual(hourly_dict['level'], Level.INFO.value)
|
|
142
|
-
self.assertEqual(hourly_dict['retention_hours'], 24)
|
|
143
|
-
|
|
144
|
-
async def testCustomValuesToDict(self):
|
|
145
|
-
"""
|
|
146
|
-
Test that custom values are properly included in dictionary.
|
|
147
|
-
|
|
148
|
-
Verifies that custom values provided to the Hourly instance are correctly
|
|
149
|
-
reflected in the dictionary returned by `toDict`.
|
|
150
|
-
|
|
151
|
-
Returns
|
|
152
|
-
-------
|
|
153
|
-
None
|
|
154
|
-
"""
|
|
155
|
-
custom_hourly = Hourly(
|
|
156
|
-
path="custom/logs/app.log",
|
|
157
|
-
level="warning",
|
|
158
|
-
retention_hours=48
|
|
159
|
-
)
|
|
160
|
-
hourly_dict = custom_hourly.toDict()
|
|
161
|
-
self.assertEqual(hourly_dict['path'], "custom/logs/app.log")
|
|
162
|
-
self.assertEqual(hourly_dict['level'], Level.WARNING.value)
|
|
163
|
-
self.assertEqual(hourly_dict['retention_hours'], 48)
|
|
164
|
-
|
|
165
|
-
async def testHashability(self):
|
|
166
|
-
"""
|
|
167
|
-
Test that Hourly maintains hashability due to unsafe_hash=True.
|
|
168
|
-
|
|
169
|
-
Ensures that Hourly instances can be added to a set and that their
|
|
170
|
-
hashability is preserved.
|
|
171
|
-
|
|
172
|
-
Returns
|
|
173
|
-
-------
|
|
174
|
-
None
|
|
175
|
-
"""
|
|
176
|
-
hourly1 = Hourly()
|
|
177
|
-
hourly2 = Hourly()
|
|
178
|
-
hourly_set = {hourly1, hourly2}
|
|
179
|
-
self.assertEqual(len(hourly_set), 1)
|
|
180
|
-
custom_hourly = Hourly(path="custom.log")
|
|
181
|
-
hourly_set.add(custom_hourly)
|
|
182
|
-
self.assertEqual(len(hourly_set), 2)
|
|
183
|
-
|
|
184
|
-
async def testKwOnlyInitialization(self):
|
|
185
|
-
"""
|
|
186
|
-
Test that Hourly enforces keyword-only initialization.
|
|
187
|
-
|
|
188
|
-
Verifies that attempting to initialize Hourly with positional arguments
|
|
189
|
-
raises a TypeError.
|
|
190
|
-
|
|
191
|
-
Returns
|
|
192
|
-
-------
|
|
193
|
-
None
|
|
194
|
-
"""
|
|
195
|
-
with self.assertRaises(TypeError):
|
|
196
|
-
Hourly("path.log", "info", 24)
|
|
@@ -1,214 +0,0 @@
|
|
|
1
|
-
from orionis.foundation.config.logging.entities.monthly import Monthly
|
|
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 TestFoundationConfigLoggingMonthly(AsyncTestCase):
|
|
7
|
-
"""
|
|
8
|
-
Test suite for the `Monthly` logging configuration class.
|
|
9
|
-
|
|
10
|
-
This class contains asynchronous test cases to validate the behavior of the
|
|
11
|
-
`Monthly` logging configuration, including default values, attribute validation,
|
|
12
|
-
dictionary conversion, hashability, and keyword-only initialization.
|
|
13
|
-
"""
|
|
14
|
-
|
|
15
|
-
async def testDefaultValues(self):
|
|
16
|
-
"""
|
|
17
|
-
Test the default attribute values of a Monthly instance.
|
|
18
|
-
|
|
19
|
-
Returns
|
|
20
|
-
-------
|
|
21
|
-
None
|
|
22
|
-
|
|
23
|
-
Asserts
|
|
24
|
-
-------
|
|
25
|
-
- The default path is "storage/log/monthly.log".
|
|
26
|
-
- The default level is `Level.INFO.value`.
|
|
27
|
-
- The default retention_months is 4.
|
|
28
|
-
"""
|
|
29
|
-
monthly = Monthly()
|
|
30
|
-
self.assertEqual(monthly.path, "storage/log/monthly.log")
|
|
31
|
-
self.assertEqual(monthly.level, Level.INFO.value)
|
|
32
|
-
self.assertEqual(monthly.retention_months, 4)
|
|
33
|
-
|
|
34
|
-
async def testPathValidation(self):
|
|
35
|
-
"""
|
|
36
|
-
Validate the `path` attribute for correct and incorrect values.
|
|
37
|
-
|
|
38
|
-
Returns
|
|
39
|
-
-------
|
|
40
|
-
None
|
|
41
|
-
|
|
42
|
-
Asserts
|
|
43
|
-
-------
|
|
44
|
-
- Raises OrionisIntegrityException for empty or non-string paths.
|
|
45
|
-
- Does not raise for valid string paths.
|
|
46
|
-
"""
|
|
47
|
-
with self.assertRaises(OrionisIntegrityException):
|
|
48
|
-
Monthly(path="")
|
|
49
|
-
with self.assertRaises(OrionisIntegrityException):
|
|
50
|
-
Monthly(path=123)
|
|
51
|
-
try:
|
|
52
|
-
Monthly(path="custom/log/path.log")
|
|
53
|
-
except OrionisIntegrityException:
|
|
54
|
-
self.fail("Valid path should not raise exception")
|
|
55
|
-
|
|
56
|
-
async def testLevelValidation(self):
|
|
57
|
-
"""
|
|
58
|
-
Validate the `level` attribute with various input types.
|
|
59
|
-
|
|
60
|
-
Returns
|
|
61
|
-
-------
|
|
62
|
-
None
|
|
63
|
-
|
|
64
|
-
Asserts
|
|
65
|
-
-------
|
|
66
|
-
- Accepts string, int, and enum values for level.
|
|
67
|
-
- Raises OrionisIntegrityException for invalid level values.
|
|
68
|
-
"""
|
|
69
|
-
# Test string level
|
|
70
|
-
monthly = Monthly(level="debug")
|
|
71
|
-
self.assertEqual(monthly.level, Level.DEBUG.value)
|
|
72
|
-
|
|
73
|
-
# Test int level
|
|
74
|
-
monthly = Monthly(level=Level.WARNING.value)
|
|
75
|
-
self.assertEqual(monthly.level, Level.WARNING.value)
|
|
76
|
-
|
|
77
|
-
# Test enum level
|
|
78
|
-
monthly = Monthly(level=Level.ERROR)
|
|
79
|
-
self.assertEqual(monthly.level, Level.ERROR.value)
|
|
80
|
-
|
|
81
|
-
# Test invalid cases
|
|
82
|
-
with self.assertRaises(OrionisIntegrityException):
|
|
83
|
-
Monthly(level="invalid")
|
|
84
|
-
with self.assertRaises(OrionisIntegrityException):
|
|
85
|
-
Monthly(level=999)
|
|
86
|
-
with self.assertRaises(OrionisIntegrityException):
|
|
87
|
-
Monthly(level=[])
|
|
88
|
-
|
|
89
|
-
async def testRetentionMonthsValidation(self):
|
|
90
|
-
"""
|
|
91
|
-
Validate the `retention_months` attribute for correct and incorrect values.
|
|
92
|
-
|
|
93
|
-
Returns
|
|
94
|
-
-------
|
|
95
|
-
None
|
|
96
|
-
|
|
97
|
-
Asserts
|
|
98
|
-
-------
|
|
99
|
-
- Accepts valid integer values for retention_months.
|
|
100
|
-
- Raises OrionisIntegrityException for invalid values.
|
|
101
|
-
"""
|
|
102
|
-
# Test valid values
|
|
103
|
-
try:
|
|
104
|
-
Monthly(retention_months=1)
|
|
105
|
-
Monthly(retention_months=12)
|
|
106
|
-
Monthly(retention_months=6)
|
|
107
|
-
except OrionisIntegrityException:
|
|
108
|
-
self.fail("Valid retention_months should not raise exception")
|
|
109
|
-
|
|
110
|
-
# Test invalid values
|
|
111
|
-
with self.assertRaises(OrionisIntegrityException):
|
|
112
|
-
Monthly(retention_months=0)
|
|
113
|
-
with self.assertRaises(OrionisIntegrityException):
|
|
114
|
-
Monthly(retention_months=13)
|
|
115
|
-
with self.assertRaises(OrionisIntegrityException):
|
|
116
|
-
Monthly(retention_months=-1)
|
|
117
|
-
with self.assertRaises(OrionisIntegrityException):
|
|
118
|
-
Monthly(retention_months="4")
|
|
119
|
-
|
|
120
|
-
async def testWhitespaceHandling(self):
|
|
121
|
-
"""
|
|
122
|
-
Test handling of leading and trailing whitespace in `path` and `level` attributes.
|
|
123
|
-
|
|
124
|
-
Returns
|
|
125
|
-
-------
|
|
126
|
-
None
|
|
127
|
-
|
|
128
|
-
Asserts
|
|
129
|
-
-------
|
|
130
|
-
- Raises OrionisIntegrityException if whitespace is not properly handled.
|
|
131
|
-
"""
|
|
132
|
-
with self.assertRaises(OrionisIntegrityException):
|
|
133
|
-
monthly = Monthly(path=" logs/app.log ", level=" debug ")
|
|
134
|
-
self.assertEqual(monthly.path, " logs/app.log ")
|
|
135
|
-
self.assertEqual(monthly.level, Level.DEBUG.value)
|
|
136
|
-
|
|
137
|
-
async def testToDictMethod(self):
|
|
138
|
-
"""
|
|
139
|
-
Test the `toDict` method for correct dictionary representation.
|
|
140
|
-
|
|
141
|
-
Returns
|
|
142
|
-
-------
|
|
143
|
-
None
|
|
144
|
-
|
|
145
|
-
Asserts
|
|
146
|
-
-------
|
|
147
|
-
- The output is a dictionary with correct keys and values.
|
|
148
|
-
"""
|
|
149
|
-
monthly = Monthly()
|
|
150
|
-
monthly_dict = monthly.toDict()
|
|
151
|
-
self.assertIsInstance(monthly_dict, dict)
|
|
152
|
-
self.assertEqual(monthly_dict['path'], "storage/log/monthly.log")
|
|
153
|
-
self.assertEqual(monthly_dict['level'], Level.INFO.value)
|
|
154
|
-
self.assertEqual(monthly_dict['retention_months'], 4)
|
|
155
|
-
|
|
156
|
-
async def testCustomValuesToDict(self):
|
|
157
|
-
"""
|
|
158
|
-
Test that custom attribute values are reflected in the dictionary output.
|
|
159
|
-
|
|
160
|
-
Returns
|
|
161
|
-
-------
|
|
162
|
-
None
|
|
163
|
-
|
|
164
|
-
Asserts
|
|
165
|
-
-------
|
|
166
|
-
- Custom path, level, and retention_months are present in the output dictionary.
|
|
167
|
-
"""
|
|
168
|
-
custom_monthly = Monthly(
|
|
169
|
-
path="custom/logs/app.log",
|
|
170
|
-
level="warning",
|
|
171
|
-
retention_months=6
|
|
172
|
-
)
|
|
173
|
-
monthly_dict = custom_monthly.toDict()
|
|
174
|
-
self.assertEqual(monthly_dict['path'], "custom/logs/app.log")
|
|
175
|
-
self.assertEqual(monthly_dict['level'], Level.WARNING.value)
|
|
176
|
-
self.assertEqual(monthly_dict['retention_months'], 6)
|
|
177
|
-
|
|
178
|
-
async def testHashability(self):
|
|
179
|
-
"""
|
|
180
|
-
Test that Monthly instances are hashable and can be used in sets.
|
|
181
|
-
|
|
182
|
-
Returns
|
|
183
|
-
-------
|
|
184
|
-
None
|
|
185
|
-
|
|
186
|
-
Asserts
|
|
187
|
-
-------
|
|
188
|
-
- Monthly instances with identical attributes are considered equal in a set.
|
|
189
|
-
- Monthly instances with different attributes are considered distinct.
|
|
190
|
-
"""
|
|
191
|
-
monthly1 = Monthly()
|
|
192
|
-
monthly2 = Monthly()
|
|
193
|
-
monthly_set = {monthly1, monthly2}
|
|
194
|
-
|
|
195
|
-
self.assertEqual(len(monthly_set), 1)
|
|
196
|
-
|
|
197
|
-
custom_monthly = Monthly(path="custom.log")
|
|
198
|
-
monthly_set.add(custom_monthly)
|
|
199
|
-
self.assertEqual(len(monthly_set), 2)
|
|
200
|
-
|
|
201
|
-
async def testKwOnlyInitialization(self):
|
|
202
|
-
"""
|
|
203
|
-
Test that Monthly enforces keyword-only initialization.
|
|
204
|
-
|
|
205
|
-
Returns
|
|
206
|
-
-------
|
|
207
|
-
None
|
|
208
|
-
|
|
209
|
-
Asserts
|
|
210
|
-
-------
|
|
211
|
-
- Raises TypeError when positional arguments are used.
|
|
212
|
-
"""
|
|
213
|
-
with self.assertRaises(TypeError):
|
|
214
|
-
Monthly("path.log", "info", 4)
|
|
@@ -1,178 +0,0 @@
|
|
|
1
|
-
from orionis.foundation.config.logging.entities.stack import Stack
|
|
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 TestFoundationConfigLoggingStack(AsyncTestCase):
|
|
7
|
-
"""
|
|
8
|
-
Asynchronous unit tests for the Stack logging configuration class.
|
|
9
|
-
|
|
10
|
-
This test class validates the behavior of the Stack class, including default values,
|
|
11
|
-
attribute validation, dictionary conversion, hashability, and enforcement of keyword-only
|
|
12
|
-
initialization.
|
|
13
|
-
"""
|
|
14
|
-
|
|
15
|
-
async def testDefaultValues(self):
|
|
16
|
-
"""
|
|
17
|
-
Test that Stack initializes with correct default values.
|
|
18
|
-
|
|
19
|
-
Checks that the default path and level attributes of a Stack instance match
|
|
20
|
-
the expected class defaults.
|
|
21
|
-
|
|
22
|
-
Returns
|
|
23
|
-
-------
|
|
24
|
-
None
|
|
25
|
-
"""
|
|
26
|
-
stack = Stack()
|
|
27
|
-
self.assertEqual(stack.path, "storage/log/stack.log")
|
|
28
|
-
self.assertEqual(stack.level, Level.INFO.value)
|
|
29
|
-
|
|
30
|
-
async def testPathValidation(self):
|
|
31
|
-
"""
|
|
32
|
-
Validate the path attribute for correct type and non-emptiness.
|
|
33
|
-
|
|
34
|
-
Ensures that providing an empty string or a non-string value for the path
|
|
35
|
-
raises an OrionisIntegrityException, while a valid string path is accepted.
|
|
36
|
-
|
|
37
|
-
Raises
|
|
38
|
-
------
|
|
39
|
-
OrionisIntegrityException
|
|
40
|
-
If the path is empty or not a string.
|
|
41
|
-
"""
|
|
42
|
-
# Test empty path
|
|
43
|
-
with self.assertRaises(OrionisIntegrityException):
|
|
44
|
-
Stack(path="")
|
|
45
|
-
# Test non-string path
|
|
46
|
-
with self.assertRaises(OrionisIntegrityException):
|
|
47
|
-
Stack(path=123)
|
|
48
|
-
# Test valid path
|
|
49
|
-
try:
|
|
50
|
-
Stack(path="custom/log/path.log")
|
|
51
|
-
except OrionisIntegrityException:
|
|
52
|
-
self.fail("Valid path should not raise exception")
|
|
53
|
-
|
|
54
|
-
async def testLevelValidation(self):
|
|
55
|
-
"""
|
|
56
|
-
Validate the level attribute with various input types.
|
|
57
|
-
|
|
58
|
-
Verifies that the level attribute accepts string, integer, and enum values
|
|
59
|
-
corresponding to valid logging levels, and raises exceptions for invalid values.
|
|
60
|
-
|
|
61
|
-
Raises
|
|
62
|
-
------
|
|
63
|
-
OrionisIntegrityException
|
|
64
|
-
If the level is invalid or of an unsupported type.
|
|
65
|
-
"""
|
|
66
|
-
# Test string level
|
|
67
|
-
stack = Stack(level="debug")
|
|
68
|
-
self.assertEqual(stack.level, Level.DEBUG.value)
|
|
69
|
-
|
|
70
|
-
# Test int level
|
|
71
|
-
stack = Stack(level=Level.WARNING.value)
|
|
72
|
-
self.assertEqual(stack.level, Level.WARNING.value)
|
|
73
|
-
|
|
74
|
-
# Test enum level
|
|
75
|
-
stack = Stack(level=Level.ERROR)
|
|
76
|
-
self.assertEqual(stack.level, Level.ERROR.value)
|
|
77
|
-
|
|
78
|
-
# Test invalid string level
|
|
79
|
-
with self.assertRaises(OrionisIntegrityException):
|
|
80
|
-
Stack(level="invalid")
|
|
81
|
-
|
|
82
|
-
# Test invalid int level
|
|
83
|
-
with self.assertRaises(OrionisIntegrityException):
|
|
84
|
-
Stack(level=999)
|
|
85
|
-
|
|
86
|
-
# Test invalid type
|
|
87
|
-
with self.assertRaises(OrionisIntegrityException):
|
|
88
|
-
Stack(level=[])
|
|
89
|
-
|
|
90
|
-
async def testWhitespaceHandling(self):
|
|
91
|
-
"""
|
|
92
|
-
Test handling of whitespace in path and level attributes.
|
|
93
|
-
|
|
94
|
-
Ensures that leading or trailing whitespace in the path attribute is not accepted
|
|
95
|
-
and raises an OrionisIntegrityException.
|
|
96
|
-
|
|
97
|
-
Raises
|
|
98
|
-
------
|
|
99
|
-
OrionisIntegrityException
|
|
100
|
-
If the path contains leading or trailing whitespace.
|
|
101
|
-
"""
|
|
102
|
-
with self.assertRaises(OrionisIntegrityException):
|
|
103
|
-
spaced_path = " logs/app.log "
|
|
104
|
-
stack = Stack(path=spaced_path)
|
|
105
|
-
self.assertEqual(stack.path, spaced_path)
|
|
106
|
-
|
|
107
|
-
async def testToDictMethod(self):
|
|
108
|
-
"""
|
|
109
|
-
Test the toDict method for correct dictionary representation.
|
|
110
|
-
|
|
111
|
-
Verifies that the dictionary returned by toDict contains the correct path and
|
|
112
|
-
level values for a Stack instance with default attributes.
|
|
113
|
-
|
|
114
|
-
Returns
|
|
115
|
-
-------
|
|
116
|
-
None
|
|
117
|
-
"""
|
|
118
|
-
stack = Stack()
|
|
119
|
-
stack_dict = stack.toDict()
|
|
120
|
-
|
|
121
|
-
self.assertIsInstance(stack_dict, dict)
|
|
122
|
-
self.assertEqual(stack_dict['path'], "storage/log/stack.log")
|
|
123
|
-
self.assertEqual(stack_dict['level'], Level.INFO.value)
|
|
124
|
-
|
|
125
|
-
async def testCustomValuesToDict(self):
|
|
126
|
-
"""
|
|
127
|
-
Test dictionary representation with custom attribute values.
|
|
128
|
-
|
|
129
|
-
Ensures that custom path and level values are accurately reflected in the
|
|
130
|
-
dictionary returned by toDict.
|
|
131
|
-
|
|
132
|
-
Returns
|
|
133
|
-
-------
|
|
134
|
-
None
|
|
135
|
-
"""
|
|
136
|
-
custom_stack = Stack(
|
|
137
|
-
path="custom/logs/app.log",
|
|
138
|
-
level="warning"
|
|
139
|
-
)
|
|
140
|
-
stack_dict = custom_stack.toDict()
|
|
141
|
-
self.assertEqual(stack_dict['path'], "custom/logs/app.log")
|
|
142
|
-
self.assertEqual(stack_dict['level'], Level.WARNING.value)
|
|
143
|
-
|
|
144
|
-
async def testHashability(self):
|
|
145
|
-
"""
|
|
146
|
-
Test that Stack instances are hashable.
|
|
147
|
-
|
|
148
|
-
Verifies that Stack instances can be added to sets and used as dictionary keys,
|
|
149
|
-
and that instances with identical attributes are considered equal.
|
|
150
|
-
|
|
151
|
-
Returns
|
|
152
|
-
-------
|
|
153
|
-
None
|
|
154
|
-
"""
|
|
155
|
-
stack1 = Stack()
|
|
156
|
-
stack2 = Stack()
|
|
157
|
-
stack_set = {stack1, stack2}
|
|
158
|
-
|
|
159
|
-
self.assertEqual(len(stack_set), 1)
|
|
160
|
-
|
|
161
|
-
custom_stack = Stack(path="custom.log")
|
|
162
|
-
stack_set.add(custom_stack)
|
|
163
|
-
self.assertEqual(len(stack_set), 2)
|
|
164
|
-
|
|
165
|
-
async def testKwOnlyInitialization(self):
|
|
166
|
-
"""
|
|
167
|
-
Test enforcement of keyword-only initialization for Stack.
|
|
168
|
-
|
|
169
|
-
Ensures that attempting to initialize Stack with positional arguments raises
|
|
170
|
-
a TypeError.
|
|
171
|
-
|
|
172
|
-
Raises
|
|
173
|
-
------
|
|
174
|
-
TypeError
|
|
175
|
-
If positional arguments are used for initialization.
|
|
176
|
-
"""
|
|
177
|
-
with self.assertRaises(TypeError):
|
|
178
|
-
Stack("path.log", "info")
|