orionis 0.418.0__py3-none-any.whl → 0.419.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-0.418.0.dist-info → orionis-0.419.0.dist-info}/METADATA +1 -1
- {orionis-0.418.0.dist-info → orionis-0.419.0.dist-info}/RECORD +58 -60
- {orionis-0.418.0.dist-info → orionis-0.419.0.dist-info}/top_level.txt +0 -1
- tests/foundation/config/app/test_foundation_config_app.py +262 -0
- {foundation → tests/foundation}/config/cache/test_foundation_config_cache_file.py +8 -8
- {foundation → tests/foundation}/config/cache/test_foundation_config_cache_stores.py +11 -3
- {foundation → tests/foundation}/config/database/test_foundation_config_database_pgsql.py +5 -5
- {foundation → tests/foundation}/config/queue/test_foundation_config_queue.py +0 -20
- {foundation → tests/foundation}/config/queue/test_foundation_config_queue_brokers.py +0 -13
- tests/foundation/config/root/test_foundation_config_root_paths.py +116 -0
- tests/foundation/config/startup/test_foundation_config_startup.py +199 -0
- foundation/config/app/test_foundation_config_app.py +0 -150
- foundation/config/root/test_foundation_config_root_paths.py +0 -201
- foundation/config/startup/test_foundation_config_startup.py +0 -205
- foundation/exceptions/__init__.py +0 -0
- foundation/exceptions/test_foundation_config_exceptions.py +0 -117
- {orionis-0.418.0.dist-info → orionis-0.419.0.dist-info}/WHEEL +0 -0
- {orionis-0.418.0.dist-info → orionis-0.419.0.dist-info}/licenses/LICENCE +0 -0
- {orionis-0.418.0.dist-info → orionis-0.419.0.dist-info}/zip-safe +0 -0
- {foundation → tests/foundation}/__init__.py +0 -0
- {foundation → tests/foundation}/config/__init__.py +0 -0
- {foundation → tests/foundation}/config/app/__init__.py +0 -0
- {foundation → tests/foundation}/config/auth/__init__.py +0 -0
- {foundation → tests/foundation}/config/auth/test_foundation_config_auth.py +0 -0
- {foundation → tests/foundation}/config/cache/__init__.py +0 -0
- {foundation → tests/foundation}/config/cache/test_foundation_config_cache.py +0 -0
- {foundation → tests/foundation}/config/cors/__init__.py +0 -0
- {foundation → tests/foundation}/config/cors/test_foundation_config_cors.py +0 -0
- {foundation → tests/foundation}/config/database/__init__.py +0 -0
- {foundation → tests/foundation}/config/database/test_foundation_config_database.py +0 -0
- {foundation → tests/foundation}/config/database/test_foundation_config_database_connections.py +0 -0
- {foundation → tests/foundation}/config/database/test_foundation_config_database_mysql.py +0 -0
- {foundation → tests/foundation}/config/database/test_foundation_config_database_oracle.py +0 -0
- {foundation → tests/foundation}/config/database/test_foundation_config_database_sqlite.py +0 -0
- {foundation → tests/foundation}/config/filesystems/__init__.py +0 -0
- {foundation → tests/foundation}/config/filesystems/test_foundation_config_filesystems.py +0 -0
- {foundation → tests/foundation}/config/filesystems/test_foundation_config_filesystems_aws.py +0 -0
- {foundation → tests/foundation}/config/filesystems/test_foundation_config_filesystems_disks.py +0 -0
- {foundation → tests/foundation}/config/filesystems/test_foundation_config_filesystems_local.py +0 -0
- {foundation → tests/foundation}/config/filesystems/test_foundation_config_filesystems_public.py +0 -0
- {foundation → tests/foundation}/config/logging/__init__.py +0 -0
- {foundation → tests/foundation}/config/logging/test_foundation_config_logging.py +0 -0
- {foundation → tests/foundation}/config/logging/test_foundation_config_logging_channels.py +0 -0
- {foundation → tests/foundation}/config/logging/test_foundation_config_logging_chunked.py +0 -0
- {foundation → tests/foundation}/config/logging/test_foundation_config_logging_daily.py +0 -0
- {foundation → tests/foundation}/config/logging/test_foundation_config_logging_hourly.py +0 -0
- {foundation → tests/foundation}/config/logging/test_foundation_config_logging_monthly.py +0 -0
- {foundation → tests/foundation}/config/logging/test_foundation_config_logging_stack.py +0 -0
- {foundation → tests/foundation}/config/logging/test_foundation_config_logging_weekly.py +0 -0
- {foundation → tests/foundation}/config/mail/__init__.py +0 -0
- {foundation → tests/foundation}/config/mail/test_foundation_config_mail.py +0 -0
- {foundation → tests/foundation}/config/mail/test_foundation_config_mail_file.py +0 -0
- {foundation → tests/foundation}/config/mail/test_foundation_config_mail_mailers.py +0 -0
- {foundation → tests/foundation}/config/mail/test_foundation_config_mail_smtp.py +0 -0
- {foundation → tests/foundation}/config/queue/__init__.py +0 -0
- {foundation → tests/foundation}/config/queue/test_foundation_config_queue_database.py +0 -0
- {foundation → tests/foundation}/config/root/__init__.py +0 -0
- {foundation → tests/foundation}/config/session/__init__.py +0 -0
- {foundation → tests/foundation}/config/session/test_foundation_config_session.py +0 -0
- {foundation → tests/foundation}/config/startup/__init__.py +0 -0
- {foundation → tests/foundation}/config/testing/__init__.py +0 -0
- {foundation → tests/foundation}/config/testing/test_foundation_config_testing.py +0 -0
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
from orionis.foundation.exceptions import OrionisIntegrityException
|
|
2
|
+
from orionis.foundation.config.roots.paths import Paths
|
|
3
|
+
from orionis.test.cases.asynchronous import AsyncTestCase
|
|
4
|
+
|
|
5
|
+
class TestFoundationConfigRootPaths(AsyncTestCase):
|
|
6
|
+
"""
|
|
7
|
+
Test suite for the Paths dataclass which defines the project directory structure.
|
|
8
|
+
|
|
9
|
+
This class verifies the integrity of path definitions, default values,
|
|
10
|
+
and the behavior of accessor methods.
|
|
11
|
+
|
|
12
|
+
Methods
|
|
13
|
+
-------
|
|
14
|
+
testDefaultPathsInstantiation()
|
|
15
|
+
Test that a Paths instance can be created with default values.
|
|
16
|
+
testAllPathsAreStrings()
|
|
17
|
+
Test that all path attributes are strings.
|
|
18
|
+
testPathValidationRejectsNonStringValues()
|
|
19
|
+
Test that non-string path values raise OrionisIntegrityException.
|
|
20
|
+
testToDictReturnsCompleteDictionary()
|
|
21
|
+
Test that toDict() returns a complete dictionary of all paths.
|
|
22
|
+
testFrozenDataclassBehavior()
|
|
23
|
+
Test that the dataclass is truly frozen (immutable).
|
|
24
|
+
testPathMetadataIsAccessible()
|
|
25
|
+
Test that path metadata is properly defined and accessible.
|
|
26
|
+
"""
|
|
27
|
+
|
|
28
|
+
def testDefaultPathsInstantiation(self):
|
|
29
|
+
"""
|
|
30
|
+
Test that a Paths instance can be created with default values.
|
|
31
|
+
|
|
32
|
+
Ensures that all default paths are correctly initialized and
|
|
33
|
+
the instance is properly constructed.
|
|
34
|
+
"""
|
|
35
|
+
paths = Paths()
|
|
36
|
+
self.assertIsInstance(paths, Paths)
|
|
37
|
+
|
|
38
|
+
def testAllPathsAreStrings(self):
|
|
39
|
+
"""
|
|
40
|
+
Test that all path attributes are strings.
|
|
41
|
+
|
|
42
|
+
Ensures that every field in Paths is a string by default.
|
|
43
|
+
"""
|
|
44
|
+
paths = Paths()
|
|
45
|
+
for field_name in paths.__dataclass_fields__:
|
|
46
|
+
value = getattr(paths, field_name)
|
|
47
|
+
self.assertIsInstance(value, str)
|
|
48
|
+
self.assertTrue(len(value) > 0)
|
|
49
|
+
|
|
50
|
+
def testPathValidationRejectsNonStringValues(self):
|
|
51
|
+
"""
|
|
52
|
+
Test that non-string path values raise OrionisIntegrityException.
|
|
53
|
+
|
|
54
|
+
Verifies that the __post_init__ validation rejects non-string values
|
|
55
|
+
for all path fields.
|
|
56
|
+
|
|
57
|
+
Raises
|
|
58
|
+
------
|
|
59
|
+
OrionisIntegrityException
|
|
60
|
+
If a non-string value is provided.
|
|
61
|
+
"""
|
|
62
|
+
with self.assertRaises(OrionisIntegrityException):
|
|
63
|
+
Paths(console_scheduler=123)
|
|
64
|
+
|
|
65
|
+
def testToDictReturnsCompleteDictionary(self):
|
|
66
|
+
"""
|
|
67
|
+
Test that toDict() returns a complete dictionary of all paths.
|
|
68
|
+
|
|
69
|
+
Verifies that the returned dictionary contains all path fields
|
|
70
|
+
with their current values.
|
|
71
|
+
|
|
72
|
+
Returns
|
|
73
|
+
-------
|
|
74
|
+
None
|
|
75
|
+
"""
|
|
76
|
+
paths = Paths()
|
|
77
|
+
path_dict = paths.toDict()
|
|
78
|
+
self.assertIsInstance(path_dict, dict)
|
|
79
|
+
self.assertEqual(len(path_dict), len(paths.__dataclass_fields__))
|
|
80
|
+
for field in paths.__dataclass_fields__:
|
|
81
|
+
self.assertIn(field, path_dict)
|
|
82
|
+
|
|
83
|
+
def testFrozenDataclassBehavior(self):
|
|
84
|
+
"""
|
|
85
|
+
Test that the dataclass is truly frozen (immutable).
|
|
86
|
+
|
|
87
|
+
Verifies that attempts to modify attributes after creation
|
|
88
|
+
raise exceptions.
|
|
89
|
+
|
|
90
|
+
Raises
|
|
91
|
+
------
|
|
92
|
+
Exception
|
|
93
|
+
If an attempt is made to modify a frozen dataclass.
|
|
94
|
+
"""
|
|
95
|
+
paths = Paths()
|
|
96
|
+
with self.assertRaises(Exception):
|
|
97
|
+
paths.console_scheduler = 'new/path' # type: ignore
|
|
98
|
+
|
|
99
|
+
def testPathMetadataIsAccessible(self):
|
|
100
|
+
"""
|
|
101
|
+
Test that path metadata is properly defined and accessible.
|
|
102
|
+
|
|
103
|
+
Verifies that each path field has the expected metadata structure
|
|
104
|
+
with description and default fields.
|
|
105
|
+
|
|
106
|
+
Returns
|
|
107
|
+
-------
|
|
108
|
+
None
|
|
109
|
+
"""
|
|
110
|
+
paths = Paths()
|
|
111
|
+
for field in paths.__dataclass_fields__.values():
|
|
112
|
+
metadata = field.metadata
|
|
113
|
+
self.assertIn('description', metadata)
|
|
114
|
+
self.assertIn('default', metadata)
|
|
115
|
+
self.assertIsInstance(metadata['description'], str)
|
|
116
|
+
self.assertIsInstance(metadata['default'], str)
|
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
from dataclasses import is_dataclass
|
|
2
|
+
from orionis.foundation.exceptions.integrity import OrionisIntegrityException
|
|
3
|
+
from orionis.foundation.config.startup import Configuration
|
|
4
|
+
from orionis.foundation.config.app.entities.app import App
|
|
5
|
+
from orionis.foundation.config.auth.entities.auth import Auth
|
|
6
|
+
from orionis.foundation.config.cache.entities.cache import Cache
|
|
7
|
+
from orionis.foundation.config.cors.entities.cors import Cors
|
|
8
|
+
from orionis.foundation.config.database.entities.database import Database
|
|
9
|
+
from orionis.foundation.config.roots.paths import Paths
|
|
10
|
+
from orionis.foundation.config.filesystems.entitites.filesystems import Filesystems
|
|
11
|
+
from orionis.foundation.config.logging.entities.logging import Logging
|
|
12
|
+
from orionis.foundation.config.mail.entities.mail import Mail
|
|
13
|
+
from orionis.foundation.config.queue.entities.queue import Queue
|
|
14
|
+
from orionis.foundation.config.session.entities.session import Session
|
|
15
|
+
from orionis.foundation.config.testing.entities.testing import Testing
|
|
16
|
+
from orionis.test.cases.asynchronous import AsyncTestCase
|
|
17
|
+
from unittest.mock import Mock
|
|
18
|
+
|
|
19
|
+
class TestFoundationConfigStartup(AsyncTestCase):
|
|
20
|
+
"""
|
|
21
|
+
Test suite for the Configuration dataclass.
|
|
22
|
+
|
|
23
|
+
Methods
|
|
24
|
+
-------
|
|
25
|
+
testConfigurationIsDataclass()
|
|
26
|
+
Test that Configuration is a dataclass.
|
|
27
|
+
testDefaultInitialization()
|
|
28
|
+
Test default initialization of Configuration.
|
|
29
|
+
testAllSectionsHaveDefaultFactories()
|
|
30
|
+
Test that all fields have default factories.
|
|
31
|
+
testTypeValidationInPostInit()
|
|
32
|
+
Test type validation and dict conversion in __post_init__.
|
|
33
|
+
testToDictReturnsCompleteDictionary()
|
|
34
|
+
Test that toDict() returns all configuration sections.
|
|
35
|
+
testToDictReturnsNestedStructures()
|
|
36
|
+
Test that toDict() returns nested structures as dicts.
|
|
37
|
+
testMetadataIsAccessible()
|
|
38
|
+
Test that field metadata is accessible and correct.
|
|
39
|
+
testConfigurationIsMutable()
|
|
40
|
+
Test that Configuration is mutable.
|
|
41
|
+
testConfigurationEquality()
|
|
42
|
+
Test equality of Configuration instances.
|
|
43
|
+
"""
|
|
44
|
+
|
|
45
|
+
def testConfigurationIsDataclass(self):
|
|
46
|
+
"""
|
|
47
|
+
Test that Configuration is a dataclass.
|
|
48
|
+
|
|
49
|
+
Returns
|
|
50
|
+
-------
|
|
51
|
+
None
|
|
52
|
+
"""
|
|
53
|
+
self.assertTrue(is_dataclass(Configuration))
|
|
54
|
+
|
|
55
|
+
def testDefaultInitialization(self):
|
|
56
|
+
"""
|
|
57
|
+
Test default initialization of Configuration.
|
|
58
|
+
|
|
59
|
+
Ensures all fields are initialized with their default factories.
|
|
60
|
+
|
|
61
|
+
Returns
|
|
62
|
+
-------
|
|
63
|
+
None
|
|
64
|
+
"""
|
|
65
|
+
config = Configuration()
|
|
66
|
+
self.assertIsInstance(config, Configuration)
|
|
67
|
+
self.assertIsInstance(config.app, App)
|
|
68
|
+
self.assertIsInstance(config.auth, Auth)
|
|
69
|
+
self.assertIsInstance(config.cache, Cache)
|
|
70
|
+
self.assertIsInstance(config.cors, Cors)
|
|
71
|
+
self.assertIsInstance(config.database, Database)
|
|
72
|
+
self.assertIsInstance(config.filesystems, Filesystems)
|
|
73
|
+
self.assertIsInstance(config.logging, Logging)
|
|
74
|
+
self.assertIsInstance(config.mail, Mail)
|
|
75
|
+
self.assertIsInstance(config.path, Paths)
|
|
76
|
+
self.assertIsInstance(config.queue, Queue)
|
|
77
|
+
self.assertIsInstance(config.session, Session)
|
|
78
|
+
self.assertIsInstance(config.testing, Testing)
|
|
79
|
+
|
|
80
|
+
def testAllSectionsHaveDefaultFactories(self):
|
|
81
|
+
"""
|
|
82
|
+
Test that all fields have default factories.
|
|
83
|
+
|
|
84
|
+
Returns
|
|
85
|
+
-------
|
|
86
|
+
None
|
|
87
|
+
"""
|
|
88
|
+
config = Configuration()
|
|
89
|
+
for field in config.__dataclass_fields__.values():
|
|
90
|
+
self.assertTrue(callable(field.default_factory),
|
|
91
|
+
f"Field {field.name} is missing default_factory")
|
|
92
|
+
|
|
93
|
+
def testTypeValidationInPostInit(self):
|
|
94
|
+
"""
|
|
95
|
+
Test type validation and dict conversion in __post_init__.
|
|
96
|
+
|
|
97
|
+
Ensures that dicts are converted to entities and wrong types raise OrionisIntegrityException.
|
|
98
|
+
|
|
99
|
+
Returns
|
|
100
|
+
-------
|
|
101
|
+
None
|
|
102
|
+
"""
|
|
103
|
+
# Valid dict conversion
|
|
104
|
+
config = Configuration(app={"name": "TestApp"})
|
|
105
|
+
self.assertIsInstance(config.app, App)
|
|
106
|
+
|
|
107
|
+
# Invalid types
|
|
108
|
+
sections = [
|
|
109
|
+
('app', 123),
|
|
110
|
+
('auth', 123),
|
|
111
|
+
('cache', 123),
|
|
112
|
+
('cors', 123),
|
|
113
|
+
('database', 123),
|
|
114
|
+
('filesystems', 123),
|
|
115
|
+
('logging', 123),
|
|
116
|
+
('mail', 123),
|
|
117
|
+
('path', 123),
|
|
118
|
+
('queue', 123),
|
|
119
|
+
('session', 123),
|
|
120
|
+
('testing', 123)
|
|
121
|
+
]
|
|
122
|
+
for section_name, wrong_value in sections:
|
|
123
|
+
with self.subTest(section=section_name):
|
|
124
|
+
kwargs = {section_name: wrong_value}
|
|
125
|
+
with self.assertRaises(OrionisIntegrityException):
|
|
126
|
+
Configuration(**kwargs)
|
|
127
|
+
|
|
128
|
+
def testToDictReturnsCompleteDictionary(self):
|
|
129
|
+
"""
|
|
130
|
+
Test that toDict() returns all configuration sections.
|
|
131
|
+
|
|
132
|
+
Returns
|
|
133
|
+
-------
|
|
134
|
+
None
|
|
135
|
+
"""
|
|
136
|
+
config = Configuration()
|
|
137
|
+
config_dict = config.toDict()
|
|
138
|
+
self.assertIsInstance(config_dict, dict)
|
|
139
|
+
self.assertEqual(set(config_dict.keys()), set(config.__dataclass_fields__.keys()))
|
|
140
|
+
|
|
141
|
+
def testToDictReturnsNestedStructures(self):
|
|
142
|
+
"""
|
|
143
|
+
Test that toDict() returns nested structures as dicts.
|
|
144
|
+
|
|
145
|
+
Returns
|
|
146
|
+
-------
|
|
147
|
+
None
|
|
148
|
+
"""
|
|
149
|
+
config = Configuration()
|
|
150
|
+
config_dict = config.toDict()
|
|
151
|
+
self.assertIsInstance(config_dict['app'], dict)
|
|
152
|
+
self.assertIsInstance(config_dict['auth'], dict)
|
|
153
|
+
self.assertIsInstance(config_dict['database'], dict)
|
|
154
|
+
self.assertIsInstance(config_dict['path'], dict)
|
|
155
|
+
|
|
156
|
+
def testMetadataIsAccessible(self):
|
|
157
|
+
"""
|
|
158
|
+
Test that field metadata is accessible and correct.
|
|
159
|
+
|
|
160
|
+
Returns
|
|
161
|
+
-------
|
|
162
|
+
None
|
|
163
|
+
"""
|
|
164
|
+
config = Configuration()
|
|
165
|
+
for field in config.__dataclass_fields__.values():
|
|
166
|
+
metadata = field.metadata
|
|
167
|
+
self.assertIn('description', metadata)
|
|
168
|
+
self.assertIsInstance(metadata['description'], str)
|
|
169
|
+
self.assertIn('default', metadata)
|
|
170
|
+
|
|
171
|
+
def testConfigurationIsMutable(self):
|
|
172
|
+
"""
|
|
173
|
+
Test that Configuration is mutable.
|
|
174
|
+
|
|
175
|
+
Returns
|
|
176
|
+
-------
|
|
177
|
+
None
|
|
178
|
+
"""
|
|
179
|
+
config = Configuration()
|
|
180
|
+
new_app = App()
|
|
181
|
+
try:
|
|
182
|
+
config.app = new_app
|
|
183
|
+
except Exception as e:
|
|
184
|
+
self.fail(f"Should be able to modify attributes, but got {type(e).__name__}")
|
|
185
|
+
|
|
186
|
+
def testConfigurationEquality(self):
|
|
187
|
+
"""
|
|
188
|
+
Test equality of Configuration instances.
|
|
189
|
+
|
|
190
|
+
Returns
|
|
191
|
+
-------
|
|
192
|
+
None
|
|
193
|
+
"""
|
|
194
|
+
# Ensure both configs have identical App objects, but their keys differ
|
|
195
|
+
app_data = {"name": "TestApp"}
|
|
196
|
+
config1 = Configuration(app=app_data)
|
|
197
|
+
config2 = Configuration(app=app_data)
|
|
198
|
+
# The key (e.g., a generated UUID or secret) will be different for each instance
|
|
199
|
+
self.assertNotEqual(config1, config2)
|
|
@@ -1,150 +0,0 @@
|
|
|
1
|
-
from orionis.foundation.config.app.entities.app import App
|
|
2
|
-
from orionis.foundation.config.app.enums.ciphers import Cipher
|
|
3
|
-
from orionis.foundation.config.app.enums.environments import Environments
|
|
4
|
-
from orionis.foundation.exceptions.integrity import OrionisIntegrityException
|
|
5
|
-
from orionis.test.cases.asynchronous import AsyncTestCase
|
|
6
|
-
|
|
7
|
-
class TestFoundationConfigApp(AsyncTestCase):
|
|
8
|
-
|
|
9
|
-
async def testDefaultValues(self):
|
|
10
|
-
"""
|
|
11
|
-
Test that the App instance is created with the correct default values.
|
|
12
|
-
|
|
13
|
-
Notes
|
|
14
|
-
-----
|
|
15
|
-
Verifies that all default values match the expected defaults from the class definition.
|
|
16
|
-
"""
|
|
17
|
-
app = App()
|
|
18
|
-
self.assertEqual(app.name, 'Orionis Application')
|
|
19
|
-
self.assertEqual(app.env, Environments.DEVELOPMENT.value)
|
|
20
|
-
self.assertTrue(app.debug)
|
|
21
|
-
self.assertEqual(app.url, 'http://127.0.0.1')
|
|
22
|
-
self.assertEqual(app.port, 8000)
|
|
23
|
-
self.assertEqual(app.timezone, 'UTC')
|
|
24
|
-
self.assertEqual(app.locale, 'en')
|
|
25
|
-
self.assertEqual(app.fallback_locale, 'en')
|
|
26
|
-
self.assertEqual(app.cipher, Cipher.AES_256_CBC.value)
|
|
27
|
-
self.assertIsNone(app.key)
|
|
28
|
-
self.assertEqual(app.maintenance, '/maintenance')
|
|
29
|
-
|
|
30
|
-
async def testEnvironmentValidation(self):
|
|
31
|
-
"""
|
|
32
|
-
Test that the environment attribute is properly validated and converted.
|
|
33
|
-
|
|
34
|
-
Notes
|
|
35
|
-
-----
|
|
36
|
-
Verifies that string environments are converted to enum values and invalid environments raise exceptions.
|
|
37
|
-
"""
|
|
38
|
-
# Test valid string environment
|
|
39
|
-
app = App(env="PRODUCTION")
|
|
40
|
-
self.assertEqual(app.env, Environments.PRODUCTION.value)
|
|
41
|
-
|
|
42
|
-
# Test valid enum environment
|
|
43
|
-
app = App(env=Environments.TESTING)
|
|
44
|
-
self.assertEqual(app.env, Environments.TESTING.value)
|
|
45
|
-
|
|
46
|
-
# Test invalid environment
|
|
47
|
-
with self.assertRaises(OrionisIntegrityException):
|
|
48
|
-
App(env="INVALID_ENV")
|
|
49
|
-
|
|
50
|
-
async def testCipherValidation(self):
|
|
51
|
-
"""
|
|
52
|
-
Test that the cipher attribute is properly validated and converted.
|
|
53
|
-
|
|
54
|
-
Notes
|
|
55
|
-
-----
|
|
56
|
-
Verifies that string ciphers are converted to enum values and invalid ciphers raise exceptions.
|
|
57
|
-
"""
|
|
58
|
-
# Test valid string cipher
|
|
59
|
-
app = App(cipher="AES_128_CBC")
|
|
60
|
-
self.assertEqual(app.cipher, Cipher.AES_128_CBC.value)
|
|
61
|
-
|
|
62
|
-
# Test valid enum cipher
|
|
63
|
-
app = App(cipher=Cipher.AES_192_CBC)
|
|
64
|
-
self.assertEqual(app.cipher, Cipher.AES_192_CBC.value)
|
|
65
|
-
|
|
66
|
-
# Test invalid cipher
|
|
67
|
-
with self.assertRaises(OrionisIntegrityException):
|
|
68
|
-
App(cipher="INVALID_CIPHER")
|
|
69
|
-
|
|
70
|
-
async def testTypeValidation(self):
|
|
71
|
-
"""
|
|
72
|
-
Test that type validation works correctly for all attributes.
|
|
73
|
-
|
|
74
|
-
Notes
|
|
75
|
-
-----
|
|
76
|
-
Verifies that invalid types for each attribute raise OrionisIntegrityException.
|
|
77
|
-
"""
|
|
78
|
-
# Test invalid name type
|
|
79
|
-
with self.assertRaises(OrionisIntegrityException):
|
|
80
|
-
App(name=123)
|
|
81
|
-
|
|
82
|
-
# Test invalid debug type
|
|
83
|
-
with self.assertRaises(OrionisIntegrityException):
|
|
84
|
-
App(debug="true")
|
|
85
|
-
|
|
86
|
-
# Test invalid url type
|
|
87
|
-
with self.assertRaises(OrionisIntegrityException):
|
|
88
|
-
App(url=123)
|
|
89
|
-
|
|
90
|
-
# Test invalid port type
|
|
91
|
-
with self.assertRaises(OrionisIntegrityException):
|
|
92
|
-
App(port="8000")
|
|
93
|
-
|
|
94
|
-
# Test invalid workers type
|
|
95
|
-
with self.assertRaises(OrionisIntegrityException):
|
|
96
|
-
App(workers="4")
|
|
97
|
-
|
|
98
|
-
# Test invalid reload type
|
|
99
|
-
with self.assertRaises(OrionisIntegrityException):
|
|
100
|
-
App(reload="true")
|
|
101
|
-
|
|
102
|
-
async def testToDictMethod(self):
|
|
103
|
-
"""
|
|
104
|
-
Test that the toDict method returns a proper dictionary representation.
|
|
105
|
-
|
|
106
|
-
Notes
|
|
107
|
-
-----
|
|
108
|
-
Verifies that the returned dictionary contains all expected keys and values.
|
|
109
|
-
"""
|
|
110
|
-
app = App()
|
|
111
|
-
app_dict = app.toDict()
|
|
112
|
-
|
|
113
|
-
self.assertIsInstance(app_dict, dict)
|
|
114
|
-
self.assertEqual(app_dict['name'], 'Orionis Application')
|
|
115
|
-
self.assertEqual(app_dict['env'], Environments.DEVELOPMENT.value)
|
|
116
|
-
self.assertTrue(app_dict['debug'])
|
|
117
|
-
self.assertEqual(app_dict['url'], 'http://127.0.0.1')
|
|
118
|
-
self.assertEqual(app_dict['port'], 8000)
|
|
119
|
-
self.assertEqual(app_dict['timezone'], 'UTC')
|
|
120
|
-
self.assertEqual(app_dict['locale'], 'en')
|
|
121
|
-
self.assertEqual(app_dict['fallback_locale'], 'en')
|
|
122
|
-
self.assertEqual(app_dict['cipher'], Cipher.AES_256_CBC.value)
|
|
123
|
-
self.assertIsNone(app_dict['key'])
|
|
124
|
-
self.assertEqual(app_dict['maintenance'], '/maintenance')
|
|
125
|
-
|
|
126
|
-
async def testNonEmptyStringValidation(self):
|
|
127
|
-
"""
|
|
128
|
-
Test that empty strings are rejected for attributes requiring non-empty strings.
|
|
129
|
-
|
|
130
|
-
Notes
|
|
131
|
-
-----
|
|
132
|
-
Verifies that attributes requiring non-empty strings raise exceptions when empty strings are provided.
|
|
133
|
-
"""
|
|
134
|
-
with self.assertRaises(OrionisIntegrityException):
|
|
135
|
-
App(name="")
|
|
136
|
-
|
|
137
|
-
with self.assertRaises(OrionisIntegrityException):
|
|
138
|
-
App(url="")
|
|
139
|
-
|
|
140
|
-
with self.assertRaises(OrionisIntegrityException):
|
|
141
|
-
App(timezone="")
|
|
142
|
-
|
|
143
|
-
with self.assertRaises(OrionisIntegrityException):
|
|
144
|
-
App(locale="")
|
|
145
|
-
|
|
146
|
-
with self.assertRaises(OrionisIntegrityException):
|
|
147
|
-
App(fallback_locale="")
|
|
148
|
-
|
|
149
|
-
with self.assertRaises(OrionisIntegrityException):
|
|
150
|
-
App(maintenance="")
|
|
@@ -1,201 +0,0 @@
|
|
|
1
|
-
from pathlib import Path
|
|
2
|
-
from orionis.foundation.exceptions import OrionisIntegrityException
|
|
3
|
-
from orionis.foundation.config.roots.paths import Paths
|
|
4
|
-
from orionis.test.cases.asynchronous import AsyncTestCase
|
|
5
|
-
|
|
6
|
-
class TestFoundationConfigRootPaths(AsyncTestCase):
|
|
7
|
-
"""
|
|
8
|
-
Test suite for the Paths dataclass which defines the project directory structure.
|
|
9
|
-
|
|
10
|
-
This class verifies the integrity of path definitions, default values,
|
|
11
|
-
and the behavior of accessor methods.
|
|
12
|
-
|
|
13
|
-
Attributes
|
|
14
|
-
----------
|
|
15
|
-
None
|
|
16
|
-
|
|
17
|
-
Methods
|
|
18
|
-
-------
|
|
19
|
-
testDefaultPathsInstantiation()
|
|
20
|
-
Test that a Paths instance can be created with default values.
|
|
21
|
-
testRequiredPathsAreSet()
|
|
22
|
-
Test that all required paths have non-empty default values.
|
|
23
|
-
testOptionalPathsCanBeEmpty()
|
|
24
|
-
Test that optional paths can be empty strings.
|
|
25
|
-
testPathValidationRejectsNonStringValues()
|
|
26
|
-
Test that non-string path values raise OrionisIntegrityException.
|
|
27
|
-
testPathValidationRejectsEmptyRequiredPaths()
|
|
28
|
-
Test that empty required paths raise OrionisIntegrityException.
|
|
29
|
-
testToDictReturnsCompleteDictionary()
|
|
30
|
-
Test that toDict() returns a complete dictionary of all paths.
|
|
31
|
-
testPathAccessorMethodsReturnPathObjects()
|
|
32
|
-
Test that all path accessor methods return Path objects.
|
|
33
|
-
testFrozenDataclassBehavior()
|
|
34
|
-
Test that the dataclass is truly frozen (immutable).
|
|
35
|
-
testPathMetadataIsAccessible()
|
|
36
|
-
Test that path metadata is properly defined and accessible.
|
|
37
|
-
"""
|
|
38
|
-
|
|
39
|
-
def testDefaultPathsInstantiation(self):
|
|
40
|
-
"""
|
|
41
|
-
Test that a Paths instance can be created with default values.
|
|
42
|
-
|
|
43
|
-
Ensures that all default paths are correctly initialized and
|
|
44
|
-
the instance is properly constructed.
|
|
45
|
-
"""
|
|
46
|
-
paths = Paths()
|
|
47
|
-
self.assertIsInstance(paths, Paths)
|
|
48
|
-
|
|
49
|
-
def testRequiredPathsAreSet(self):
|
|
50
|
-
"""
|
|
51
|
-
Test that all required paths have non-empty default values.
|
|
52
|
-
|
|
53
|
-
Checks that paths marked as required in metadata are properly
|
|
54
|
-
initialized with valid string values.
|
|
55
|
-
"""
|
|
56
|
-
paths = Paths()
|
|
57
|
-
required_fields = [
|
|
58
|
-
'console_scheduler', 'console_commands', 'http_controllers',
|
|
59
|
-
'http_middleware', 'models', 'providers', 'exceptions',
|
|
60
|
-
'views', 'routes_web', 'config', 'migrations',
|
|
61
|
-
'storage_logs', 'storage_framework'
|
|
62
|
-
]
|
|
63
|
-
for field in required_fields:
|
|
64
|
-
value = getattr(paths, field)
|
|
65
|
-
self.assertTrue(isinstance(value, str) and len(value) > 0)
|
|
66
|
-
|
|
67
|
-
def testOptionalPathsCanBeEmpty(self):
|
|
68
|
-
"""
|
|
69
|
-
Test that optional paths can be empty strings.
|
|
70
|
-
|
|
71
|
-
Verifies that paths not marked as required can be empty strings
|
|
72
|
-
without raising exceptions.
|
|
73
|
-
|
|
74
|
-
Raises
|
|
75
|
-
------
|
|
76
|
-
OrionisIntegrityException
|
|
77
|
-
If required validation fails.
|
|
78
|
-
"""
|
|
79
|
-
with self.assertRaises(OrionisIntegrityException):
|
|
80
|
-
Paths(
|
|
81
|
-
http_requests='',
|
|
82
|
-
events='',
|
|
83
|
-
listeners='',
|
|
84
|
-
notifications='',
|
|
85
|
-
jobs='',
|
|
86
|
-
policies='',
|
|
87
|
-
services='',
|
|
88
|
-
lang='',
|
|
89
|
-
assets='',
|
|
90
|
-
routes_api='',
|
|
91
|
-
routes_console='',
|
|
92
|
-
routes_channels='',
|
|
93
|
-
seeders='',
|
|
94
|
-
factories='',
|
|
95
|
-
storage_sessions='',
|
|
96
|
-
storage_cache='',
|
|
97
|
-
storage_views=''
|
|
98
|
-
)
|
|
99
|
-
|
|
100
|
-
def testPathValidationRejectsNonStringValues(self):
|
|
101
|
-
"""
|
|
102
|
-
Test that non-string path values raise OrionisIntegrityException.
|
|
103
|
-
|
|
104
|
-
Verifies that the __post_init__ validation rejects non-string values
|
|
105
|
-
for all path fields.
|
|
106
|
-
|
|
107
|
-
Raises
|
|
108
|
-
------
|
|
109
|
-
OrionisIntegrityException
|
|
110
|
-
If a non-string value is provided.
|
|
111
|
-
"""
|
|
112
|
-
with self.assertRaises(OrionisIntegrityException):
|
|
113
|
-
Paths(console_scheduler=123)
|
|
114
|
-
|
|
115
|
-
def testPathValidationRejectsEmptyRequiredPaths(self):
|
|
116
|
-
"""
|
|
117
|
-
Test that empty required paths raise OrionisIntegrityException.
|
|
118
|
-
|
|
119
|
-
Verifies that required paths cannot be empty strings.
|
|
120
|
-
|
|
121
|
-
Raises
|
|
122
|
-
------
|
|
123
|
-
OrionisIntegrityException
|
|
124
|
-
If a required path is empty.
|
|
125
|
-
"""
|
|
126
|
-
with self.assertRaises(OrionisIntegrityException):
|
|
127
|
-
Paths(console_scheduler='')
|
|
128
|
-
|
|
129
|
-
def testToDictReturnsCompleteDictionary(self):
|
|
130
|
-
"""
|
|
131
|
-
Test that toDict() returns a complete dictionary of all paths.
|
|
132
|
-
|
|
133
|
-
Verifies that the returned dictionary contains all path fields
|
|
134
|
-
with their current values.
|
|
135
|
-
|
|
136
|
-
Returns
|
|
137
|
-
-------
|
|
138
|
-
None
|
|
139
|
-
"""
|
|
140
|
-
paths = Paths()
|
|
141
|
-
path_dict = paths.toDict()
|
|
142
|
-
self.assertIsInstance(path_dict, dict)
|
|
143
|
-
self.assertEqual(len(path_dict), len(paths.__dataclass_fields__))
|
|
144
|
-
for field in paths.__dataclass_fields__:
|
|
145
|
-
self.assertIn(field, path_dict)
|
|
146
|
-
|
|
147
|
-
def testPathAccessorMethodsReturnPathObjects(self):
|
|
148
|
-
"""
|
|
149
|
-
Test that all path accessor methods return Path objects.
|
|
150
|
-
|
|
151
|
-
Verifies that each get* method returns a proper pathlib.Path instance.
|
|
152
|
-
|
|
153
|
-
Returns
|
|
154
|
-
-------
|
|
155
|
-
None
|
|
156
|
-
"""
|
|
157
|
-
paths = Paths()
|
|
158
|
-
self.assertIsInstance(paths.getConsoleScheduler(), Path)
|
|
159
|
-
self.assertIsInstance(paths.getHttpControllers(), Path)
|
|
160
|
-
self.assertIsInstance(paths.getModels(), Path)
|
|
161
|
-
self.assertIsInstance(paths.getViews(), Path)
|
|
162
|
-
self.assertIsInstance(paths.getRoutesWeb(), Path)
|
|
163
|
-
self.assertIsInstance(paths.getConfig(), Path)
|
|
164
|
-
self.assertIsInstance(paths.getMigrations(), Path)
|
|
165
|
-
self.assertIsInstance(paths.getStorageLogs(), Path)
|
|
166
|
-
|
|
167
|
-
def testFrozenDataclassBehavior(self):
|
|
168
|
-
"""
|
|
169
|
-
Test that the dataclass is truly frozen (immutable).
|
|
170
|
-
|
|
171
|
-
Verifies that attempts to modify attributes after creation
|
|
172
|
-
raise exceptions.
|
|
173
|
-
|
|
174
|
-
Raises
|
|
175
|
-
------
|
|
176
|
-
Exception
|
|
177
|
-
If an attempt is made to modify a frozen dataclass.
|
|
178
|
-
"""
|
|
179
|
-
paths = Paths()
|
|
180
|
-
with self.assertRaises(Exception):
|
|
181
|
-
paths.console_scheduler = 'new/path' # type: ignore
|
|
182
|
-
|
|
183
|
-
def testPathMetadataIsAccessible(self):
|
|
184
|
-
"""
|
|
185
|
-
Test that path metadata is properly defined and accessible.
|
|
186
|
-
|
|
187
|
-
Verifies that each path field has the expected metadata structure
|
|
188
|
-
with description, type, and required fields.
|
|
189
|
-
|
|
190
|
-
Returns
|
|
191
|
-
-------
|
|
192
|
-
None
|
|
193
|
-
"""
|
|
194
|
-
paths = Paths()
|
|
195
|
-
for field in paths.__dataclass_fields__.values():
|
|
196
|
-
metadata = field.metadata
|
|
197
|
-
self.assertIn('description', metadata)
|
|
198
|
-
self.assertIn('type', metadata)
|
|
199
|
-
self.assertIn('required', metadata)
|
|
200
|
-
self.assertIn(metadata['type'], ['file', 'directory'])
|
|
201
|
-
self.assertIsInstance(metadata['required'], bool)
|