orionis 0.286.0__py3-none-any.whl → 0.288.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- orionis/metadata/framework.py +1 -1
- orionis/services/environment/contracts/env.py +45 -50
- orionis/services/environment/contracts/types.py +70 -0
- orionis/services/environment/dot_env.py +204 -182
- orionis/services/environment/env.py +68 -85
- orionis/services/{standard/exceptions/path_value_exceptions.py → environment/exceptions/environment_value_error.py} +2 -12
- orionis/services/environment/exceptions/environment_value_exception.py +23 -0
- orionis/services/environment/types.py +578 -0
- orionis/services/paths/exceptions/not_found_exceptions.py +15 -12
- orionis/services/paths/exceptions/path_value_exceptions.py +13 -10
- orionis/services/standard/contracts/std.py +1 -1
- orionis/services/standard/exceptions/std_value_exception.py +23 -0
- orionis/services/standard/std.py +2 -2
- orionis/services/system/contracts/imports.py +27 -7
- orionis/services/system/contracts/workers.py +8 -3
- orionis/services/system/imports.py +31 -12
- orionis/services/system/runtime_imports.py +33 -23
- orionis/services/system/workers.py +6 -8
- orionis/services/wrapper/dicts/dot_dict.py +82 -41
- orionis/test/logs/history.py +3 -5
- orionis/unittesting.py +12 -12
- {orionis-0.286.0.dist-info → orionis-0.288.0.dist-info}/METADATA +1 -1
- {orionis-0.286.0.dist-info → orionis-0.288.0.dist-info}/RECORD +76 -70
- tests/example/test_example.py +5 -2
- tests/foundation/config/app/{test_app.py → test_foundation_config_app.py} +14 -4
- tests/foundation/config/auth/{test_auth.py → test_foundation_config_auth.py} +10 -5
- tests/foundation/config/cache/{test_cache.py → test_foundation_config_cache.py} +61 -16
- tests/foundation/config/cache/test_foundation_config_cache_file.py +126 -0
- tests/foundation/config/cache/test_foundation_config_cache_stores.py +148 -0
- tests/foundation/config/cors/test_foundation_config_cors.py +190 -0
- tests/foundation/config/database/{test_database.py → test_foundation_config_database.py} +39 -15
- tests/foundation/config/database/{test_database_connections.py → test_foundation_config_database_connections.py} +80 -6
- tests/foundation/config/database/{test_database_mysql.py → test_foundation_config_database_mysql.py} +139 -16
- tests/foundation/config/database/{test_database_oracle.py → test_foundation_config_database_oracle.py} +111 -27
- tests/foundation/config/database/{test_database_pgsql.py → test_foundation_config_database_pgsql.py} +97 -27
- tests/foundation/config/database/{test_database_sqlite.py → test_foundation_config_database_sqlite.py} +57 -3
- tests/foundation/config/exceptions/{test_exceptions_integrity.py → test_foundation_config_exceptions.py} +45 -11
- tests/foundation/config/filesystems/{test_filesystems.py → test_foundation_config_filesystems.py} +65 -15
- tests/foundation/config/filesystems/{test_filesystems_aws.py → test_foundation_config_filesystems_aws.py} +46 -8
- tests/foundation/config/filesystems/{test_filesystems_disks.py → test_foundation_config_filesystems_disks.py} +79 -9
- tests/foundation/config/filesystems/{test_filesystems_local.py → test_foundation_config_filesystems_local.py} +67 -19
- tests/foundation/config/filesystems/{test_filesystems_public.py → test_foundation_config_filesystems_public.py} +38 -1
- tests/foundation/config/logging/test_foundation_config_logging.py +112 -0
- tests/foundation/config/logging/{test_logging_channels.py → test_foundation_config_logging_channels.py} +80 -3
- tests/foundation/config/logging/{test_logging_chunked.py → test_foundation_config_logging_chunked.py} +86 -13
- tests/foundation/config/logging/{test_logging_daily.py → test_foundation_config_logging_daily.py} +80 -13
- tests/foundation/config/logging/{test_logging_hourly.py → test_foundation_config_logging_hourly.py} +69 -3
- tests/foundation/config/logging/{test_logging_monthly.py → test_foundation_config_logging_monthly.py} +49 -3
- tests/foundation/config/logging/{test_logging_stack.py → test_foundation_config_logging_stack.py} +50 -15
- tests/foundation/config/logging/{test_logging_weekly.py → test_foundation_config_logging_weekly.py} +93 -3
- tests/foundation/config/mail/test_foundation_config_mail.py +145 -0
- tests/foundation/config/mail/{test_mail_file.py → test_foundation_config_mail_file.py} +41 -5
- tests/foundation/config/mail/test_foundation_config_mail_mailers.py +106 -0
- tests/foundation/config/mail/{test_mail_smtp.py → test_foundation_config_mail_smtp.py} +59 -15
- tests/foundation/config/queue/test_foundation_config_queue.py +111 -0
- tests/foundation/config/queue/{test_queue_brokers.py → test_foundation_config_queue_brokers.py} +28 -11
- tests/foundation/config/queue/{test_queue_database.py → test_foundation_config_queue_database.py} +54 -16
- tests/foundation/config/root/{test_root_paths.py → test_foundation_config_root_paths.py} +70 -3
- tests/foundation/config/session/{test_session.py → test_foundation_config_session.py} +31 -2
- tests/foundation/config/startup/{test_config_startup.py → test_foundation_config_startup.py} +91 -21
- tests/foundation/config/testing/{test_testing.py → test_foundation_config_testing.py} +69 -1
- tests/patterns/singleton/test_patterns_singleton.py +27 -0
- tests/services/asynchrony/{test_async_io.py → test_services_asynchrony_coroutine.py} +1 -1
- tests/services/environment/test_services_environment.py +93 -0
- tests/services/path/{test_resolver.py → test_services_resolver.py} +51 -12
- tests/services/standard/{test_std.py → test_services_std.py} +45 -22
- tests/services/system/__init__.py +0 -0
- tests/services/system/test_services_system_imports.py +101 -0
- tests/services/system/test_services_system_workers.py +89 -0
- tests/services/wrapper/{test_wrapper_doc_dict.py → test_services_wrapper_docdict.py} +28 -16
- tests/testing/test_testing_result.py +57 -20
- tests/testing/test_testing_unit.py +110 -41
- orionis/services/environment/exceptions/value_exception.py +0 -27
- tests/foundation/config/cache/test_cache_file.py +0 -78
- tests/foundation/config/cache/test_cache_stores.py +0 -88
- tests/foundation/config/cors/test_cors.py +0 -121
- tests/foundation/config/logging/test_logging.py +0 -48
- tests/foundation/config/mail/test_mail.py +0 -73
- tests/foundation/config/mail/test_mail_mailers.py +0 -58
- tests/foundation/config/queue/test_queue.py +0 -58
- tests/patterns/singleton/test_singleton.py +0 -18
- tests/services/environment/test_env.py +0 -155
- {orionis-0.286.0.dist-info → orionis-0.288.0.dist-info}/WHEEL +0 -0
- {orionis-0.286.0.dist-info → orionis-0.288.0.dist-info}/licenses/LICENCE +0 -0
- {orionis-0.286.0.dist-info → orionis-0.288.0.dist-info}/top_level.txt +0 -0
- {orionis-0.286.0.dist-info → orionis-0.288.0.dist-info}/zip-safe +0 -0
@@ -0,0 +1,148 @@
|
|
1
|
+
from orionis.foundation.config.cache.entities.stores import Stores
|
2
|
+
from orionis.foundation.config.cache.entities.file import File
|
3
|
+
from orionis.foundation.config.exceptions.integrity import OrionisIntegrityException
|
4
|
+
from orionis.unittesting import TestCase
|
5
|
+
|
6
|
+
class TestFoundationConfigCacheStores(TestCase):
|
7
|
+
"""
|
8
|
+
Test cases for the Stores cache configuration entity.
|
9
|
+
|
10
|
+
This class contains asynchronous unit tests for the `Stores` entity,
|
11
|
+
validating its initialization, type enforcement, dictionary conversion,
|
12
|
+
hashability, and keyword-only argument enforcement.
|
13
|
+
|
14
|
+
Attributes
|
15
|
+
----------
|
16
|
+
None
|
17
|
+
"""
|
18
|
+
|
19
|
+
async def testDefaultFileStore(self):
|
20
|
+
"""
|
21
|
+
Test initialization with default File instance.
|
22
|
+
|
23
|
+
Ensures that `Stores` initializes with a default `File` instance and
|
24
|
+
that the `file` attribute is properly set with the default configuration.
|
25
|
+
|
26
|
+
Returns
|
27
|
+
-------
|
28
|
+
None
|
29
|
+
"""
|
30
|
+
stores = Stores()
|
31
|
+
self.assertIsInstance(stores.file, File)
|
32
|
+
self.assertEqual(stores.file.path, 'storage/framework/cache/data')
|
33
|
+
|
34
|
+
async def testCustomFileStore(self):
|
35
|
+
"""
|
36
|
+
Test initialization with a custom File configuration.
|
37
|
+
|
38
|
+
Ensures that a custom `File` instance can be provided during
|
39
|
+
initialization and is correctly assigned to the `file` attribute.
|
40
|
+
|
41
|
+
Returns
|
42
|
+
-------
|
43
|
+
None
|
44
|
+
"""
|
45
|
+
custom_file = File(path='custom/cache/path')
|
46
|
+
stores = Stores(file=custom_file)
|
47
|
+
self.assertIsInstance(stores.file, File)
|
48
|
+
self.assertEqual(stores.file.path, 'custom/cache/path')
|
49
|
+
|
50
|
+
async def testFileTypeValidation(self):
|
51
|
+
"""
|
52
|
+
Test type validation for the file attribute.
|
53
|
+
|
54
|
+
Ensures that providing a non-`File` instance to the `file` attribute
|
55
|
+
raises an `OrionisIntegrityException`.
|
56
|
+
|
57
|
+
Returns
|
58
|
+
-------
|
59
|
+
None
|
60
|
+
|
61
|
+
Raises
|
62
|
+
------
|
63
|
+
OrionisIntegrityException
|
64
|
+
If the `file` attribute is not a `File` instance.
|
65
|
+
"""
|
66
|
+
with self.assertRaises(OrionisIntegrityException):
|
67
|
+
Stores(file="not_a_file_instance")
|
68
|
+
|
69
|
+
with self.assertRaises(OrionisIntegrityException):
|
70
|
+
Stores(file=123)
|
71
|
+
|
72
|
+
with self.assertRaises(OrionisIntegrityException):
|
73
|
+
Stores(file=None)
|
74
|
+
|
75
|
+
async def testToDictMethodWithDefaults(self):
|
76
|
+
"""
|
77
|
+
Test dictionary representation with default values.
|
78
|
+
|
79
|
+
Ensures that `toDict` returns a dictionary with the correct default
|
80
|
+
file path.
|
81
|
+
|
82
|
+
Returns
|
83
|
+
-------
|
84
|
+
None
|
85
|
+
"""
|
86
|
+
stores = Stores()
|
87
|
+
stores_dict = stores.toDict()
|
88
|
+
|
89
|
+
self.assertIsInstance(stores_dict, dict)
|
90
|
+
self.assertIsInstance(stores_dict['file'], dict)
|
91
|
+
self.assertEqual(stores_dict['file']['path'], 'storage/framework/cache/data')
|
92
|
+
|
93
|
+
async def testToDictMethodWithCustomFile(self):
|
94
|
+
"""
|
95
|
+
Test dictionary representation with custom file configuration.
|
96
|
+
|
97
|
+
Ensures that `toDict` reflects custom file paths in its dictionary
|
98
|
+
representation.
|
99
|
+
|
100
|
+
Returns
|
101
|
+
-------
|
102
|
+
None
|
103
|
+
"""
|
104
|
+
custom_file = File(path='alternate/cache/location')
|
105
|
+
stores = Stores(file=custom_file)
|
106
|
+
stores_dict = stores.toDict()
|
107
|
+
|
108
|
+
self.assertEqual(stores_dict['file']['path'], 'alternate/cache/location')
|
109
|
+
|
110
|
+
async def testHashability(self):
|
111
|
+
"""
|
112
|
+
Test hashability of Stores instances.
|
113
|
+
|
114
|
+
Ensures that `Stores` instances are hashable and can be used in sets
|
115
|
+
and as dictionary keys.
|
116
|
+
|
117
|
+
Returns
|
118
|
+
-------
|
119
|
+
None
|
120
|
+
"""
|
121
|
+
store1 = Stores()
|
122
|
+
store2 = Stores()
|
123
|
+
store_set = {store1, store2}
|
124
|
+
|
125
|
+
self.assertEqual(len(store_set), 1)
|
126
|
+
|
127
|
+
custom_store = Stores(file=File(path='custom/path'))
|
128
|
+
store_set.add(custom_store)
|
129
|
+
self.assertEqual(len(store_set), 2)
|
130
|
+
|
131
|
+
async def testKwOnlyInitialization(self):
|
132
|
+
"""
|
133
|
+
Test keyword-only initialization enforcement.
|
134
|
+
|
135
|
+
Ensures that `Stores` enforces keyword-only arguments and does not
|
136
|
+
allow positional arguments during initialization.
|
137
|
+
|
138
|
+
Returns
|
139
|
+
-------
|
140
|
+
None
|
141
|
+
|
142
|
+
Raises
|
143
|
+
------
|
144
|
+
TypeError
|
145
|
+
If positional arguments are provided during initialization.
|
146
|
+
"""
|
147
|
+
with self.assertRaises(TypeError):
|
148
|
+
Stores(File())
|
@@ -0,0 +1,190 @@
|
|
1
|
+
from orionis.foundation.config.cors.entities.cors import Cors
|
2
|
+
from orionis.foundation.config.exceptions.integrity import OrionisIntegrityException
|
3
|
+
from orionis.unittesting import TestCase
|
4
|
+
|
5
|
+
class TestFoundationConfigCors(TestCase):
|
6
|
+
"""
|
7
|
+
Unit tests for Cors configuration defaults and validation.
|
8
|
+
|
9
|
+
Notes
|
10
|
+
-----
|
11
|
+
These tests verify the default values, custom value assignment, and type validation
|
12
|
+
for the `Cors` configuration entity.
|
13
|
+
"""
|
14
|
+
|
15
|
+
async def testDefaultValues(self):
|
16
|
+
"""
|
17
|
+
Test the default values of the Cors configuration.
|
18
|
+
|
19
|
+
Verifies that a newly instantiated Cors object has the expected default settings.
|
20
|
+
|
21
|
+
Expected Defaults
|
22
|
+
-----------------
|
23
|
+
allow_origins : list of str
|
24
|
+
["*"]
|
25
|
+
allow_origin_regex : None or str
|
26
|
+
None
|
27
|
+
allow_methods : list of str
|
28
|
+
["*"]
|
29
|
+
allow_headers : list of str
|
30
|
+
["*"]
|
31
|
+
expose_headers : list of str
|
32
|
+
[]
|
33
|
+
allow_credentials : bool
|
34
|
+
False
|
35
|
+
max_age : int
|
36
|
+
600
|
37
|
+
"""
|
38
|
+
cors = Cors()
|
39
|
+
self.assertEqual(cors.allow_origins, ["*"])
|
40
|
+
self.assertIsNone(cors.allow_origin_regex)
|
41
|
+
self.assertEqual(cors.allow_methods, ["*"])
|
42
|
+
self.assertEqual(cors.allow_headers, ["*"])
|
43
|
+
self.assertEqual(cors.expose_headers, [])
|
44
|
+
self.assertFalse(cors.allow_credentials)
|
45
|
+
self.assertEqual(cors.max_age, 600)
|
46
|
+
|
47
|
+
async def testCustomValues(self):
|
48
|
+
"""
|
49
|
+
Test custom value assignment for all Cors configuration parameters.
|
50
|
+
|
51
|
+
Ensures that the Cors object accurately reflects the provided custom configuration values.
|
52
|
+
|
53
|
+
Parameters
|
54
|
+
----------
|
55
|
+
allow_origins : list of str
|
56
|
+
Custom list of allowed origins.
|
57
|
+
allow_origin_regex : str
|
58
|
+
Custom regex pattern for allowed origins.
|
59
|
+
allow_methods : list of str
|
60
|
+
Custom list of allowed HTTP methods.
|
61
|
+
allow_headers : list of str
|
62
|
+
Custom list of allowed headers.
|
63
|
+
expose_headers : list of str
|
64
|
+
Custom list of exposed headers.
|
65
|
+
allow_credentials : bool
|
66
|
+
Whether credentials are allowed.
|
67
|
+
max_age : int
|
68
|
+
Custom max age value.
|
69
|
+
"""
|
70
|
+
cors = Cors(
|
71
|
+
allow_origins=["https://example.com"],
|
72
|
+
allow_origin_regex="^https://.*\\.example\\.com$",
|
73
|
+
allow_methods=["GET", "POST"],
|
74
|
+
allow_headers=["Authorization", "Content-Type"],
|
75
|
+
expose_headers=["X-Custom-Header"],
|
76
|
+
allow_credentials=True,
|
77
|
+
max_age=3600
|
78
|
+
)
|
79
|
+
self.assertEqual(cors.allow_origins, ["https://example.com"])
|
80
|
+
self.assertEqual(cors.allow_origin_regex, "^https://.*\\.example\\.com$")
|
81
|
+
self.assertEqual(cors.allow_methods, ["GET", "POST"])
|
82
|
+
self.assertEqual(cors.allow_headers, ["Authorization", "Content-Type"])
|
83
|
+
self.assertEqual(cors.expose_headers, ["X-Custom-Header"])
|
84
|
+
self.assertTrue(cors.allow_credentials)
|
85
|
+
self.assertEqual(cors.max_age, 3600)
|
86
|
+
|
87
|
+
async def testInvalidAllowOriginsType(self):
|
88
|
+
"""
|
89
|
+
Test type validation for 'allow_origins' parameter.
|
90
|
+
|
91
|
+
Ensures that passing a string instead of a list to the `allow_origins` parameter
|
92
|
+
raises an OrionisIntegrityException.
|
93
|
+
|
94
|
+
Raises
|
95
|
+
------
|
96
|
+
OrionisIntegrityException
|
97
|
+
If `allow_origins` is not a list.
|
98
|
+
"""
|
99
|
+
with self.assertRaises(OrionisIntegrityException):
|
100
|
+
Cors(allow_origins="*")
|
101
|
+
|
102
|
+
async def testInvalidAllowOriginRegexType(self):
|
103
|
+
"""
|
104
|
+
Test type validation for 'allow_origin_regex' parameter.
|
105
|
+
|
106
|
+
Ensures that passing a non-string, non-None value (e.g., integer) to the
|
107
|
+
`allow_origin_regex` parameter raises an OrionisIntegrityException.
|
108
|
+
|
109
|
+
Raises
|
110
|
+
------
|
111
|
+
OrionisIntegrityException
|
112
|
+
If `allow_origin_regex` is not a string or None.
|
113
|
+
"""
|
114
|
+
with self.assertRaises(OrionisIntegrityException):
|
115
|
+
Cors(allow_origin_regex=123)
|
116
|
+
|
117
|
+
async def testInvalidAllowMethodsType(self):
|
118
|
+
"""
|
119
|
+
Test type validation for 'allow_methods' parameter.
|
120
|
+
|
121
|
+
Ensures that passing a string instead of a list to the `allow_methods` parameter
|
122
|
+
raises an OrionisIntegrityException.
|
123
|
+
|
124
|
+
Raises
|
125
|
+
------
|
126
|
+
OrionisIntegrityException
|
127
|
+
If `allow_methods` is not a list.
|
128
|
+
"""
|
129
|
+
with self.assertRaises(OrionisIntegrityException):
|
130
|
+
Cors(allow_methods="GET")
|
131
|
+
|
132
|
+
async def testInvalidAllowHeadersType(self):
|
133
|
+
"""
|
134
|
+
Test type validation for 'allow_headers' parameter.
|
135
|
+
|
136
|
+
Ensures that passing a string instead of a list to the `allow_headers` parameter
|
137
|
+
raises an OrionisIntegrityException.
|
138
|
+
|
139
|
+
Raises
|
140
|
+
------
|
141
|
+
OrionisIntegrityException
|
142
|
+
If `allow_headers` is not a list.
|
143
|
+
"""
|
144
|
+
with self.assertRaises(OrionisIntegrityException):
|
145
|
+
Cors(allow_headers="Authorization")
|
146
|
+
|
147
|
+
async def testInvalidExposeHeadersType(self):
|
148
|
+
"""
|
149
|
+
Test type validation for 'expose_headers' parameter.
|
150
|
+
|
151
|
+
Ensures that passing a string instead of a list to the `expose_headers` parameter
|
152
|
+
raises an OrionisIntegrityException.
|
153
|
+
|
154
|
+
Raises
|
155
|
+
------
|
156
|
+
OrionisIntegrityException
|
157
|
+
If `expose_headers` is not a list.
|
158
|
+
"""
|
159
|
+
with self.assertRaises(OrionisIntegrityException):
|
160
|
+
Cors(expose_headers="X-Custom-Header")
|
161
|
+
|
162
|
+
async def testInvalidAllowCredentialsType(self):
|
163
|
+
"""
|
164
|
+
Test type validation for 'allow_credentials' parameter.
|
165
|
+
|
166
|
+
Ensures that passing a non-boolean value to the `allow_credentials` parameter
|
167
|
+
raises an OrionisIntegrityException.
|
168
|
+
|
169
|
+
Raises
|
170
|
+
------
|
171
|
+
OrionisIntegrityException
|
172
|
+
If `allow_credentials` is not a boolean.
|
173
|
+
"""
|
174
|
+
with self.assertRaises(OrionisIntegrityException):
|
175
|
+
Cors(allow_credentials="yes")
|
176
|
+
|
177
|
+
async def testInvalidMaxAgeType(self):
|
178
|
+
"""
|
179
|
+
Test type validation for 'max_age' parameter.
|
180
|
+
|
181
|
+
Ensures that passing a non-integer value (e.g., string) to the `max_age` parameter
|
182
|
+
raises an OrionisIntegrityException.
|
183
|
+
|
184
|
+
Raises
|
185
|
+
------
|
186
|
+
OrionisIntegrityException
|
187
|
+
If `max_age` is not an integer or None.
|
188
|
+
"""
|
189
|
+
with self.assertRaises(OrionisIntegrityException):
|
190
|
+
Cors(max_age="3600")
|
@@ -3,15 +3,25 @@ from orionis.foundation.config.database.entities.connections import Connections
|
|
3
3
|
from orionis.foundation.config.exceptions.integrity import OrionisIntegrityException
|
4
4
|
from orionis.unittesting import TestCase
|
5
5
|
|
6
|
-
class
|
6
|
+
class TestFoundationConfigDatabase(TestCase):
|
7
7
|
"""
|
8
8
|
Test cases for the Database configuration class.
|
9
|
+
|
10
|
+
This class contains unit tests for the `Database` configuration class,
|
11
|
+
ensuring correct default values, validation, dictionary representation,
|
12
|
+
custom values, hashability, and keyword-only initialization.
|
13
|
+
|
14
|
+
Attributes
|
15
|
+
----------
|
16
|
+
None
|
9
17
|
"""
|
10
18
|
|
11
19
|
async def testDefaultValues(self):
|
12
20
|
"""
|
13
|
-
Test
|
14
|
-
|
21
|
+
Test creation of Database instance with default values.
|
22
|
+
|
23
|
+
Ensures that the default connection is set to 'sqlite' and the
|
24
|
+
connections attribute is properly initialized as a Connections instance.
|
15
25
|
"""
|
16
26
|
db = Database()
|
17
27
|
self.assertEqual(db.default, 'sqlite')
|
@@ -19,8 +29,11 @@ class TestConfigDatabase(TestCase):
|
|
19
29
|
|
20
30
|
async def testDefaultConnectionValidation(self):
|
21
31
|
"""
|
22
|
-
|
23
|
-
|
32
|
+
Validate the default connection attribute.
|
33
|
+
|
34
|
+
Checks that only valid connection types are accepted as default.
|
35
|
+
Also verifies that invalid, empty, or non-string defaults raise
|
36
|
+
OrionisIntegrityException.
|
24
37
|
"""
|
25
38
|
# Test valid connection types
|
26
39
|
valid_connections = ['sqlite', 'mysql', 'pgsql', 'oracle']
|
@@ -44,8 +57,11 @@ class TestConfigDatabase(TestCase):
|
|
44
57
|
|
45
58
|
async def testConnectionsValidation(self):
|
46
59
|
"""
|
47
|
-
|
48
|
-
|
60
|
+
Validate the connections attribute.
|
61
|
+
|
62
|
+
Ensures that only instances of Connections are accepted for the
|
63
|
+
connections attribute. Invalid types or None should raise
|
64
|
+
OrionisIntegrityException.
|
49
65
|
"""
|
50
66
|
# Test invalid connections type
|
51
67
|
with self.assertRaises(OrionisIntegrityException):
|
@@ -63,8 +79,10 @@ class TestConfigDatabase(TestCase):
|
|
63
79
|
|
64
80
|
async def testToDictMethod(self):
|
65
81
|
"""
|
66
|
-
Test
|
67
|
-
|
82
|
+
Test the toDict method of Database.
|
83
|
+
|
84
|
+
Ensures that the toDict method returns a dictionary representation
|
85
|
+
of the Database instance, including all attributes.
|
68
86
|
"""
|
69
87
|
db = Database()
|
70
88
|
db_dict = db.toDict()
|
@@ -74,8 +92,10 @@ class TestConfigDatabase(TestCase):
|
|
74
92
|
|
75
93
|
async def testCustomValues(self):
|
76
94
|
"""
|
77
|
-
Test
|
78
|
-
|
95
|
+
Test storage and validation of custom values.
|
96
|
+
|
97
|
+
Ensures that custom configurations for default and connections
|
98
|
+
are correctly handled and validated.
|
79
99
|
"""
|
80
100
|
custom_connections = Connections()
|
81
101
|
custom_db = Database(
|
@@ -87,8 +107,10 @@ class TestConfigDatabase(TestCase):
|
|
87
107
|
|
88
108
|
async def testHashability(self):
|
89
109
|
"""
|
90
|
-
Test
|
91
|
-
|
110
|
+
Test hashability of Database instances.
|
111
|
+
|
112
|
+
Ensures that Database instances are hashable (due to unsafe_hash=True)
|
113
|
+
and can be used in sets and as dictionary keys.
|
92
114
|
"""
|
93
115
|
db1 = Database()
|
94
116
|
db2 = Database()
|
@@ -101,8 +123,10 @@ class TestConfigDatabase(TestCase):
|
|
101
123
|
|
102
124
|
async def testKwOnlyInitialization(self):
|
103
125
|
"""
|
104
|
-
Test
|
105
|
-
|
126
|
+
Test keyword-only initialization enforcement.
|
127
|
+
|
128
|
+
Ensures that Database enforces keyword-only initialization and
|
129
|
+
raises TypeError when positional arguments are used.
|
106
130
|
"""
|
107
131
|
with self.assertRaises(TypeError):
|
108
132
|
Database('sqlite', Connections())
|
@@ -6,15 +6,24 @@ from orionis.foundation.config.database.entities.sqlite import SQLite
|
|
6
6
|
from orionis.foundation.config.exceptions.integrity import OrionisIntegrityException
|
7
7
|
from orionis.unittesting import TestCase
|
8
8
|
|
9
|
-
class
|
9
|
+
class TestFoundationConfigDatabaseConnections(TestCase):
|
10
10
|
"""
|
11
11
|
Test cases for the Connections configuration class.
|
12
|
+
|
13
|
+
This class contains unit tests to validate the behavior and integrity of the
|
14
|
+
Connections class, ensuring correct type validation, default values, dictionary
|
15
|
+
representation, custom connection handling, hashability, and keyword-only initialization.
|
12
16
|
"""
|
13
17
|
|
14
18
|
async def testDefaultValues(self):
|
15
19
|
"""
|
16
20
|
Test that Connections instance is created with correct default values.
|
21
|
+
|
17
22
|
Verifies all default connections are properly initialized with their respective types.
|
23
|
+
|
24
|
+
Returns
|
25
|
+
-------
|
26
|
+
None
|
18
27
|
"""
|
19
28
|
connections = Connections()
|
20
29
|
self.assertIsInstance(connections.sqlite, SQLite)
|
@@ -25,7 +34,17 @@ class TestConfigConnections(TestCase):
|
|
25
34
|
async def testSqliteTypeValidation(self):
|
26
35
|
"""
|
27
36
|
Test sqlite attribute type validation.
|
28
|
-
|
37
|
+
|
38
|
+
Verifies that only SQLite instances are accepted for the sqlite attribute.
|
39
|
+
|
40
|
+
Returns
|
41
|
+
-------
|
42
|
+
None
|
43
|
+
|
44
|
+
Raises
|
45
|
+
------
|
46
|
+
OrionisIntegrityException
|
47
|
+
If the sqlite attribute is not a valid SQLite instance.
|
29
48
|
"""
|
30
49
|
with self.assertRaises(OrionisIntegrityException):
|
31
50
|
Connections(sqlite="not_a_sqlite_instance")
|
@@ -37,7 +56,17 @@ class TestConfigConnections(TestCase):
|
|
37
56
|
async def testMysqlTypeValidation(self):
|
38
57
|
"""
|
39
58
|
Test mysql attribute type validation.
|
40
|
-
|
59
|
+
|
60
|
+
Verifies that only MySQL instances are accepted for the mysql attribute.
|
61
|
+
|
62
|
+
Returns
|
63
|
+
-------
|
64
|
+
None
|
65
|
+
|
66
|
+
Raises
|
67
|
+
------
|
68
|
+
OrionisIntegrityException
|
69
|
+
If the mysql attribute is not a valid MySQL instance.
|
41
70
|
"""
|
42
71
|
with self.assertRaises(OrionisIntegrityException):
|
43
72
|
Connections(mysql="not_a_mysql_instance")
|
@@ -49,7 +78,17 @@ class TestConfigConnections(TestCase):
|
|
49
78
|
async def testPgsqlTypeValidation(self):
|
50
79
|
"""
|
51
80
|
Test pgsql attribute type validation.
|
52
|
-
|
81
|
+
|
82
|
+
Verifies that only PGSQL instances are accepted for the pgsql attribute.
|
83
|
+
|
84
|
+
Returns
|
85
|
+
-------
|
86
|
+
None
|
87
|
+
|
88
|
+
Raises
|
89
|
+
------
|
90
|
+
OrionisIntegrityException
|
91
|
+
If the pgsql attribute is not a valid PGSQL instance.
|
53
92
|
"""
|
54
93
|
with self.assertRaises(OrionisIntegrityException):
|
55
94
|
Connections(pgsql="not_a_pgsql_instance")
|
@@ -61,7 +100,17 @@ class TestConfigConnections(TestCase):
|
|
61
100
|
async def testOracleTypeValidation(self):
|
62
101
|
"""
|
63
102
|
Test oracle attribute type validation.
|
64
|
-
|
103
|
+
|
104
|
+
Verifies that only Oracle instances are accepted for the oracle attribute.
|
105
|
+
|
106
|
+
Returns
|
107
|
+
-------
|
108
|
+
None
|
109
|
+
|
110
|
+
Raises
|
111
|
+
------
|
112
|
+
OrionisIntegrityException
|
113
|
+
If the oracle attribute is not a valid Oracle instance.
|
65
114
|
"""
|
66
115
|
with self.assertRaises(OrionisIntegrityException):
|
67
116
|
Connections(oracle="not_an_oracle_instance")
|
@@ -73,7 +122,12 @@ class TestConfigConnections(TestCase):
|
|
73
122
|
async def testToDictMethod(self):
|
74
123
|
"""
|
75
124
|
Test that toDict returns proper dictionary representation.
|
76
|
-
|
125
|
+
|
126
|
+
Verifies all connections are correctly included in the dictionary.
|
127
|
+
|
128
|
+
Returns
|
129
|
+
-------
|
130
|
+
None
|
77
131
|
"""
|
78
132
|
connections = Connections()
|
79
133
|
connections_dict = connections.toDict()
|
@@ -86,7 +140,12 @@ class TestConfigConnections(TestCase):
|
|
86
140
|
async def testCustomConnections(self):
|
87
141
|
"""
|
88
142
|
Test that custom connections are properly stored and validated.
|
143
|
+
|
89
144
|
Verifies custom connection configurations are correctly handled.
|
145
|
+
|
146
|
+
Returns
|
147
|
+
-------
|
148
|
+
None
|
90
149
|
"""
|
91
150
|
custom_sqlite = SQLite(database='custom.db')
|
92
151
|
custom_mysql = MySQL(database='custom_db')
|
@@ -108,7 +167,12 @@ class TestConfigConnections(TestCase):
|
|
108
167
|
async def testHashability(self):
|
109
168
|
"""
|
110
169
|
Test that Connections maintains hashability due to unsafe_hash=True.
|
170
|
+
|
111
171
|
Verifies that Connections instances can be used in sets and as dictionary keys.
|
172
|
+
|
173
|
+
Returns
|
174
|
+
-------
|
175
|
+
None
|
112
176
|
"""
|
113
177
|
conn1 = Connections()
|
114
178
|
conn2 = Connections()
|
@@ -123,7 +187,17 @@ class TestConfigConnections(TestCase):
|
|
123
187
|
async def testKwOnlyInitialization(self):
|
124
188
|
"""
|
125
189
|
Test that Connections enforces keyword-only initialization.
|
190
|
+
|
126
191
|
Verifies that positional arguments are not allowed for initialization.
|
192
|
+
|
193
|
+
Returns
|
194
|
+
-------
|
195
|
+
None
|
196
|
+
|
197
|
+
Raises
|
198
|
+
------
|
199
|
+
TypeError
|
200
|
+
If positional arguments are used for initialization.
|
127
201
|
"""
|
128
202
|
with self.assertRaises(TypeError):
|
129
203
|
Connections(SQLite(), MySQL(), PGSQL(), Oracle())
|