orionis 0.285.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/asynchrony/contracts/__init__.py +0 -0
- orionis/services/asynchrony/contracts/coroutines.py +24 -0
- orionis/services/asynchrony/coroutines.py +58 -19
- orionis/services/asynchrony/exceptions/coroutine_exception.py +8 -15
- 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/exceptions/test_config_exception.py +8 -17
- orionis/test/exceptions/test_failure_exception.py +27 -27
- orionis/test/exceptions/test_persistence_error.py +10 -20
- orionis/test/exceptions/test_runtime_error.py +8 -15
- orionis/test/exceptions/test_value_error.py +8 -15
- orionis/test/logs/history.py +3 -5
- {orionis-0.285.0.dist-info → orionis-0.287.0.dist-info}/METADATA +1 -1
- {orionis-0.285.0.dist-info → orionis-0.287.0.dist-info}/RECORD +66 -62
- 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/asynchrony/test_async_io.py +4 -4
- 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.285.0.dist-info → orionis-0.287.0.dist-info}/WHEEL +0 -0
- {orionis-0.285.0.dist-info → orionis-0.287.0.dist-info}/licenses/LICENCE +0 -0
- {orionis-0.285.0.dist-info → orionis-0.287.0.dist-info}/top_level.txt +0 -0
- {orionis-0.285.0.dist-info → orionis-0.287.0.dist-info}/zip-safe +0 -0
@@ -6,12 +6,18 @@ from orionis.unittesting import TestCase
|
|
6
6
|
class TestConfigStack(TestCase):
|
7
7
|
"""
|
8
8
|
Test cases for the Stack logging configuration class.
|
9
|
+
|
10
|
+
This class contains asynchronous unit tests for the Stack class,
|
11
|
+
validating default values, attribute validation, dictionary representation,
|
12
|
+
hashability, and keyword-only initialization.
|
9
13
|
"""
|
10
14
|
|
11
15
|
async def testDefaultValues(self):
|
12
16
|
"""
|
13
|
-
Test
|
14
|
-
|
17
|
+
Test default values of Stack.
|
18
|
+
|
19
|
+
Ensures that a Stack instance is created with the correct default values.
|
20
|
+
Verifies that the default path and level match the expected values from the class definition.
|
15
21
|
"""
|
16
22
|
stack = Stack()
|
17
23
|
self.assertEqual(stack.path, "storage/log/application.log")
|
@@ -19,8 +25,14 @@ class TestConfigStack(TestCase):
|
|
19
25
|
|
20
26
|
async def testPathValidation(self):
|
21
27
|
"""
|
22
|
-
Test path attribute
|
23
|
-
|
28
|
+
Test validation of the path attribute.
|
29
|
+
|
30
|
+
Checks that empty or non-string paths raise exceptions, and that valid paths are accepted.
|
31
|
+
|
32
|
+
Raises
|
33
|
+
------
|
34
|
+
OrionisIntegrityException
|
35
|
+
If the path is empty or not a string.
|
24
36
|
"""
|
25
37
|
# Test empty path
|
26
38
|
with self.assertRaises(OrionisIntegrityException):
|
@@ -36,8 +48,14 @@ class TestConfigStack(TestCase):
|
|
36
48
|
|
37
49
|
async def testLevelValidation(self):
|
38
50
|
"""
|
39
|
-
Test level attribute
|
40
|
-
|
51
|
+
Test validation of the level attribute with different input types.
|
52
|
+
|
53
|
+
Verifies that string, int, and enum level values are properly handled.
|
54
|
+
|
55
|
+
Raises
|
56
|
+
------
|
57
|
+
OrionisIntegrityException
|
58
|
+
If the level is invalid or of an unsupported type.
|
41
59
|
"""
|
42
60
|
# Test string level
|
43
61
|
stack = Stack(level="debug")
|
@@ -65,8 +83,9 @@ class TestConfigStack(TestCase):
|
|
65
83
|
|
66
84
|
async def testWhitespaceHandling(self):
|
67
85
|
"""
|
68
|
-
Test whitespace
|
69
|
-
|
86
|
+
Test handling of whitespace in path and level attributes.
|
87
|
+
|
88
|
+
Ensures that whitespace is preserved in the path and trimmed in level strings.
|
70
89
|
"""
|
71
90
|
# Test path with whitespace
|
72
91
|
spaced_path = " logs/app.log "
|
@@ -79,8 +98,14 @@ class TestConfigStack(TestCase):
|
|
79
98
|
|
80
99
|
async def testToDictMethod(self):
|
81
100
|
"""
|
82
|
-
Test
|
83
|
-
|
101
|
+
Test the toDict method for dictionary representation.
|
102
|
+
|
103
|
+
Ensures that both path and level are correctly included in the dictionary.
|
104
|
+
|
105
|
+
Returns
|
106
|
+
-------
|
107
|
+
dict
|
108
|
+
Dictionary representation of the Stack instance.
|
84
109
|
"""
|
85
110
|
stack = Stack()
|
86
111
|
stack_dict = stack.toDict()
|
@@ -91,7 +116,9 @@ class TestConfigStack(TestCase):
|
|
91
116
|
|
92
117
|
async def testCustomValuesToDict(self):
|
93
118
|
"""
|
94
|
-
Test
|
119
|
+
Test custom values in dictionary representation.
|
120
|
+
|
121
|
+
Ensures that custom path and level values are properly included in the dictionary.
|
95
122
|
"""
|
96
123
|
custom_stack = Stack(
|
97
124
|
path="custom/logs/app.log",
|
@@ -103,8 +130,9 @@ class TestConfigStack(TestCase):
|
|
103
130
|
|
104
131
|
async def testHashability(self):
|
105
132
|
"""
|
106
|
-
Test
|
107
|
-
|
133
|
+
Test hashability of Stack instances.
|
134
|
+
|
135
|
+
Ensures that Stack instances can be used in sets and as dictionary keys due to unsafe_hash=True.
|
108
136
|
"""
|
109
137
|
stack1 = Stack()
|
110
138
|
stack2 = Stack()
|
@@ -118,7 +146,14 @@ class TestConfigStack(TestCase):
|
|
118
146
|
|
119
147
|
async def testKwOnlyInitialization(self):
|
120
148
|
"""
|
121
|
-
Test
|
149
|
+
Test enforcement of keyword-only initialization.
|
150
|
+
|
151
|
+
Ensures that Stack cannot be initialized with positional arguments.
|
152
|
+
|
153
|
+
Raises
|
154
|
+
------
|
155
|
+
TypeError
|
156
|
+
If positional arguments are used for initialization.
|
122
157
|
"""
|
123
158
|
with self.assertRaises(TypeError):
|
124
159
|
Stack("path.log", "info")
|
@@ -6,12 +6,47 @@ from orionis.unittesting import TestCase
|
|
6
6
|
class TestConfigWeekly(TestCase):
|
7
7
|
"""
|
8
8
|
Test cases for the Weekly logging configuration class.
|
9
|
+
|
10
|
+
This class contains unit tests for the `Weekly` logging configuration entity,
|
11
|
+
including validation of default values, attribute validation, dictionary conversion,
|
12
|
+
hashability, and keyword-only initialization.
|
13
|
+
|
14
|
+
Attributes
|
15
|
+
----------
|
16
|
+
None
|
17
|
+
|
18
|
+
Methods
|
19
|
+
-------
|
20
|
+
testDefaultValues()
|
21
|
+
Test that Weekly instance is created with correct default values.
|
22
|
+
testPathValidation()
|
23
|
+
Test path attribute validation.
|
24
|
+
testLevelValidation()
|
25
|
+
Test level attribute validation with different input types.
|
26
|
+
testRetentionWeeksValidation()
|
27
|
+
Test retention_weeks attribute validation.
|
28
|
+
testWhitespaceHandling()
|
29
|
+
Test whitespace handling in path and level attributes.
|
30
|
+
testToDictMethod()
|
31
|
+
Test that toDict returns proper dictionary representation.
|
32
|
+
testCustomValuesToDict()
|
33
|
+
Test that custom values are properly included in dictionary.
|
34
|
+
testHashability()
|
35
|
+
Test that Weekly maintains hashability due to unsafe_hash=True.
|
36
|
+
testKwOnlyInitialization()
|
37
|
+
Test that Weekly enforces keyword-only initialization.
|
9
38
|
"""
|
10
39
|
|
11
40
|
async def testDefaultValues(self):
|
12
41
|
"""
|
13
42
|
Test that Weekly instance is created with correct default values.
|
14
|
-
|
43
|
+
|
44
|
+
Verifies that the default `path`, `level`, and `retention_weeks` attributes
|
45
|
+
of a `Weekly` instance match the expected values.
|
46
|
+
|
47
|
+
Returns
|
48
|
+
-------
|
49
|
+
None
|
15
50
|
"""
|
16
51
|
weekly = Weekly()
|
17
52
|
self.assertEqual(weekly.path, "storage/log/application.log")
|
@@ -21,7 +56,13 @@ class TestConfigWeekly(TestCase):
|
|
21
56
|
async def testPathValidation(self):
|
22
57
|
"""
|
23
58
|
Test path attribute validation.
|
24
|
-
|
59
|
+
|
60
|
+
Verifies that empty or non-string `path` values raise exceptions,
|
61
|
+
and that a valid path does not raise an exception.
|
62
|
+
|
63
|
+
Returns
|
64
|
+
-------
|
65
|
+
None
|
25
66
|
"""
|
26
67
|
with self.assertRaises(OrionisIntegrityException):
|
27
68
|
Weekly(path="")
|
@@ -35,6 +76,13 @@ class TestConfigWeekly(TestCase):
|
|
35
76
|
async def testLevelValidation(self):
|
36
77
|
"""
|
37
78
|
Test level attribute validation with different input types.
|
79
|
+
|
80
|
+
Checks that the `level` attribute accepts string, integer, and enum values,
|
81
|
+
and raises exceptions for invalid types or values.
|
82
|
+
|
83
|
+
Returns
|
84
|
+
-------
|
85
|
+
None
|
38
86
|
"""
|
39
87
|
# Test string level
|
40
88
|
weekly = Weekly(level="debug")
|
@@ -59,6 +107,13 @@ class TestConfigWeekly(TestCase):
|
|
59
107
|
async def testRetentionWeeksValidation(self):
|
60
108
|
"""
|
61
109
|
Test retention_weeks attribute validation.
|
110
|
+
|
111
|
+
Ensures that valid `retention_weeks` values are accepted and invalid
|
112
|
+
values raise exceptions.
|
113
|
+
|
114
|
+
Returns
|
115
|
+
-------
|
116
|
+
None
|
62
117
|
"""
|
63
118
|
# Test valid values
|
64
119
|
try:
|
@@ -81,6 +136,13 @@ class TestConfigWeekly(TestCase):
|
|
81
136
|
async def testWhitespaceHandling(self):
|
82
137
|
"""
|
83
138
|
Test whitespace handling in path and level attributes.
|
139
|
+
|
140
|
+
Verifies that leading and trailing whitespace in `path` and `level`
|
141
|
+
attributes are handled as expected.
|
142
|
+
|
143
|
+
Returns
|
144
|
+
-------
|
145
|
+
None
|
84
146
|
"""
|
85
147
|
weekly = Weekly(path=" logs/app.log ", level=" debug ")
|
86
148
|
self.assertEqual(weekly.path, " logs/app.log ")
|
@@ -89,6 +151,13 @@ class TestConfigWeekly(TestCase):
|
|
89
151
|
async def testToDictMethod(self):
|
90
152
|
"""
|
91
153
|
Test that toDict returns proper dictionary representation.
|
154
|
+
|
155
|
+
Ensures that the `toDict` method returns a dictionary with the correct
|
156
|
+
keys and values for a default `Weekly` instance.
|
157
|
+
|
158
|
+
Returns
|
159
|
+
-------
|
160
|
+
None
|
92
161
|
"""
|
93
162
|
weekly = Weekly()
|
94
163
|
weekly_dict = weekly.toDict()
|
@@ -100,6 +169,13 @@ class TestConfigWeekly(TestCase):
|
|
100
169
|
async def testCustomValuesToDict(self):
|
101
170
|
"""
|
102
171
|
Test that custom values are properly included in dictionary.
|
172
|
+
|
173
|
+
Checks that custom attribute values are correctly represented in the
|
174
|
+
dictionary returned by `toDict`.
|
175
|
+
|
176
|
+
Returns
|
177
|
+
-------
|
178
|
+
None
|
103
179
|
"""
|
104
180
|
custom_weekly = Weekly(
|
105
181
|
path="custom/logs/app.log",
|
@@ -114,6 +190,13 @@ class TestConfigWeekly(TestCase):
|
|
114
190
|
async def testHashability(self):
|
115
191
|
"""
|
116
192
|
Test that Weekly maintains hashability due to unsafe_hash=True.
|
193
|
+
|
194
|
+
Verifies that `Weekly` instances are hashable and can be used in sets,
|
195
|
+
and that identical instances are considered equal.
|
196
|
+
|
197
|
+
Returns
|
198
|
+
-------
|
199
|
+
None
|
117
200
|
"""
|
118
201
|
weekly1 = Weekly()
|
119
202
|
weekly2 = Weekly()
|
@@ -128,6 +211,13 @@ class TestConfigWeekly(TestCase):
|
|
128
211
|
async def testKwOnlyInitialization(self):
|
129
212
|
"""
|
130
213
|
Test that Weekly enforces keyword-only initialization.
|
214
|
+
|
215
|
+
Ensures that providing positional arguments to the `Weekly` constructor
|
216
|
+
raises a TypeError.
|
217
|
+
|
218
|
+
Returns
|
219
|
+
-------
|
220
|
+
None
|
131
221
|
"""
|
132
222
|
with self.assertRaises(TypeError):
|
133
223
|
Weekly("path.log", "info", 4)
|
@@ -4,11 +4,24 @@ from orionis.foundation.config.exceptions.integrity import OrionisIntegrityExcep
|
|
4
4
|
from orionis.unittesting import TestCase
|
5
5
|
|
6
6
|
class TestMail(TestCase):
|
7
|
+
"""
|
8
|
+
Test suite for the Mail class, covering initialization, validation, and utility methods.
|
9
|
+
"""
|
7
10
|
|
8
11
|
async def testDefaultInitialization(self):
|
9
12
|
"""
|
10
|
-
Test
|
11
|
-
|
13
|
+
Test default initialization of Mail.
|
14
|
+
|
15
|
+
Tests that a Mail instance is initialized with the correct default values.
|
16
|
+
|
17
|
+
Returns
|
18
|
+
-------
|
19
|
+
None
|
20
|
+
|
21
|
+
Raises
|
22
|
+
------
|
23
|
+
AssertionError
|
24
|
+
If the default mailer is not 'smtp' or mailers is not an instance of Mailers.
|
12
25
|
"""
|
13
26
|
mail = Mail()
|
14
27
|
self.assertEqual(mail.default, "smtp")
|
@@ -16,8 +29,18 @@ class TestMail(TestCase):
|
|
16
29
|
|
17
30
|
async def testDefaultValidation(self):
|
18
31
|
"""
|
19
|
-
Test validation of default mailer
|
20
|
-
|
32
|
+
Test validation of the default mailer.
|
33
|
+
|
34
|
+
Ensures that providing an invalid default mailer raises an exception.
|
35
|
+
|
36
|
+
Returns
|
37
|
+
-------
|
38
|
+
None
|
39
|
+
|
40
|
+
Raises
|
41
|
+
------
|
42
|
+
OrionisIntegrityException
|
43
|
+
If the default mailer is invalid or not a string.
|
21
44
|
"""
|
22
45
|
with self.assertRaises(OrionisIntegrityException):
|
23
46
|
Mail(default="invalid_mailer")
|
@@ -26,16 +49,36 @@ class TestMail(TestCase):
|
|
26
49
|
|
27
50
|
async def testMailersTypeValidation(self):
|
28
51
|
"""
|
29
|
-
Test validation
|
30
|
-
|
52
|
+
Test type validation for the mailers attribute.
|
53
|
+
|
54
|
+
Ensures that assigning a non-Mailers object to mailers raises an exception.
|
55
|
+
|
56
|
+
Returns
|
57
|
+
-------
|
58
|
+
None
|
59
|
+
|
60
|
+
Raises
|
61
|
+
------
|
62
|
+
OrionisIntegrityException
|
63
|
+
If mailers is not an instance of Mailers.
|
31
64
|
"""
|
32
65
|
with self.assertRaises(OrionisIntegrityException):
|
33
66
|
Mail(mailers="invalid_mailers_object")
|
34
67
|
|
35
68
|
async def testToDictMethod(self):
|
36
69
|
"""
|
37
|
-
Test the toDict method
|
38
|
-
|
70
|
+
Test the toDict method.
|
71
|
+
|
72
|
+
Checks that the toDict method returns a dictionary representation of the Mail instance.
|
73
|
+
|
74
|
+
Returns
|
75
|
+
-------
|
76
|
+
None
|
77
|
+
|
78
|
+
Raises
|
79
|
+
------
|
80
|
+
AssertionError
|
81
|
+
If the returned value is not a dict or missing expected fields.
|
39
82
|
"""
|
40
83
|
mail = Mail()
|
41
84
|
result = mail.toDict()
|
@@ -46,8 +89,18 @@ class TestMail(TestCase):
|
|
46
89
|
|
47
90
|
async def testHashability(self):
|
48
91
|
"""
|
49
|
-
Test
|
50
|
-
|
92
|
+
Test hashability of Mail instances.
|
93
|
+
|
94
|
+
Ensures that Mail instances are hashable and can be used in sets or as dictionary keys.
|
95
|
+
|
96
|
+
Returns
|
97
|
+
-------
|
98
|
+
None
|
99
|
+
|
100
|
+
Raises
|
101
|
+
------
|
102
|
+
AssertionError
|
103
|
+
If Mail instances are not hashable or set behavior is incorrect.
|
51
104
|
"""
|
52
105
|
mail1 = Mail()
|
53
106
|
mail2 = Mail(default="smtp")
|
@@ -56,18 +109,37 @@ class TestMail(TestCase):
|
|
56
109
|
|
57
110
|
async def testKwOnlyInitialization(self):
|
58
111
|
"""
|
59
|
-
Test
|
60
|
-
|
112
|
+
Test keyword-only initialization enforcement.
|
113
|
+
|
114
|
+
Ensures that Mail requires keyword arguments for initialization.
|
115
|
+
|
116
|
+
Returns
|
117
|
+
-------
|
118
|
+
None
|
119
|
+
|
120
|
+
Raises
|
121
|
+
------
|
122
|
+
TypeError
|
123
|
+
If positional arguments are used for initialization.
|
61
124
|
"""
|
62
125
|
with self.assertRaises(TypeError):
|
63
126
|
Mail("smtp", Mailers())
|
64
127
|
|
65
128
|
async def testValidCustomInitialization(self):
|
66
129
|
"""
|
67
|
-
Test valid custom initialization
|
68
|
-
|
130
|
+
Test valid custom initialization.
|
131
|
+
|
132
|
+
Checks that a Mail instance can be created with valid, non-default values.
|
133
|
+
|
134
|
+
Returns
|
135
|
+
-------
|
136
|
+
None
|
137
|
+
|
138
|
+
Raises
|
139
|
+
------
|
140
|
+
AssertionError
|
141
|
+
If the instance is not initialized with the provided values.
|
69
142
|
"""
|
70
|
-
# Assuming 'smtp' is a valid mailer option from Mailers
|
71
143
|
mail = Mail(default="smtp", mailers=Mailers())
|
72
144
|
self.assertEqual(mail.default, "smtp")
|
73
145
|
self.assertIsInstance(mail.mailers, Mailers)
|
@@ -3,10 +3,16 @@ from orionis.foundation.config.exceptions.integrity import OrionisIntegrityExcep
|
|
3
3
|
from orionis.unittesting import TestCase
|
4
4
|
|
5
5
|
class TestMailFile(TestCase):
|
6
|
+
"""
|
7
|
+
Unit tests for the File entity in the mail configuration module.
|
8
|
+
"""
|
6
9
|
|
7
10
|
async def testDefaultPathValue(self):
|
8
11
|
"""
|
9
12
|
Test that the File instance is initialized with the correct default path.
|
13
|
+
|
14
|
+
Notes
|
15
|
+
-----
|
10
16
|
Verifies that a new File object has 'storage/mail' as the default path.
|
11
17
|
"""
|
12
18
|
file = File()
|
@@ -14,8 +20,16 @@ class TestMailFile(TestCase):
|
|
14
20
|
|
15
21
|
async def testPathValidation(self):
|
16
22
|
"""
|
17
|
-
Test the path validation in __post_init__ method.
|
18
|
-
|
23
|
+
Test the path validation in the __post_init__ method.
|
24
|
+
|
25
|
+
Raises
|
26
|
+
------
|
27
|
+
OrionisIntegrityException
|
28
|
+
If the path is not a string or is an empty string.
|
29
|
+
|
30
|
+
Notes
|
31
|
+
-----
|
32
|
+
Verifies that non-string paths or empty strings raise OrionisIntegrityException.
|
19
33
|
"""
|
20
34
|
with self.assertRaises(OrionisIntegrityException):
|
21
35
|
File(path=123)
|
@@ -25,6 +39,9 @@ class TestMailFile(TestCase):
|
|
25
39
|
async def testValidPathAssignment(self):
|
26
40
|
"""
|
27
41
|
Test that valid path assignments work correctly.
|
42
|
+
|
43
|
+
Notes
|
44
|
+
-----
|
28
45
|
Verifies that string paths are accepted and stored properly.
|
29
46
|
"""
|
30
47
|
test_path = "custom/path/to/mail"
|
@@ -34,8 +51,16 @@ class TestMailFile(TestCase):
|
|
34
51
|
async def testToDictMethod(self):
|
35
52
|
"""
|
36
53
|
Test the toDict method returns a proper dictionary representation.
|
37
|
-
|
38
|
-
|
54
|
+
|
55
|
+
Returns
|
56
|
+
-------
|
57
|
+
dict
|
58
|
+
Dictionary representation of the File instance.
|
59
|
+
|
60
|
+
Notes
|
61
|
+
-----
|
62
|
+
Checks that the toDict method converts the File instance into a dictionary
|
63
|
+
with the expected path field.
|
39
64
|
"""
|
40
65
|
file = File()
|
41
66
|
result = file.toDict()
|
@@ -45,6 +70,9 @@ class TestMailFile(TestCase):
|
|
45
70
|
async def testHashability(self):
|
46
71
|
"""
|
47
72
|
Test that File instances are hashable due to unsafe_hash=True.
|
73
|
+
|
74
|
+
Notes
|
75
|
+
-----
|
48
76
|
Verifies that instances can be used in sets or as dictionary keys.
|
49
77
|
"""
|
50
78
|
file1 = File()
|
@@ -55,6 +83,14 @@ class TestMailFile(TestCase):
|
|
55
83
|
async def testKwOnlyInitialization(self):
|
56
84
|
"""
|
57
85
|
Test that File requires keyword arguments for initialization.
|
86
|
+
|
87
|
+
Raises
|
88
|
+
------
|
89
|
+
TypeError
|
90
|
+
If positional arguments are used for initialization.
|
91
|
+
|
92
|
+
Notes
|
93
|
+
-----
|
58
94
|
Verifies that the class enforces kw_only=True in its dataclass decorator.
|
59
95
|
"""
|
60
96
|
with self.assertRaises(TypeError):
|
@@ -5,11 +5,25 @@ from orionis.foundation.config.exceptions.integrity import OrionisIntegrityExcep
|
|
5
5
|
from orionis.unittesting import TestCase
|
6
6
|
|
7
7
|
class TestMailers(TestCase):
|
8
|
+
"""
|
9
|
+
Unit tests for the Mailers class.
|
10
|
+
|
11
|
+
This test suite verifies the correct initialization, type validation,
|
12
|
+
custom initialization, dictionary conversion, and keyword-only enforcement
|
13
|
+
of the Mailers class.
|
14
|
+
"""
|
8
15
|
|
9
16
|
async def testDefaultInitialization(self):
|
10
17
|
"""
|
11
|
-
Test
|
12
|
-
|
18
|
+
Test default initialization of Mailers.
|
19
|
+
|
20
|
+
Ensures that a Mailers instance is initialized with default factories
|
21
|
+
and that the `smtp` and `file` attributes are instances of their
|
22
|
+
respective types.
|
23
|
+
|
24
|
+
Returns
|
25
|
+
-------
|
26
|
+
None
|
13
27
|
"""
|
14
28
|
mailers = Mailers()
|
15
29
|
self.assertIsInstance(mailers.smtp, Smtp)
|
@@ -18,7 +32,18 @@ class TestMailers(TestCase):
|
|
18
32
|
async def testTypeValidation(self):
|
19
33
|
"""
|
20
34
|
Test type validation for smtp and file attributes.
|
21
|
-
|
35
|
+
|
36
|
+
Ensures that providing invalid types for `smtp` or `file` raises
|
37
|
+
an OrionisIntegrityException.
|
38
|
+
|
39
|
+
Returns
|
40
|
+
-------
|
41
|
+
None
|
42
|
+
|
43
|
+
Raises
|
44
|
+
------
|
45
|
+
OrionisIntegrityException
|
46
|
+
If an invalid type is provided for `smtp` or `file`.
|
22
47
|
"""
|
23
48
|
with self.assertRaises(OrionisIntegrityException):
|
24
49
|
Mailers(smtp="invalid_smtp")
|
@@ -28,7 +53,13 @@ class TestMailers(TestCase):
|
|
28
53
|
async def testCustomInitialization(self):
|
29
54
|
"""
|
30
55
|
Test custom initialization with valid parameters.
|
31
|
-
|
56
|
+
|
57
|
+
Ensures that valid Smtp and File instances can be provided to the
|
58
|
+
Mailers constructor and are correctly assigned.
|
59
|
+
|
60
|
+
Returns
|
61
|
+
-------
|
62
|
+
None
|
32
63
|
"""
|
33
64
|
custom_smtp = Smtp()
|
34
65
|
custom_file = File()
|
@@ -38,8 +69,14 @@ class TestMailers(TestCase):
|
|
38
69
|
|
39
70
|
async def testToDictMethod(self):
|
40
71
|
"""
|
41
|
-
Test the toDict method
|
42
|
-
|
72
|
+
Test the toDict method of Mailers.
|
73
|
+
|
74
|
+
Ensures that the `toDict` method returns a dictionary representation
|
75
|
+
containing all fields with correct values and types.
|
76
|
+
|
77
|
+
Returns
|
78
|
+
-------
|
79
|
+
None
|
43
80
|
"""
|
44
81
|
mailers = Mailers()
|
45
82
|
result = mailers.toDict()
|
@@ -51,8 +88,19 @@ class TestMailers(TestCase):
|
|
51
88
|
|
52
89
|
async def testKwOnlyInitialization(self):
|
53
90
|
"""
|
54
|
-
Test
|
55
|
-
|
91
|
+
Test keyword-only initialization enforcement.
|
92
|
+
|
93
|
+
Ensures that the Mailers class enforces keyword-only arguments
|
94
|
+
during initialization (i.e., `kw_only=True` in its dataclass decorator).
|
95
|
+
|
96
|
+
Returns
|
97
|
+
-------
|
98
|
+
None
|
99
|
+
|
100
|
+
Raises
|
101
|
+
------
|
102
|
+
TypeError
|
103
|
+
If positional arguments are provided to the constructor.
|
56
104
|
"""
|
57
105
|
with self.assertRaises(TypeError):
|
58
106
|
Mailers(Smtp(), File())
|