orionis 0.286.0__py3-none-any.whl → 0.287.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/dot_env.py +205 -181
- orionis/services/environment/env.py +68 -85
- orionis/services/environment/exceptions/environment_value_error.py +18 -0
- orionis/services/environment/exceptions/environment_value_exception.py +23 -0
- orionis/services/environment/type_hint.py +559 -0
- orionis/test/logs/history.py +3 -5
- {orionis-0.286.0.dist-info → orionis-0.287.0.dist-info}/METADATA +1 -1
- {orionis-0.286.0.dist-info → orionis-0.287.0.dist-info}/RECORD +56 -54
- tests/example/test_example.py +5 -2
- tests/foundation/config/app/test_app.py +13 -3
- tests/foundation/config/auth/test_auth.py +9 -4
- tests/foundation/config/cache/test_cache.py +60 -15
- tests/foundation/config/cache/test_cache_file.py +62 -14
- tests/foundation/config/cache/test_cache_stores.py +74 -14
- tests/foundation/config/cors/test_cors.py +102 -33
- tests/foundation/config/database/test_database.py +38 -14
- tests/foundation/config/database/test_database_connections.py +79 -5
- tests/foundation/config/database/test_database_mysql.py +138 -15
- tests/foundation/config/database/test_database_oracle.py +110 -26
- tests/foundation/config/database/test_database_pgsql.py +96 -26
- tests/foundation/config/database/test_database_sqlite.py +56 -2
- tests/foundation/config/exceptions/test_exceptions_integrity.py +44 -10
- tests/foundation/config/filesystems/test_filesystems.py +64 -14
- tests/foundation/config/filesystems/test_filesystems_aws.py +45 -7
- tests/foundation/config/filesystems/test_filesystems_disks.py +78 -8
- tests/foundation/config/filesystems/test_filesystems_local.py +66 -18
- tests/foundation/config/filesystems/test_filesystems_public.py +37 -0
- tests/foundation/config/logging/test_logging.py +75 -11
- tests/foundation/config/logging/test_logging_channels.py +79 -2
- tests/foundation/config/logging/test_logging_chunked.py +85 -12
- tests/foundation/config/logging/test_logging_daily.py +79 -12
- tests/foundation/config/logging/test_logging_hourly.py +68 -2
- tests/foundation/config/logging/test_logging_monthly.py +48 -2
- tests/foundation/config/logging/test_logging_stack.py +49 -14
- tests/foundation/config/logging/test_logging_weekly.py +92 -2
- tests/foundation/config/mail/test_mail.py +87 -15
- tests/foundation/config/mail/test_mail_file.py +40 -4
- tests/foundation/config/mail/test_mail_mailers.py +56 -8
- tests/foundation/config/mail/test_mail_smtp.py +58 -14
- tests/foundation/config/queue/test_queue.py +62 -9
- tests/foundation/config/queue/test_queue_brokers.py +27 -10
- tests/foundation/config/queue/test_queue_database.py +53 -15
- tests/foundation/config/root/test_root_paths.py +69 -2
- tests/foundation/config/session/test_session.py +30 -1
- tests/foundation/config/startup/test_config_startup.py +77 -7
- tests/foundation/config/testing/test_testing.py +68 -0
- tests/patterns/singleton/test_singleton.py +10 -1
- tests/services/environment/test_env.py +3 -4
- tests/testing/test_testing_result.py +56 -19
- tests/testing/test_testing_unit.py +93 -24
- orionis/services/environment/exceptions/value_exception.py +0 -27
- {orionis-0.286.0.dist-info → orionis-0.287.0.dist-info}/WHEEL +0 -0
- {orionis-0.286.0.dist-info → orionis-0.287.0.dist-info}/licenses/LICENCE +0 -0
- {orionis-0.286.0.dist-info → orionis-0.287.0.dist-info}/top_level.txt +0 -0
- {orionis-0.286.0.dist-info → orionis-0.287.0.dist-info}/zip-safe +0 -0
@@ -8,12 +8,21 @@ from orionis.unittesting import TestCase
|
|
8
8
|
class TestConfigSQLite(TestCase):
|
9
9
|
"""
|
10
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.
|
11
15
|
"""
|
12
16
|
|
13
17
|
async def testDefaultValues(self):
|
14
18
|
"""
|
15
19
|
Test that SQLite instance is created with correct default values.
|
16
|
-
|
20
|
+
|
21
|
+
Ensures all default values match expected defaults from the class definition.
|
22
|
+
|
23
|
+
Returns
|
24
|
+
-------
|
25
|
+
None
|
17
26
|
"""
|
18
27
|
sqlite = SQLite()
|
19
28
|
self.assertEqual(sqlite.driver, 'sqlite')
|
@@ -28,7 +37,12 @@ class TestConfigSQLite(TestCase):
|
|
28
37
|
async def testDriverValidation(self):
|
29
38
|
"""
|
30
39
|
Test driver attribute validation.
|
40
|
+
|
31
41
|
Verifies that empty or non-string drivers raise exceptions.
|
42
|
+
|
43
|
+
Returns
|
44
|
+
-------
|
45
|
+
None
|
32
46
|
"""
|
33
47
|
with self.assertRaises(OrionisIntegrityException):
|
34
48
|
SQLite(driver='')
|
@@ -38,7 +52,12 @@ class TestConfigSQLite(TestCase):
|
|
38
52
|
async def testUrlValidation(self):
|
39
53
|
"""
|
40
54
|
Test URL attribute validation.
|
55
|
+
|
41
56
|
Verifies that empty or non-string URLs raise exceptions.
|
57
|
+
|
58
|
+
Returns
|
59
|
+
-------
|
60
|
+
None
|
42
61
|
"""
|
43
62
|
with self.assertRaises(OrionisIntegrityException):
|
44
63
|
SQLite(url='')
|
@@ -48,7 +67,12 @@ class TestConfigSQLite(TestCase):
|
|
48
67
|
async def testDatabaseValidation(self):
|
49
68
|
"""
|
50
69
|
Test database attribute validation.
|
70
|
+
|
51
71
|
Verifies that empty or non-string database paths raise exceptions.
|
72
|
+
|
73
|
+
Returns
|
74
|
+
-------
|
75
|
+
None
|
52
76
|
"""
|
53
77
|
with self.assertRaises(OrionisIntegrityException):
|
54
78
|
SQLite(database='')
|
@@ -58,7 +82,12 @@ class TestConfigSQLite(TestCase):
|
|
58
82
|
async def testForeignKeyConstraintsValidation(self):
|
59
83
|
"""
|
60
84
|
Test foreign_key_constraints attribute validation.
|
85
|
+
|
61
86
|
Verifies enum conversion and invalid value handling.
|
87
|
+
|
88
|
+
Returns
|
89
|
+
-------
|
90
|
+
None
|
62
91
|
"""
|
63
92
|
# Test string conversion
|
64
93
|
sqlite = SQLite(foreign_key_constraints='ON')
|
@@ -75,7 +104,12 @@ class TestConfigSQLite(TestCase):
|
|
75
104
|
async def testBusyTimeoutValidation(self):
|
76
105
|
"""
|
77
106
|
Test busy_timeout attribute validation.
|
107
|
+
|
78
108
|
Verifies non-negative integer requirement.
|
109
|
+
|
110
|
+
Returns
|
111
|
+
-------
|
112
|
+
None
|
79
113
|
"""
|
80
114
|
with self.assertRaises(OrionisIntegrityException):
|
81
115
|
SQLite(busy_timeout=-1)
|
@@ -85,7 +119,12 @@ class TestConfigSQLite(TestCase):
|
|
85
119
|
async def testJournalModeValidation(self):
|
86
120
|
"""
|
87
121
|
Test journal_mode attribute validation.
|
122
|
+
|
88
123
|
Verifies enum conversion and invalid value handling.
|
124
|
+
|
125
|
+
Returns
|
126
|
+
-------
|
127
|
+
None
|
89
128
|
"""
|
90
129
|
# Test string conversion
|
91
130
|
sqlite = SQLite(journal_mode='WAL')
|
@@ -102,7 +141,12 @@ class TestConfigSQLite(TestCase):
|
|
102
141
|
async def testSynchronousValidation(self):
|
103
142
|
"""
|
104
143
|
Test synchronous attribute validation.
|
144
|
+
|
105
145
|
Verifies enum conversion and invalid value handling.
|
146
|
+
|
147
|
+
Returns
|
148
|
+
-------
|
149
|
+
None
|
106
150
|
"""
|
107
151
|
# Test string conversion
|
108
152
|
sqlite = SQLite(synchronous='FULL')
|
@@ -119,7 +163,12 @@ class TestConfigSQLite(TestCase):
|
|
119
163
|
async def testToDictMethod(self):
|
120
164
|
"""
|
121
165
|
Test that toDict returns proper dictionary representation.
|
122
|
-
|
166
|
+
|
167
|
+
Verifies all attributes are correctly included in the dictionary.
|
168
|
+
|
169
|
+
Returns
|
170
|
+
-------
|
171
|
+
None
|
123
172
|
"""
|
124
173
|
sqlite = SQLite()
|
125
174
|
sqlite_dict = sqlite.toDict()
|
@@ -135,7 +184,12 @@ class TestConfigSQLite(TestCase):
|
|
135
184
|
async def testCustomValues(self):
|
136
185
|
"""
|
137
186
|
Test that custom values are properly stored and validated.
|
187
|
+
|
138
188
|
Verifies custom configuration values are correctly handled.
|
189
|
+
|
190
|
+
Returns
|
191
|
+
-------
|
192
|
+
None
|
139
193
|
"""
|
140
194
|
custom_sqlite = SQLite(
|
141
195
|
database='custom.db',
|
@@ -4,12 +4,21 @@ from orionis.unittesting import TestCase
|
|
4
4
|
class TestOrionisIntegrityException(TestCase):
|
5
5
|
"""
|
6
6
|
Test cases for the OrionisIntegrityException class.
|
7
|
+
|
8
|
+
Notes
|
9
|
+
-----
|
10
|
+
These tests verify the initialization, inheritance, string representation,
|
11
|
+
handling of different message types, raising and catching, and exception
|
12
|
+
chaining behavior of the OrionisIntegrityException.
|
7
13
|
"""
|
8
14
|
|
9
15
|
async def testExceptionInitialization(self):
|
10
16
|
"""
|
11
|
-
Test
|
12
|
-
|
17
|
+
Test initialization of OrionisIntegrityException with a message.
|
18
|
+
|
19
|
+
Verifies
|
20
|
+
--------
|
21
|
+
- The exception stores and returns the provided message correctly.
|
13
22
|
"""
|
14
23
|
test_msg = "Test integrity violation message"
|
15
24
|
exception = OrionisIntegrityException(test_msg)
|
@@ -18,8 +27,12 @@ class TestOrionisIntegrityException(TestCase):
|
|
18
27
|
|
19
28
|
async def testExceptionInheritance(self):
|
20
29
|
"""
|
21
|
-
Test
|
22
|
-
|
30
|
+
Test inheritance of OrionisIntegrityException.
|
31
|
+
|
32
|
+
Verifies
|
33
|
+
--------
|
34
|
+
- OrionisIntegrityException properly inherits from Exception.
|
35
|
+
- The exception hierarchy is correctly implemented.
|
23
36
|
"""
|
24
37
|
exception = OrionisIntegrityException("Test")
|
25
38
|
self.assertIsInstance(exception, Exception)
|
@@ -27,8 +40,11 @@ class TestOrionisIntegrityException(TestCase):
|
|
27
40
|
|
28
41
|
async def testExceptionStringRepresentation(self):
|
29
42
|
"""
|
30
|
-
Test
|
31
|
-
|
43
|
+
Test string representation of OrionisIntegrityException.
|
44
|
+
|
45
|
+
Verifies
|
46
|
+
--------
|
47
|
+
- The __str__ method returns the expected format.
|
32
48
|
"""
|
33
49
|
test_msg = "Configuration validation failed"
|
34
50
|
exception = OrionisIntegrityException(test_msg)
|
@@ -37,7 +53,10 @@ class TestOrionisIntegrityException(TestCase):
|
|
37
53
|
async def testExceptionWithEmptyMessage(self):
|
38
54
|
"""
|
39
55
|
Test OrionisIntegrityException with an empty message.
|
40
|
-
|
56
|
+
|
57
|
+
Verifies
|
58
|
+
--------
|
59
|
+
- The exception handles empty messages correctly.
|
41
60
|
"""
|
42
61
|
exception = OrionisIntegrityException("")
|
43
62
|
self.assertEqual(str(exception), "OrionisIntegrityException: ")
|
@@ -45,7 +64,15 @@ class TestOrionisIntegrityException(TestCase):
|
|
45
64
|
async def testExceptionWithNonStringMessage(self):
|
46
65
|
"""
|
47
66
|
Test OrionisIntegrityException with non-string message types.
|
48
|
-
|
67
|
+
|
68
|
+
Verifies
|
69
|
+
--------
|
70
|
+
- The exception converts non-string messages to strings.
|
71
|
+
|
72
|
+
Tests
|
73
|
+
-----
|
74
|
+
- Integer message
|
75
|
+
- List message
|
49
76
|
"""
|
50
77
|
# Test with integer
|
51
78
|
exception = OrionisIntegrityException(123)
|
@@ -58,7 +85,10 @@ class TestOrionisIntegrityException(TestCase):
|
|
58
85
|
async def testExceptionRaiseAndCatch(self):
|
59
86
|
"""
|
60
87
|
Test raising and catching OrionisIntegrityException.
|
61
|
-
|
88
|
+
|
89
|
+
Verifies
|
90
|
+
--------
|
91
|
+
- The exception can be properly raised and caught.
|
62
92
|
"""
|
63
93
|
test_msg = "Test exception handling"
|
64
94
|
try:
|
@@ -71,7 +101,11 @@ class TestOrionisIntegrityException(TestCase):
|
|
71
101
|
async def testExceptionChaining(self):
|
72
102
|
"""
|
73
103
|
Test exception chaining with OrionisIntegrityException.
|
74
|
-
|
104
|
+
|
105
|
+
Verifies
|
106
|
+
--------
|
107
|
+
- The exception works correctly in chained exception scenarios.
|
108
|
+
- The __cause__ attribute is set as expected.
|
75
109
|
"""
|
76
110
|
try:
|
77
111
|
try:
|
@@ -6,12 +6,18 @@ from orionis.unittesting import TestCase
|
|
6
6
|
class TestConfigFilesystems(TestCase):
|
7
7
|
"""
|
8
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.
|
9
13
|
"""
|
10
14
|
|
11
15
|
async def testDefaultValues(self):
|
12
16
|
"""
|
13
|
-
Test
|
14
|
-
|
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.
|
15
21
|
"""
|
16
22
|
fs = Filesystems()
|
17
23
|
self.assertEqual(fs.default, "local")
|
@@ -19,8 +25,15 @@ class TestConfigFilesystems(TestCase):
|
|
19
25
|
|
20
26
|
async def testDefaultDiskValidation(self):
|
21
27
|
"""
|
22
|
-
|
23
|
-
|
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.
|
24
37
|
"""
|
25
38
|
# Test valid disk types
|
26
39
|
valid_disks = ["local", "public", "aws"]
|
@@ -44,8 +57,15 @@ class TestConfigFilesystems(TestCase):
|
|
44
57
|
|
45
58
|
async def testDisksValidation(self):
|
46
59
|
"""
|
47
|
-
|
48
|
-
|
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.
|
49
69
|
"""
|
50
70
|
# Test invalid disks type
|
51
71
|
with self.assertRaises(OrionisIntegrityException):
|
@@ -63,8 +83,15 @@ class TestConfigFilesystems(TestCase):
|
|
63
83
|
|
64
84
|
async def testToDictMethod(self):
|
65
85
|
"""
|
66
|
-
Test
|
67
|
-
|
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.
|
68
95
|
"""
|
69
96
|
fs = Filesystems()
|
70
97
|
fs_dict = fs.toDict()
|
@@ -75,8 +102,18 @@ class TestConfigFilesystems(TestCase):
|
|
75
102
|
|
76
103
|
async def testCustomValues(self):
|
77
104
|
"""
|
78
|
-
Test
|
79
|
-
|
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
|
80
117
|
"""
|
81
118
|
custom_disks = Disks()
|
82
119
|
custom_fs = Filesystems(
|
@@ -88,8 +125,14 @@ class TestConfigFilesystems(TestCase):
|
|
88
125
|
|
89
126
|
async def testHashability(self):
|
90
127
|
"""
|
91
|
-
Test
|
92
|
-
|
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
|
93
136
|
"""
|
94
137
|
fs1 = Filesystems()
|
95
138
|
fs2 = Filesystems()
|
@@ -103,8 +146,15 @@ class TestConfigFilesystems(TestCase):
|
|
103
146
|
|
104
147
|
async def testKwOnlyInitialization(self):
|
105
148
|
"""
|
106
|
-
Test
|
107
|
-
|
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.
|
108
158
|
"""
|
109
159
|
with self.assertRaises(TypeError):
|
110
160
|
Filesystems("local", Disks())
|
@@ -5,11 +5,16 @@ from orionis.unittesting import TestCase
|
|
5
5
|
class TestConfigS3(TestCase):
|
6
6
|
"""
|
7
7
|
Test cases for the S3 storage configuration class.
|
8
|
+
|
9
|
+
This class contains unit tests for the S3 configuration entity, ensuring
|
10
|
+
correct default values, field validation, custom value handling, dictionary
|
11
|
+
conversion, hashability, and keyword-only initialization.
|
8
12
|
"""
|
9
13
|
|
10
14
|
async def testDefaultValues(self):
|
11
15
|
"""
|
12
16
|
Test that S3 instance is created with correct default values.
|
17
|
+
|
13
18
|
Verifies all default values match expected defaults from class definition.
|
14
19
|
"""
|
15
20
|
s3 = S3()
|
@@ -25,7 +30,13 @@ class TestConfigS3(TestCase):
|
|
25
30
|
async def testRequiredFieldValidation(self):
|
26
31
|
"""
|
27
32
|
Test validation of required fields.
|
28
|
-
|
33
|
+
|
34
|
+
Ensures that the 'region' field must be a non-empty string.
|
35
|
+
|
36
|
+
Raises
|
37
|
+
------
|
38
|
+
OrionisIntegrityException
|
39
|
+
If 'region' is empty or not a string.
|
29
40
|
"""
|
30
41
|
# Test empty region
|
31
42
|
with self.assertRaises(OrionisIntegrityException):
|
@@ -38,7 +49,13 @@ class TestConfigS3(TestCase):
|
|
38
49
|
async def testOptionalFieldValidation(self):
|
39
50
|
"""
|
40
51
|
Test validation of optional fields.
|
41
|
-
|
52
|
+
|
53
|
+
Ensures that optional fields accept None or proper types.
|
54
|
+
|
55
|
+
Raises
|
56
|
+
------
|
57
|
+
OrionisIntegrityException
|
58
|
+
If optional fields are not of the correct type.
|
42
59
|
"""
|
43
60
|
# Valid optional configurations
|
44
61
|
try:
|
@@ -56,7 +73,13 @@ class TestConfigS3(TestCase):
|
|
56
73
|
async def testBooleanFieldValidation(self):
|
57
74
|
"""
|
58
75
|
Test validation of boolean fields.
|
59
|
-
|
76
|
+
|
77
|
+
Ensures that boolean fields only accept boolean values.
|
78
|
+
|
79
|
+
Raises
|
80
|
+
------
|
81
|
+
OrionisIntegrityException
|
82
|
+
If boolean fields are not of type bool.
|
60
83
|
"""
|
61
84
|
# Test use_path_style_endpoint
|
62
85
|
with self.assertRaises(OrionisIntegrityException):
|
@@ -69,7 +92,9 @@ class TestConfigS3(TestCase):
|
|
69
92
|
async def testCustomValues(self):
|
70
93
|
"""
|
71
94
|
Test that custom values are properly stored and validated.
|
72
|
-
|
95
|
+
|
96
|
+
Ensures custom configuration values are correctly handled.
|
97
|
+
|
73
98
|
"""
|
74
99
|
custom_s3 = S3(
|
75
100
|
key="AKIAEXAMPLE",
|
@@ -94,7 +119,13 @@ class TestConfigS3(TestCase):
|
|
94
119
|
async def testToDictMethod(self):
|
95
120
|
"""
|
96
121
|
Test that toDict returns proper dictionary representation.
|
97
|
-
|
122
|
+
|
123
|
+
Ensures all attributes are correctly included in the dictionary.
|
124
|
+
|
125
|
+
Returns
|
126
|
+
-------
|
127
|
+
dict
|
128
|
+
Dictionary representation of the S3 instance.
|
98
129
|
"""
|
99
130
|
s3 = S3()
|
100
131
|
s3_dict = s3.toDict()
|
@@ -112,7 +143,8 @@ class TestConfigS3(TestCase):
|
|
112
143
|
async def testHashability(self):
|
113
144
|
"""
|
114
145
|
Test that S3 maintains hashability due to unsafe_hash=True.
|
115
|
-
|
146
|
+
|
147
|
+
Ensures that S3 instances can be used in sets and as dictionary keys.
|
116
148
|
"""
|
117
149
|
s3_1 = S3()
|
118
150
|
s3_2 = S3()
|
@@ -127,7 +159,13 @@ class TestConfigS3(TestCase):
|
|
127
159
|
async def testKwOnlyInitialization(self):
|
128
160
|
"""
|
129
161
|
Test that S3 enforces keyword-only initialization.
|
130
|
-
|
162
|
+
|
163
|
+
Ensures that positional arguments are not allowed for initialization.
|
164
|
+
|
165
|
+
Raises
|
166
|
+
------
|
167
|
+
TypeError
|
168
|
+
If positional arguments are used for initialization.
|
131
169
|
"""
|
132
170
|
with self.assertRaises(TypeError):
|
133
171
|
S3("key", "secret", "region") # Should fail as it requires keyword arguments
|
@@ -8,12 +8,41 @@ from orionis.unittesting import TestCase
|
|
8
8
|
class TestConfigDisks(TestCase):
|
9
9
|
"""
|
10
10
|
Test cases for the Disks filesystem configuration class.
|
11
|
+
|
12
|
+
This class contains unit tests to validate the behavior and integrity of the
|
13
|
+
`Disks` configuration class, ensuring correct type validation, default values,
|
14
|
+
custom configuration handling, dictionary conversion, hashability, and
|
15
|
+
keyword-only initialization.
|
16
|
+
|
17
|
+
Methods
|
18
|
+
-------
|
19
|
+
testDefaultValues()
|
20
|
+
Test that Disks instance is created with correct default values.
|
21
|
+
testLocalTypeValidation()
|
22
|
+
Test local attribute type validation.
|
23
|
+
testPublicTypeValidation()
|
24
|
+
Test public attribute type validation.
|
25
|
+
testAwsTypeValidation()
|
26
|
+
Test aws attribute type validation.
|
27
|
+
testCustomDiskConfigurations()
|
28
|
+
Test that custom disk configurations are properly stored and validated.
|
29
|
+
testToDictMethod()
|
30
|
+
Test that toDict returns proper dictionary representation.
|
31
|
+
testHashability()
|
32
|
+
Test that Disks maintains hashability due to unsafe_hash=True.
|
33
|
+
testKwOnlyInitialization()
|
34
|
+
Test that Disks enforces keyword-only initialization.
|
11
35
|
"""
|
12
36
|
|
13
37
|
async def testDefaultValues(self):
|
14
38
|
"""
|
15
39
|
Test that Disks instance is created with correct default values.
|
16
|
-
|
40
|
+
|
41
|
+
Ensures that all default disk configurations are properly initialized.
|
42
|
+
|
43
|
+
Returns
|
44
|
+
-------
|
45
|
+
None
|
17
46
|
"""
|
18
47
|
disks = Disks()
|
19
48
|
self.assertIsInstance(disks.local, Local)
|
@@ -23,7 +52,13 @@ class TestConfigDisks(TestCase):
|
|
23
52
|
async def testLocalTypeValidation(self):
|
24
53
|
"""
|
25
54
|
Test local attribute type validation.
|
26
|
-
|
55
|
+
|
56
|
+
Ensures that only `Local` instances are accepted for the `local` attribute.
|
57
|
+
|
58
|
+
Raises
|
59
|
+
------
|
60
|
+
OrionisIntegrityException
|
61
|
+
If the `local` attribute is not a `Local` instance.
|
27
62
|
"""
|
28
63
|
with self.assertRaises(OrionisIntegrityException):
|
29
64
|
Disks(local="not_a_local_instance")
|
@@ -35,7 +70,13 @@ class TestConfigDisks(TestCase):
|
|
35
70
|
async def testPublicTypeValidation(self):
|
36
71
|
"""
|
37
72
|
Test public attribute type validation.
|
38
|
-
|
73
|
+
|
74
|
+
Ensures that only `Public` instances are accepted for the `public` attribute.
|
75
|
+
|
76
|
+
Raises
|
77
|
+
------
|
78
|
+
OrionisIntegrityException
|
79
|
+
If the `public` attribute is not a `Public` instance.
|
39
80
|
"""
|
40
81
|
with self.assertRaises(OrionisIntegrityException):
|
41
82
|
Disks(public="not_a_public_instance")
|
@@ -47,7 +88,13 @@ class TestConfigDisks(TestCase):
|
|
47
88
|
async def testAwsTypeValidation(self):
|
48
89
|
"""
|
49
90
|
Test aws attribute type validation.
|
50
|
-
|
91
|
+
|
92
|
+
Ensures that only `S3` instances are accepted for the `aws` attribute.
|
93
|
+
|
94
|
+
Raises
|
95
|
+
------
|
96
|
+
OrionisIntegrityException
|
97
|
+
If the `aws` attribute is not an `S3` instance.
|
51
98
|
"""
|
52
99
|
with self.assertRaises(OrionisIntegrityException):
|
53
100
|
Disks(aws="not_an_s3_instance")
|
@@ -59,7 +106,13 @@ class TestConfigDisks(TestCase):
|
|
59
106
|
async def testCustomDiskConfigurations(self):
|
60
107
|
"""
|
61
108
|
Test that custom disk configurations are properly stored and validated.
|
62
|
-
|
109
|
+
|
110
|
+
Ensures that custom disk configurations are correctly handled and their
|
111
|
+
attributes are properly set.
|
112
|
+
|
113
|
+
Returns
|
114
|
+
-------
|
115
|
+
None
|
63
116
|
"""
|
64
117
|
custom_local = Local(path="custom/local/path")
|
65
118
|
custom_public = Public(path="custom/public/path", url="assets")
|
@@ -80,7 +133,13 @@ class TestConfigDisks(TestCase):
|
|
80
133
|
async def testToDictMethod(self):
|
81
134
|
"""
|
82
135
|
Test that toDict returns proper dictionary representation.
|
83
|
-
|
136
|
+
|
137
|
+
Ensures that all disk configurations are correctly included in the
|
138
|
+
dictionary representation.
|
139
|
+
|
140
|
+
Returns
|
141
|
+
-------
|
142
|
+
None
|
84
143
|
"""
|
85
144
|
disks = Disks()
|
86
145
|
disks_dict = disks.toDict()
|
@@ -93,7 +152,12 @@ class TestConfigDisks(TestCase):
|
|
93
152
|
async def testHashability(self):
|
94
153
|
"""
|
95
154
|
Test that Disks maintains hashability due to unsafe_hash=True.
|
96
|
-
|
155
|
+
|
156
|
+
Ensures that `Disks` instances can be used in sets and as dictionary keys.
|
157
|
+
|
158
|
+
Returns
|
159
|
+
-------
|
160
|
+
None
|
97
161
|
"""
|
98
162
|
disks1 = Disks()
|
99
163
|
disks2 = Disks()
|
@@ -108,7 +172,13 @@ class TestConfigDisks(TestCase):
|
|
108
172
|
async def testKwOnlyInitialization(self):
|
109
173
|
"""
|
110
174
|
Test that Disks enforces keyword-only initialization.
|
111
|
-
|
175
|
+
|
176
|
+
Ensures that positional arguments are not allowed for initialization.
|
177
|
+
|
178
|
+
Raises
|
179
|
+
------
|
180
|
+
TypeError
|
181
|
+
If positional arguments are used for initialization.
|
112
182
|
"""
|
113
183
|
with self.assertRaises(TypeError):
|
114
184
|
Disks(Local(), Public(), S3())
|