orionis 0.418.0__py3-none-any.whl → 0.420.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.
Files changed (136) hide show
  1. orionis/metadata/framework.py +1 -1
  2. {orionis-0.418.0.dist-info → orionis-0.420.0.dist-info}/METADATA +1 -1
  3. {orionis-0.418.0.dist-info → orionis-0.420.0.dist-info}/RECORD +58 -133
  4. {orionis-0.418.0.dist-info → orionis-0.420.0.dist-info}/top_level.txt +0 -1
  5. tests/foundation/config/app/test_foundation_config_app.py +262 -0
  6. {foundation → tests/foundation}/config/cache/test_foundation_config_cache_file.py +8 -8
  7. {foundation → tests/foundation}/config/cache/test_foundation_config_cache_stores.py +11 -3
  8. {foundation → tests/foundation}/config/database/test_foundation_config_database_pgsql.py +5 -5
  9. {foundation → tests/foundation}/config/queue/test_foundation_config_queue.py +0 -20
  10. {foundation → tests/foundation}/config/queue/test_foundation_config_queue_brokers.py +0 -13
  11. tests/foundation/config/root/test_foundation_config_root_paths.py +116 -0
  12. tests/foundation/config/startup/test_foundation_config_startup.py +199 -0
  13. foundation/config/app/test_foundation_config_app.py +0 -150
  14. foundation/config/root/test_foundation_config_root_paths.py +0 -201
  15. foundation/config/startup/test_foundation_config_startup.py +0 -205
  16. foundation/exceptions/__init__.py +0 -0
  17. foundation/exceptions/test_foundation_config_exceptions.py +0 -117
  18. orionis/_contracts/__init__.py +0 -0
  19. orionis/_contracts/application.py +0 -41
  20. orionis/_contracts/config/__init__.py +0 -0
  21. orionis/_contracts/config/config.py +0 -27
  22. orionis/_contracts/console/__init__.py +0 -0
  23. orionis/_contracts/console/base/__init__.py +0 -0
  24. orionis/_contracts/console/base/command.py +0 -437
  25. orionis/_contracts/console/command_filter.py +0 -32
  26. orionis/_contracts/console/kernel.py +0 -32
  27. orionis/_contracts/console/output/__init__.py +0 -0
  28. orionis/_contracts/console/output/console.py +0 -421
  29. orionis/_contracts/console/output/executor.py +0 -51
  30. orionis/_contracts/console/parser.py +0 -75
  31. orionis/_contracts/console/task_manager.py +0 -37
  32. orionis/_contracts/facades/__init__.py +0 -0
  33. orionis/_contracts/facades/commands/__init__.py +0 -0
  34. orionis/_contracts/facades/commands/commands_facade.py +0 -40
  35. orionis/_contracts/facades/commands/scheduler_facade.py +0 -28
  36. orionis/_contracts/facades/config/__init__.py +0 -0
  37. orionis/_contracts/facades/config/config_facade.py +0 -37
  38. orionis/_contracts/facades/environment/__init__.py +0 -0
  39. orionis/_contracts/facades/environment/environment_facade.py +0 -74
  40. orionis/_contracts/facades/facade.py +0 -38
  41. orionis/_contracts/facades/files/__init__.py +0 -0
  42. orionis/_contracts/facades/files/path_facade.py +0 -148
  43. orionis/_contracts/facades/log/__init__.py +0 -0
  44. orionis/_contracts/facades/log/log_facade.py +0 -83
  45. orionis/_contracts/facades/tests/__init__.py +0 -0
  46. orionis/_contracts/facades/tests/tests_facade.py +0 -30
  47. orionis/_contracts/foundation/__init__.py +0 -0
  48. orionis/_contracts/foundation/bootstraper.py +0 -41
  49. orionis/_contracts/foundation/config/__init__.py +0 -0
  50. orionis/_contracts/foundation/config/config_bootstrapper.py +0 -140
  51. orionis/_contracts/foundation/console/__init__.py +0 -0
  52. orionis/_contracts/foundation/console/command_bootstrapper.py +0 -81
  53. orionis/_contracts/foundation/environment/__init__.py +0 -0
  54. orionis/_contracts/foundation/environment/environment_bootstrapper.py +0 -33
  55. orionis/_contracts/foundation/providers/__init__.py +0 -0
  56. orionis/_contracts/foundation/providers/service_providers_bootstrapper.py +0 -47
  57. orionis/_contracts/providers/__init__.py +0 -0
  58. orionis/_contracts/providers/service_provider.py +0 -14
  59. orionis/_contracts/services/__init__.py +0 -0
  60. orionis/_contracts/services/commands/__init__.py +0 -0
  61. orionis/_contracts/services/commands/reactor_commands_service.py +0 -23
  62. orionis/_contracts/services/commands/schedule_service.py +0 -317
  63. orionis/_contracts/services/config/__init__.py +0 -0
  64. orionis/_contracts/services/config/config_service.py +0 -37
  65. orionis/_contracts/services/environment/__init__.py +0 -0
  66. orionis/_contracts/services/environment/environment_service.py +0 -74
  67. orionis/_contracts/services/files/__init__.py +0 -0
  68. orionis/_contracts/services/files/path_resolver_service.py +0 -29
  69. orionis/_contracts/services/log/__init__.py +0 -0
  70. orionis/_contracts/services/log/log_service.py +0 -89
  71. orionis/_contracts/support/exception_parse.py +0 -26
  72. orionis/_contracts/support/reflection.py +0 -352
  73. orionis/_foundation/__init__.py +0 -0
  74. orionis/_foundation/console/__init__.py +0 -0
  75. orionis/_foundation/console/command_bootstrapper.py +0 -175
  76. orionis/_foundation/environment/__init__.py +0 -0
  77. orionis/_foundation/environment/environment_bootstrapper.py +0 -76
  78. orionis/_foundation/exceptions/__init__.py +0 -0
  79. orionis/_foundation/exceptions/exception_bootstrapper.py +0 -54
  80. orionis/_foundation/exceptions/exception_providers.py +0 -54
  81. orionis/_foundation/foundation/config/__init__.py +0 -0
  82. orionis/_foundation/foundation/config/config_bootstrapper.py +0 -209
  83. orionis/_foundation/providers/__init__.py +0 -0
  84. orionis/_foundation/providers/service_providers_bootstrapper.py +0 -107
  85. orionis/_services/__init__.py +0 -0
  86. orionis/_services/commands/__init__.py +0 -0
  87. orionis/_services/commands/reactor_commands_service.py +0 -148
  88. orionis/_services/commands/scheduler_service.py +0 -611
  89. orionis/_services/config/__init__.py +0 -0
  90. orionis/_services/config/config_service.py +0 -72
  91. {orionis-0.418.0.dist-info → orionis-0.420.0.dist-info}/WHEEL +0 -0
  92. {orionis-0.418.0.dist-info → orionis-0.420.0.dist-info}/licenses/LICENCE +0 -0
  93. {orionis-0.418.0.dist-info → orionis-0.420.0.dist-info}/zip-safe +0 -0
  94. {foundation → tests/foundation}/__init__.py +0 -0
  95. {foundation → tests/foundation}/config/__init__.py +0 -0
  96. {foundation → tests/foundation}/config/app/__init__.py +0 -0
  97. {foundation → tests/foundation}/config/auth/__init__.py +0 -0
  98. {foundation → tests/foundation}/config/auth/test_foundation_config_auth.py +0 -0
  99. {foundation → tests/foundation}/config/cache/__init__.py +0 -0
  100. {foundation → tests/foundation}/config/cache/test_foundation_config_cache.py +0 -0
  101. {foundation → tests/foundation}/config/cors/__init__.py +0 -0
  102. {foundation → tests/foundation}/config/cors/test_foundation_config_cors.py +0 -0
  103. {foundation → tests/foundation}/config/database/__init__.py +0 -0
  104. {foundation → tests/foundation}/config/database/test_foundation_config_database.py +0 -0
  105. {foundation → tests/foundation}/config/database/test_foundation_config_database_connections.py +0 -0
  106. {foundation → tests/foundation}/config/database/test_foundation_config_database_mysql.py +0 -0
  107. {foundation → tests/foundation}/config/database/test_foundation_config_database_oracle.py +0 -0
  108. {foundation → tests/foundation}/config/database/test_foundation_config_database_sqlite.py +0 -0
  109. {foundation → tests/foundation}/config/filesystems/__init__.py +0 -0
  110. {foundation → tests/foundation}/config/filesystems/test_foundation_config_filesystems.py +0 -0
  111. {foundation → tests/foundation}/config/filesystems/test_foundation_config_filesystems_aws.py +0 -0
  112. {foundation → tests/foundation}/config/filesystems/test_foundation_config_filesystems_disks.py +0 -0
  113. {foundation → tests/foundation}/config/filesystems/test_foundation_config_filesystems_local.py +0 -0
  114. {foundation → tests/foundation}/config/filesystems/test_foundation_config_filesystems_public.py +0 -0
  115. {foundation → tests/foundation}/config/logging/__init__.py +0 -0
  116. {foundation → tests/foundation}/config/logging/test_foundation_config_logging.py +0 -0
  117. {foundation → tests/foundation}/config/logging/test_foundation_config_logging_channels.py +0 -0
  118. {foundation → tests/foundation}/config/logging/test_foundation_config_logging_chunked.py +0 -0
  119. {foundation → tests/foundation}/config/logging/test_foundation_config_logging_daily.py +0 -0
  120. {foundation → tests/foundation}/config/logging/test_foundation_config_logging_hourly.py +0 -0
  121. {foundation → tests/foundation}/config/logging/test_foundation_config_logging_monthly.py +0 -0
  122. {foundation → tests/foundation}/config/logging/test_foundation_config_logging_stack.py +0 -0
  123. {foundation → tests/foundation}/config/logging/test_foundation_config_logging_weekly.py +0 -0
  124. {foundation → tests/foundation}/config/mail/__init__.py +0 -0
  125. {foundation → tests/foundation}/config/mail/test_foundation_config_mail.py +0 -0
  126. {foundation → tests/foundation}/config/mail/test_foundation_config_mail_file.py +0 -0
  127. {foundation → tests/foundation}/config/mail/test_foundation_config_mail_mailers.py +0 -0
  128. {foundation → tests/foundation}/config/mail/test_foundation_config_mail_smtp.py +0 -0
  129. {foundation → tests/foundation}/config/queue/__init__.py +0 -0
  130. {foundation → tests/foundation}/config/queue/test_foundation_config_queue_database.py +0 -0
  131. {foundation → tests/foundation}/config/root/__init__.py +0 -0
  132. {foundation → tests/foundation}/config/session/__init__.py +0 -0
  133. {foundation → tests/foundation}/config/session/test_foundation_config_session.py +0 -0
  134. {foundation → tests/foundation}/config/startup/__init__.py +0 -0
  135. {foundation → tests/foundation}/config/testing/__init__.py +0 -0
  136. {foundation → tests/foundation}/config/testing/test_foundation_config_testing.py +0 -0
@@ -26,9 +26,9 @@ class TestFoundationConfigDatabasePgsql(AsyncTestCase):
26
26
  pgsql = PGSQL()
27
27
  self.assertEqual(pgsql.driver, 'pgsql')
28
28
  self.assertEqual(pgsql.host, '127.0.0.1')
29
- self.assertEqual(pgsql.port, '5432')
29
+ self.assertEqual(pgsql.port, 5432)
30
30
  self.assertEqual(pgsql.database, 'orionis')
31
- self.assertEqual(pgsql.username, 'root')
31
+ self.assertEqual(pgsql.username, 'postgres')
32
32
  self.assertEqual(pgsql.password, '')
33
33
  self.assertEqual(pgsql.charset, PGSQLCharset.UTF8.value)
34
34
  self.assertEqual(pgsql.prefix, '')
@@ -79,7 +79,7 @@ class TestFoundationConfigDatabasePgsql(AsyncTestCase):
79
79
  with self.assertRaises(OrionisIntegrityException):
80
80
  PGSQL(port='abc')
81
81
  with self.assertRaises(OrionisIntegrityException):
82
- PGSQL(port=5432) # Should be string
82
+ PGSQL(port='string')
83
83
 
84
84
  async def testDatabaseValidation(self):
85
85
  """
@@ -213,9 +213,9 @@ class TestFoundationConfigDatabasePgsql(AsyncTestCase):
213
213
  pgsql_dict = pgsql.toDict()
214
214
  self.assertEqual(pgsql_dict['driver'], 'pgsql')
215
215
  self.assertEqual(pgsql_dict['host'], '127.0.0.1')
216
- self.assertEqual(pgsql_dict['port'], '5432')
216
+ self.assertEqual(pgsql_dict['port'], 5432)
217
217
  self.assertEqual(pgsql_dict['database'], 'orionis')
218
- self.assertEqual(pgsql_dict['username'], 'root')
218
+ self.assertEqual(pgsql_dict['username'], 'postgres')
219
219
  self.assertEqual(pgsql_dict['password'], '')
220
220
  self.assertEqual(pgsql_dict['charset'], PGSQLCharset.UTF8.value)
221
221
  self.assertEqual(pgsql_dict['prefix'], '')
@@ -44,26 +44,6 @@ class TestFoundationConfigQueue(AsyncTestCase):
44
44
  with self.assertRaises(OrionisIntegrityException):
45
45
  Queue(default=option)
46
46
 
47
- async def testBrokersValidation(self):
48
- """
49
- Test validation of the `brokers` attribute.
50
-
51
- Ensures that non-Brokers values for the `brokers` attribute raise an OrionisIntegrityException.
52
-
53
- Returns
54
- -------
55
- None
56
-
57
- Raises
58
- ------
59
- OrionisIntegrityException
60
- If a non-Brokers value is provided for brokers.
61
- """
62
- with self.assertRaises(OrionisIntegrityException):
63
- Queue(brokers="invalid_brokers")
64
- with self.assertRaises(OrionisIntegrityException):
65
- Queue(brokers={})
66
-
67
47
  async def testValidCustomInitialization(self):
68
48
  """
69
49
  Test custom initialization with valid parameters.
@@ -29,19 +29,6 @@ class TestFoundationConfigQueueBrokers(AsyncTestCase):
29
29
  with self.assertRaises(OrionisIntegrityException):
30
30
  Brokers(sync=1)
31
31
 
32
- async def testDatabaseValidation(self):
33
- """
34
- Test validation for the `database` attribute.
35
-
36
- Notes
37
- -----
38
- Verifies that non-`Database` values for `database` raise `OrionisIntegrityException`.
39
- """
40
- with self.assertRaises(OrionisIntegrityException):
41
- Brokers(database="invalid_database")
42
- with self.assertRaises(OrionisIntegrityException):
43
- Brokers(database={})
44
-
45
32
  async def testCustomInitialization(self):
46
33
  """
47
34
  Test custom initialization with valid parameters.
@@ -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="")