orionis 0.546.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/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.547.0.dist-info}/METADATA +1 -1
- {orionis-0.546.0.dist-info → orionis-0.547.0.dist-info}/RECORD +15 -159
- {orionis-0.546.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.546.0.dist-info → orionis-0.547.0.dist-info}/WHEEL +0 -0
- {orionis-0.546.0.dist-info → orionis-0.547.0.dist-info}/licenses/LICENCE +0 -0
- {orionis-0.546.0.dist-info → orionis-0.547.0.dist-info}/zip-safe +0 -0
|
@@ -1,207 +0,0 @@
|
|
|
1
|
-
from orionis.foundation.config.database.entities.sqlite import SQLite
|
|
2
|
-
from orionis.foundation.config.database.enums.sqlite_foreign_key import SQLiteForeignKey
|
|
3
|
-
from orionis.foundation.config.database.enums.sqlite_journal import SQLiteJournalMode
|
|
4
|
-
from orionis.foundation.config.database.enums.sqlite_synchronous import SQLiteSynchronous
|
|
5
|
-
from orionis.foundation.exceptions.integrity import OrionisIntegrityException
|
|
6
|
-
from orionis.test.cases.asynchronous import AsyncTestCase
|
|
7
|
-
|
|
8
|
-
class TestFoundationConfigDatabaseSqlite(AsyncTestCase):
|
|
9
|
-
"""
|
|
10
|
-
Test cases for the SQLite database configuration class.
|
|
11
|
-
|
|
12
|
-
This class contains unit tests to validate the behavior and integrity of the
|
|
13
|
-
SQLite configuration entity, ensuring correct default values, validation logic,
|
|
14
|
-
and dictionary representation.
|
|
15
|
-
"""
|
|
16
|
-
|
|
17
|
-
async def testDefaultValues(self):
|
|
18
|
-
"""
|
|
19
|
-
Test that SQLite instance is created with correct default values.
|
|
20
|
-
|
|
21
|
-
Ensures all default values match expected defaults from the class definition.
|
|
22
|
-
|
|
23
|
-
Returns
|
|
24
|
-
-------
|
|
25
|
-
None
|
|
26
|
-
"""
|
|
27
|
-
sqlite = SQLite()
|
|
28
|
-
self.assertEqual(sqlite.driver, 'sqlite')
|
|
29
|
-
self.assertTrue(sqlite.url.startswith('sqlite:///'))
|
|
30
|
-
self.assertEqual(sqlite.database, 'database.sqlite')
|
|
31
|
-
self.assertEqual(sqlite.prefix, '')
|
|
32
|
-
self.assertEqual(sqlite.foreign_key_constraints, SQLiteForeignKey.OFF.value)
|
|
33
|
-
self.assertEqual(sqlite.busy_timeout, 5000)
|
|
34
|
-
self.assertEqual(sqlite.journal_mode, SQLiteJournalMode.DELETE.value)
|
|
35
|
-
self.assertEqual(sqlite.synchronous, SQLiteSynchronous.NORMAL.value)
|
|
36
|
-
|
|
37
|
-
async def testDriverValidation(self):
|
|
38
|
-
"""
|
|
39
|
-
Test driver attribute validation.
|
|
40
|
-
|
|
41
|
-
Verifies that empty or non-string drivers raise exceptions.
|
|
42
|
-
|
|
43
|
-
Returns
|
|
44
|
-
-------
|
|
45
|
-
None
|
|
46
|
-
"""
|
|
47
|
-
with self.assertRaises(OrionisIntegrityException):
|
|
48
|
-
SQLite(driver='')
|
|
49
|
-
with self.assertRaises(OrionisIntegrityException):
|
|
50
|
-
SQLite(driver=123)
|
|
51
|
-
|
|
52
|
-
async def testUrlValidation(self):
|
|
53
|
-
"""
|
|
54
|
-
Test URL attribute validation.
|
|
55
|
-
|
|
56
|
-
Verifies that empty or non-string URLs raise exceptions.
|
|
57
|
-
|
|
58
|
-
Returns
|
|
59
|
-
-------
|
|
60
|
-
None
|
|
61
|
-
"""
|
|
62
|
-
with self.assertRaises(OrionisIntegrityException):
|
|
63
|
-
SQLite(url='')
|
|
64
|
-
with self.assertRaises(OrionisIntegrityException):
|
|
65
|
-
SQLite(url=123)
|
|
66
|
-
|
|
67
|
-
async def testDatabaseValidation(self):
|
|
68
|
-
"""
|
|
69
|
-
Test database attribute validation.
|
|
70
|
-
|
|
71
|
-
Verifies that empty or non-string database paths raise exceptions.
|
|
72
|
-
|
|
73
|
-
Returns
|
|
74
|
-
-------
|
|
75
|
-
None
|
|
76
|
-
"""
|
|
77
|
-
with self.assertRaises(OrionisIntegrityException):
|
|
78
|
-
SQLite(database='')
|
|
79
|
-
with self.assertRaises(OrionisIntegrityException):
|
|
80
|
-
SQLite(database=123)
|
|
81
|
-
|
|
82
|
-
async def testForeignKeyConstraintsValidation(self):
|
|
83
|
-
"""
|
|
84
|
-
Test foreign_key_constraints attribute validation.
|
|
85
|
-
|
|
86
|
-
Verifies enum conversion and invalid value handling.
|
|
87
|
-
|
|
88
|
-
Returns
|
|
89
|
-
-------
|
|
90
|
-
None
|
|
91
|
-
"""
|
|
92
|
-
# Test string conversion
|
|
93
|
-
sqlite = SQLite(foreign_key_constraints='ON')
|
|
94
|
-
self.assertEqual(sqlite.foreign_key_constraints, SQLiteForeignKey.ON.value)
|
|
95
|
-
|
|
96
|
-
# Test enum assignment
|
|
97
|
-
sqlite = SQLite(foreign_key_constraints=SQLiteForeignKey.OFF)
|
|
98
|
-
self.assertEqual(sqlite.foreign_key_constraints, SQLiteForeignKey.OFF.value)
|
|
99
|
-
|
|
100
|
-
# Test invalid value
|
|
101
|
-
with self.assertRaises(OrionisIntegrityException):
|
|
102
|
-
SQLite(foreign_key_constraints='INVALID')
|
|
103
|
-
|
|
104
|
-
async def testBusyTimeoutValidation(self):
|
|
105
|
-
"""
|
|
106
|
-
Test busy_timeout attribute validation.
|
|
107
|
-
|
|
108
|
-
Verifies non-negative integer requirement.
|
|
109
|
-
|
|
110
|
-
Returns
|
|
111
|
-
-------
|
|
112
|
-
None
|
|
113
|
-
"""
|
|
114
|
-
with self.assertRaises(OrionisIntegrityException):
|
|
115
|
-
SQLite(busy_timeout=-1)
|
|
116
|
-
with self.assertRaises(OrionisIntegrityException):
|
|
117
|
-
SQLite(busy_timeout='invalid')
|
|
118
|
-
|
|
119
|
-
async def testJournalModeValidation(self):
|
|
120
|
-
"""
|
|
121
|
-
Test journal_mode attribute validation.
|
|
122
|
-
|
|
123
|
-
Verifies enum conversion and invalid value handling.
|
|
124
|
-
|
|
125
|
-
Returns
|
|
126
|
-
-------
|
|
127
|
-
None
|
|
128
|
-
"""
|
|
129
|
-
# Test string conversion
|
|
130
|
-
sqlite = SQLite(journal_mode='WAL')
|
|
131
|
-
self.assertEqual(sqlite.journal_mode, SQLiteJournalMode.WAL.value)
|
|
132
|
-
|
|
133
|
-
# Test enum assignment
|
|
134
|
-
sqlite = SQLite(journal_mode=SQLiteJournalMode.TRUNCATE)
|
|
135
|
-
self.assertEqual(sqlite.journal_mode, SQLiteJournalMode.TRUNCATE.value)
|
|
136
|
-
|
|
137
|
-
# Test invalid value
|
|
138
|
-
with self.assertRaises(OrionisIntegrityException):
|
|
139
|
-
SQLite(journal_mode='INVALID')
|
|
140
|
-
|
|
141
|
-
async def testSynchronousValidation(self):
|
|
142
|
-
"""
|
|
143
|
-
Test synchronous attribute validation.
|
|
144
|
-
|
|
145
|
-
Verifies enum conversion and invalid value handling.
|
|
146
|
-
|
|
147
|
-
Returns
|
|
148
|
-
-------
|
|
149
|
-
None
|
|
150
|
-
"""
|
|
151
|
-
# Test string conversion
|
|
152
|
-
sqlite = SQLite(synchronous='FULL')
|
|
153
|
-
self.assertEqual(sqlite.synchronous, SQLiteSynchronous.FULL.value)
|
|
154
|
-
|
|
155
|
-
# Test enum assignment
|
|
156
|
-
sqlite = SQLite(synchronous=SQLiteSynchronous.OFF)
|
|
157
|
-
self.assertEqual(sqlite.synchronous, SQLiteSynchronous.OFF.value)
|
|
158
|
-
|
|
159
|
-
# Test invalid value
|
|
160
|
-
with self.assertRaises(OrionisIntegrityException):
|
|
161
|
-
SQLite(synchronous='INVALID')
|
|
162
|
-
|
|
163
|
-
async def testToDictMethod(self):
|
|
164
|
-
"""
|
|
165
|
-
Test that toDict returns proper dictionary representation.
|
|
166
|
-
|
|
167
|
-
Verifies all attributes are correctly included in the dictionary.
|
|
168
|
-
|
|
169
|
-
Returns
|
|
170
|
-
-------
|
|
171
|
-
None
|
|
172
|
-
"""
|
|
173
|
-
sqlite = SQLite()
|
|
174
|
-
sqlite_dict = sqlite.toDict()
|
|
175
|
-
self.assertEqual(sqlite_dict['driver'], 'sqlite')
|
|
176
|
-
self.assertTrue(sqlite_dict['url'].startswith('sqlite:///'))
|
|
177
|
-
self.assertEqual(sqlite_dict['database'], 'database.sqlite')
|
|
178
|
-
self.assertEqual(sqlite_dict['prefix'], '')
|
|
179
|
-
self.assertEqual(sqlite_dict['foreign_key_constraints'], SQLiteForeignKey.OFF.value)
|
|
180
|
-
self.assertEqual(sqlite_dict['busy_timeout'], 5000)
|
|
181
|
-
self.assertEqual(sqlite_dict['journal_mode'], SQLiteJournalMode.DELETE.value)
|
|
182
|
-
self.assertEqual(sqlite_dict['synchronous'], SQLiteSynchronous.NORMAL.value)
|
|
183
|
-
|
|
184
|
-
async def testCustomValues(self):
|
|
185
|
-
"""
|
|
186
|
-
Test that custom values are properly stored and validated.
|
|
187
|
-
|
|
188
|
-
Verifies custom configuration values are correctly handled.
|
|
189
|
-
|
|
190
|
-
Returns
|
|
191
|
-
-------
|
|
192
|
-
None
|
|
193
|
-
"""
|
|
194
|
-
custom_sqlite = SQLite(
|
|
195
|
-
database='custom.db',
|
|
196
|
-
prefix='app_',
|
|
197
|
-
foreign_key_constraints='ON',
|
|
198
|
-
busy_timeout=10000,
|
|
199
|
-
journal_mode='MEMORY',
|
|
200
|
-
synchronous='OFF'
|
|
201
|
-
)
|
|
202
|
-
self.assertEqual(custom_sqlite.database, 'custom.db')
|
|
203
|
-
self.assertEqual(custom_sqlite.prefix, 'app_')
|
|
204
|
-
self.assertEqual(custom_sqlite.foreign_key_constraints, SQLiteForeignKey.ON.value)
|
|
205
|
-
self.assertEqual(custom_sqlite.busy_timeout, 10000)
|
|
206
|
-
self.assertEqual(custom_sqlite.journal_mode, SQLiteJournalMode.MEMORY.value)
|
|
207
|
-
self.assertEqual(custom_sqlite.synchronous, SQLiteSynchronous.OFF.value)
|
|
File without changes
|
|
@@ -1,160 +0,0 @@
|
|
|
1
|
-
from orionis.foundation.config.filesystems.entitites.disks import Disks
|
|
2
|
-
from orionis.foundation.config.filesystems.entitites.filesystems import Filesystems
|
|
3
|
-
from orionis.foundation.exceptions.integrity import OrionisIntegrityException
|
|
4
|
-
from orionis.test.cases.asynchronous import AsyncTestCase
|
|
5
|
-
|
|
6
|
-
class TestFoundationConfigFilesystems(AsyncTestCase):
|
|
7
|
-
"""
|
|
8
|
-
Test cases for the Filesystems configuration class.
|
|
9
|
-
|
|
10
|
-
This class contains unit tests for the `Filesystems` configuration class,
|
|
11
|
-
including validation of default values, disk types, dictionary conversion,
|
|
12
|
-
custom values, hashability, and keyword-only initialization.
|
|
13
|
-
"""
|
|
14
|
-
|
|
15
|
-
async def testDefaultValues(self):
|
|
16
|
-
"""
|
|
17
|
-
Test Filesystems instance creation with default values.
|
|
18
|
-
|
|
19
|
-
Ensures that the default disk is set to 'local' and the disks attribute
|
|
20
|
-
is properly initialized as a Disks instance.
|
|
21
|
-
"""
|
|
22
|
-
fs = Filesystems()
|
|
23
|
-
self.assertEqual(fs.default, "local")
|
|
24
|
-
self.assertIsInstance(fs.disks, Disks)
|
|
25
|
-
|
|
26
|
-
async def testDefaultDiskValidation(self):
|
|
27
|
-
"""
|
|
28
|
-
Validate the default disk attribute.
|
|
29
|
-
|
|
30
|
-
Checks that only valid disk types are accepted as default and that
|
|
31
|
-
invalid types raise an OrionisIntegrityException.
|
|
32
|
-
|
|
33
|
-
Raises
|
|
34
|
-
------
|
|
35
|
-
OrionisIntegrityException
|
|
36
|
-
If an invalid disk type is provided as default.
|
|
37
|
-
"""
|
|
38
|
-
# Test valid disk types
|
|
39
|
-
valid_disks = ["local", "public", "aws"]
|
|
40
|
-
for disk in valid_disks:
|
|
41
|
-
try:
|
|
42
|
-
Filesystems(default=disk)
|
|
43
|
-
except OrionisIntegrityException:
|
|
44
|
-
self.fail(f"Valid disk type '{disk}' should not raise exception")
|
|
45
|
-
|
|
46
|
-
# Test invalid disk type
|
|
47
|
-
with self.assertRaises(OrionisIntegrityException):
|
|
48
|
-
Filesystems(default="invalid_disk")
|
|
49
|
-
|
|
50
|
-
# Test empty default
|
|
51
|
-
with self.assertRaises(OrionisIntegrityException):
|
|
52
|
-
Filesystems(default="")
|
|
53
|
-
|
|
54
|
-
# Test non-string default
|
|
55
|
-
with self.assertRaises(OrionisIntegrityException):
|
|
56
|
-
Filesystems(default=123)
|
|
57
|
-
|
|
58
|
-
async def testDisksValidation(self):
|
|
59
|
-
"""
|
|
60
|
-
Validate the disks attribute.
|
|
61
|
-
|
|
62
|
-
Ensures that only instances of Disks are accepted for the disks attribute.
|
|
63
|
-
Invalid types should raise an OrionisIntegrityException.
|
|
64
|
-
|
|
65
|
-
Raises
|
|
66
|
-
------
|
|
67
|
-
OrionisIntegrityException
|
|
68
|
-
If disks is not a Disks instance or is None.
|
|
69
|
-
"""
|
|
70
|
-
# Test invalid disks type
|
|
71
|
-
with self.assertRaises(OrionisIntegrityException):
|
|
72
|
-
Filesystems(disks="not_a_disks_instance")
|
|
73
|
-
|
|
74
|
-
# Test None disks
|
|
75
|
-
with self.assertRaises(OrionisIntegrityException):
|
|
76
|
-
Filesystems(disks=None)
|
|
77
|
-
|
|
78
|
-
# Test valid disks
|
|
79
|
-
try:
|
|
80
|
-
Filesystems(disks=Disks())
|
|
81
|
-
except OrionisIntegrityException:
|
|
82
|
-
self.fail("Valid Disks instance should not raise exception")
|
|
83
|
-
|
|
84
|
-
async def testToDictMethod(self):
|
|
85
|
-
"""
|
|
86
|
-
Test the toDict method of Filesystems.
|
|
87
|
-
|
|
88
|
-
Ensures that the method returns a dictionary representation of the
|
|
89
|
-
Filesystems instance with all attributes correctly included.
|
|
90
|
-
|
|
91
|
-
Returns
|
|
92
|
-
-------
|
|
93
|
-
dict
|
|
94
|
-
Dictionary representation of the Filesystems instance.
|
|
95
|
-
"""
|
|
96
|
-
fs = Filesystems()
|
|
97
|
-
fs_dict = fs.toDict()
|
|
98
|
-
|
|
99
|
-
self.assertIsInstance(fs_dict, dict)
|
|
100
|
-
self.assertEqual(fs_dict['default'], "local")
|
|
101
|
-
self.assertIsInstance(fs_dict['disks'], dict)
|
|
102
|
-
|
|
103
|
-
async def testCustomValues(self):
|
|
104
|
-
"""
|
|
105
|
-
Test custom values for Filesystems.
|
|
106
|
-
|
|
107
|
-
Ensures that custom configurations are properly stored and validated.
|
|
108
|
-
|
|
109
|
-
Parameters
|
|
110
|
-
----------
|
|
111
|
-
custom_disks : Disks
|
|
112
|
-
Custom Disks instance to be used in Filesystems.
|
|
113
|
-
|
|
114
|
-
Returns
|
|
115
|
-
-------
|
|
116
|
-
None
|
|
117
|
-
"""
|
|
118
|
-
custom_disks = Disks()
|
|
119
|
-
custom_fs = Filesystems(
|
|
120
|
-
default="aws",
|
|
121
|
-
disks=custom_disks
|
|
122
|
-
)
|
|
123
|
-
self.assertEqual(custom_fs.default, "aws")
|
|
124
|
-
self.assertIs(custom_fs.disks, custom_disks)
|
|
125
|
-
|
|
126
|
-
async def testHashability(self):
|
|
127
|
-
"""
|
|
128
|
-
Test hashability of Filesystems instances.
|
|
129
|
-
|
|
130
|
-
Ensures that Filesystems instances are hashable and can be used in sets
|
|
131
|
-
and as dictionary keys due to `unsafe_hash=True`.
|
|
132
|
-
|
|
133
|
-
Returns
|
|
134
|
-
-------
|
|
135
|
-
None
|
|
136
|
-
"""
|
|
137
|
-
fs1 = Filesystems()
|
|
138
|
-
fs2 = Filesystems()
|
|
139
|
-
fs_set = {fs1, fs2}
|
|
140
|
-
|
|
141
|
-
self.assertEqual(len(fs_set), 1)
|
|
142
|
-
|
|
143
|
-
custom_fs = Filesystems(default="public")
|
|
144
|
-
fs_set.add(custom_fs)
|
|
145
|
-
self.assertEqual(len(fs_set), 2)
|
|
146
|
-
|
|
147
|
-
async def testKwOnlyInitialization(self):
|
|
148
|
-
"""
|
|
149
|
-
Test keyword-only initialization enforcement.
|
|
150
|
-
|
|
151
|
-
Ensures that Filesystems enforces keyword-only arguments and does not
|
|
152
|
-
allow positional arguments during initialization.
|
|
153
|
-
|
|
154
|
-
Raises
|
|
155
|
-
------
|
|
156
|
-
TypeError
|
|
157
|
-
If positional arguments are used for initialization.
|
|
158
|
-
"""
|
|
159
|
-
with self.assertRaises(TypeError):
|
|
160
|
-
Filesystems("local", Disks())
|
|
@@ -1,189 +0,0 @@
|
|
|
1
|
-
from orionis.foundation.exceptions.integrity import OrionisIntegrityException
|
|
2
|
-
from orionis.foundation.config.filesystems.entitites.aws import S3
|
|
3
|
-
from orionis.test.cases.asynchronous import AsyncTestCase
|
|
4
|
-
|
|
5
|
-
class TestFoundationConfigFilesystemsAws(AsyncTestCase):
|
|
6
|
-
"""
|
|
7
|
-
Unit tests for the S3 storage configuration entity.
|
|
8
|
-
|
|
9
|
-
This test class validates the behavior of the S3 configuration entity, including
|
|
10
|
-
default value assignment, field validation, custom value handling, dictionary
|
|
11
|
-
conversion, hashability, and enforcement of keyword-only initialization.
|
|
12
|
-
"""
|
|
13
|
-
|
|
14
|
-
async def testDefaultValues(self):
|
|
15
|
-
"""
|
|
16
|
-
Validate default values of S3 configuration fields.
|
|
17
|
-
|
|
18
|
-
Ensures that a newly created S3 instance has the expected default values
|
|
19
|
-
for all attributes as defined in the class.
|
|
20
|
-
|
|
21
|
-
Returns
|
|
22
|
-
-------
|
|
23
|
-
None
|
|
24
|
-
"""
|
|
25
|
-
s3 = S3()
|
|
26
|
-
self.assertEqual(s3.key, "")
|
|
27
|
-
self.assertEqual(s3.secret, "")
|
|
28
|
-
self.assertEqual(s3.region, "us-east-1")
|
|
29
|
-
self.assertEqual(s3.bucket, "")
|
|
30
|
-
self.assertIsNone(s3.url)
|
|
31
|
-
self.assertIsNone(s3.endpoint)
|
|
32
|
-
self.assertFalse(s3.use_path_style_endpoint)
|
|
33
|
-
self.assertFalse(s3.throw)
|
|
34
|
-
|
|
35
|
-
async def testRequiredFieldValidation(self):
|
|
36
|
-
"""
|
|
37
|
-
Validate required field constraints for S3 configuration.
|
|
38
|
-
|
|
39
|
-
Checks that the 'region' field must be a non-empty string and raises
|
|
40
|
-
OrionisIntegrityException if the constraint is violated.
|
|
41
|
-
|
|
42
|
-
Raises
|
|
43
|
-
------
|
|
44
|
-
OrionisIntegrityException
|
|
45
|
-
If 'region' is empty or not a string.
|
|
46
|
-
"""
|
|
47
|
-
# Test empty region
|
|
48
|
-
with self.assertRaises(OrionisIntegrityException):
|
|
49
|
-
S3(region="")
|
|
50
|
-
|
|
51
|
-
# Test non-string region
|
|
52
|
-
with self.assertRaises(OrionisIntegrityException):
|
|
53
|
-
S3(region=123)
|
|
54
|
-
|
|
55
|
-
async def testOptionalFieldValidation(self):
|
|
56
|
-
"""
|
|
57
|
-
Validate optional field types for S3 configuration.
|
|
58
|
-
|
|
59
|
-
Ensures that optional fields accept None or valid types, and raises
|
|
60
|
-
OrionisIntegrityException for invalid types.
|
|
61
|
-
|
|
62
|
-
Raises
|
|
63
|
-
------
|
|
64
|
-
OrionisIntegrityException
|
|
65
|
-
If optional fields are not of the correct type.
|
|
66
|
-
"""
|
|
67
|
-
# Valid optional configurations
|
|
68
|
-
try:
|
|
69
|
-
S3(url=None, endpoint=None)
|
|
70
|
-
S3(url="https://example.com", endpoint="https://s3.example.com")
|
|
71
|
-
except OrionisIntegrityException:
|
|
72
|
-
self.fail("Valid optional configurations should not raise exceptions")
|
|
73
|
-
|
|
74
|
-
# Invalid optional configurations
|
|
75
|
-
with self.assertRaises(OrionisIntegrityException):
|
|
76
|
-
S3(url=123)
|
|
77
|
-
with self.assertRaises(OrionisIntegrityException):
|
|
78
|
-
S3(endpoint=[])
|
|
79
|
-
|
|
80
|
-
async def testBooleanFieldValidation(self):
|
|
81
|
-
"""
|
|
82
|
-
Validate boolean field types for S3 configuration.
|
|
83
|
-
|
|
84
|
-
Ensures that boolean fields accept only boolean values and raises
|
|
85
|
-
OrionisIntegrityException for invalid types.
|
|
86
|
-
|
|
87
|
-
Raises
|
|
88
|
-
------
|
|
89
|
-
OrionisIntegrityException
|
|
90
|
-
If boolean fields are not of type bool.
|
|
91
|
-
"""
|
|
92
|
-
# Test use_path_style_endpoint
|
|
93
|
-
with self.assertRaises(OrionisIntegrityException):
|
|
94
|
-
S3(use_path_style_endpoint="true")
|
|
95
|
-
|
|
96
|
-
# Test throw
|
|
97
|
-
with self.assertRaises(OrionisIntegrityException):
|
|
98
|
-
S3(throw=1)
|
|
99
|
-
|
|
100
|
-
async def testCustomValues(self):
|
|
101
|
-
"""
|
|
102
|
-
Validate assignment and storage of custom values in S3 configuration.
|
|
103
|
-
|
|
104
|
-
Ensures that custom values provided during initialization are correctly
|
|
105
|
-
stored and validated in the S3 instance.
|
|
106
|
-
|
|
107
|
-
Returns
|
|
108
|
-
-------
|
|
109
|
-
None
|
|
110
|
-
"""
|
|
111
|
-
custom_s3 = S3(
|
|
112
|
-
key="AKIAEXAMPLE",
|
|
113
|
-
secret="secret123",
|
|
114
|
-
region="eu-west-1",
|
|
115
|
-
bucket="my-bucket",
|
|
116
|
-
url="https://my-bucket.s3.amazonaws.com",
|
|
117
|
-
endpoint="https://s3.eu-west-1.amazonaws.com",
|
|
118
|
-
use_path_style_endpoint=True,
|
|
119
|
-
throw=True
|
|
120
|
-
)
|
|
121
|
-
|
|
122
|
-
self.assertEqual(custom_s3.key, "AKIAEXAMPLE")
|
|
123
|
-
self.assertEqual(custom_s3.secret, "secret123")
|
|
124
|
-
self.assertEqual(custom_s3.region, "eu-west-1")
|
|
125
|
-
self.assertEqual(custom_s3.bucket, "my-bucket")
|
|
126
|
-
self.assertEqual(custom_s3.url, "https://my-bucket.s3.amazonaws.com")
|
|
127
|
-
self.assertEqual(custom_s3.endpoint, "https://s3.eu-west-1.amazonaws.com")
|
|
128
|
-
self.assertTrue(custom_s3.use_path_style_endpoint)
|
|
129
|
-
self.assertTrue(custom_s3.throw)
|
|
130
|
-
|
|
131
|
-
async def testToDictMethod(self):
|
|
132
|
-
"""
|
|
133
|
-
Validate dictionary conversion of S3 configuration.
|
|
134
|
-
|
|
135
|
-
Ensures that the toDict method returns a dictionary containing all
|
|
136
|
-
attributes of the S3 instance with correct values.
|
|
137
|
-
|
|
138
|
-
Returns
|
|
139
|
-
-------
|
|
140
|
-
None
|
|
141
|
-
"""
|
|
142
|
-
s3 = S3()
|
|
143
|
-
s3_dict = s3.toDict()
|
|
144
|
-
|
|
145
|
-
self.assertIsInstance(s3_dict, dict)
|
|
146
|
-
self.assertEqual(s3_dict['key'], "")
|
|
147
|
-
self.assertEqual(s3_dict['secret'], "")
|
|
148
|
-
self.assertEqual(s3_dict['region'], "us-east-1")
|
|
149
|
-
self.assertEqual(s3_dict['bucket'], "")
|
|
150
|
-
self.assertIsNone(s3_dict['url'])
|
|
151
|
-
self.assertIsNone(s3_dict['endpoint'])
|
|
152
|
-
self.assertFalse(s3_dict['use_path_style_endpoint'])
|
|
153
|
-
self.assertFalse(s3_dict['throw'])
|
|
154
|
-
|
|
155
|
-
async def testHashability(self):
|
|
156
|
-
"""
|
|
157
|
-
Validate hashability of S3 configuration instances.
|
|
158
|
-
|
|
159
|
-
Ensures that S3 instances are hashable and can be used in sets and as
|
|
160
|
-
dictionary keys due to unsafe_hash=True.
|
|
161
|
-
|
|
162
|
-
Returns
|
|
163
|
-
-------
|
|
164
|
-
None
|
|
165
|
-
"""
|
|
166
|
-
s3_1 = S3()
|
|
167
|
-
s3_2 = S3()
|
|
168
|
-
s3_set = {s3_1, s3_2}
|
|
169
|
-
|
|
170
|
-
self.assertEqual(len(s3_set), 1)
|
|
171
|
-
|
|
172
|
-
custom_s3 = S3(bucket="custom-bucket")
|
|
173
|
-
s3_set.add(custom_s3)
|
|
174
|
-
self.assertEqual(len(s3_set), 2)
|
|
175
|
-
|
|
176
|
-
async def testKwOnlyInitialization(self):
|
|
177
|
-
"""
|
|
178
|
-
Validate enforcement of keyword-only initialization for S3.
|
|
179
|
-
|
|
180
|
-
Ensures that S3 cannot be initialized with positional arguments and
|
|
181
|
-
raises TypeError if attempted.
|
|
182
|
-
|
|
183
|
-
Raises
|
|
184
|
-
------
|
|
185
|
-
TypeError
|
|
186
|
-
If positional arguments are used for initialization.
|
|
187
|
-
"""
|
|
188
|
-
with self.assertRaises(TypeError):
|
|
189
|
-
S3("key", "secret", "region") # Should fail as it requires keyword arguments
|