orionis 0.436.0__py3-none-any.whl → 0.438.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 (68) hide show
  1. orionis/console/contracts/kernel.py +16 -3
  2. orionis/console/dumper/contracts/dump.py +8 -9
  3. orionis/console/dynamic/progress_bar.py +21 -29
  4. orionis/console/output/console.py +12 -0
  5. orionis/container/context/manager.py +27 -17
  6. orionis/container/context/scope.py +8 -7
  7. orionis/container/contracts/service_provider.py +12 -8
  8. orionis/container/providers/service_provider.py +9 -16
  9. orionis/container/resolver/resolver.py +29 -22
  10. orionis/foundation/contracts/application.py +437 -47
  11. orionis/foundation/contracts/config.py +14 -6
  12. orionis/foundation/providers/console_provider.py +16 -15
  13. orionis/foundation/providers/dumper_provider.py +20 -8
  14. orionis/foundation/providers/logger_provider.py +19 -14
  15. orionis/foundation/providers/path_resolver_provider.py +17 -14
  16. orionis/foundation/providers/progress_bar_provider.py +15 -14
  17. orionis/foundation/providers/testing_provider.py +20 -14
  18. orionis/foundation/providers/workers_provider.py +19 -14
  19. orionis/metadata/framework.py +1 -1
  20. orionis/services/asynchrony/contracts/coroutines.py +1 -0
  21. orionis/services/asynchrony/coroutines.py +2 -0
  22. orionis/services/asynchrony/exceptions/exception.py +2 -0
  23. orionis/services/environment/core/dot_env.py +9 -0
  24. orionis/services/environment/dynamic/caster.py +31 -2
  25. orionis/services/environment/key/key_generator.py +1 -0
  26. orionis/services/environment/validators/key_name.py +1 -0
  27. orionis/services/environment/validators/types.py +5 -1
  28. orionis/services/introspection/abstract/contracts/reflection.py +188 -221
  29. orionis/services/introspection/abstract/reflection.py +311 -178
  30. orionis/services/introspection/callables/contracts/reflection.py +64 -21
  31. orionis/services/introspection/callables/reflection.py +98 -23
  32. orionis/services/introspection/concretes/reflection.py +278 -181
  33. orionis/services/introspection/dependencies/contracts/reflection.py +21 -18
  34. orionis/services/introspection/dependencies/entities/callable_dependencies.py +15 -16
  35. orionis/services/introspection/dependencies/entities/class_dependencies.py +24 -16
  36. orionis/services/introspection/dependencies/entities/known_dependencies.py +19 -13
  37. orionis/services/introspection/dependencies/entities/method_dependencies.py +22 -16
  38. orionis/services/introspection/dependencies/reflection.py +0 -3
  39. orionis/services/introspection/instances/reflection.py +16 -6
  40. orionis/services/log/contracts/log_service.py +4 -0
  41. orionis/services/log/handlers/filename.py +2 -0
  42. orionis/services/paths/contracts/resolver.py +0 -3
  43. orionis/services/paths/resolver.py +0 -3
  44. {orionis-0.436.0.dist-info → orionis-0.438.0.dist-info}/METADATA +1 -1
  45. {orionis-0.436.0.dist-info → orionis-0.438.0.dist-info}/RECORD +68 -67
  46. tests/container/core/__init__.py +0 -0
  47. tests/container/mocks/mock_complex_classes.py +502 -192
  48. tests/container/mocks/mock_simple_classes.py +72 -6
  49. tests/container/validators/test_is_valid_alias.py +1 -1
  50. tests/foundation/config/database/test_foundation_config_database.py +54 -28
  51. tests/foundation/config/filesystems/test_foundation_config_filesystems_aws.py +40 -22
  52. tests/foundation/config/filesystems/test_foundation_config_filesystems_public.py +75 -48
  53. tests/foundation/config/logging/test_foundation_config_logging_channels.py +49 -37
  54. tests/foundation/config/logging/test_foundation_config_logging_monthly.py +80 -42
  55. tests/foundation/config/logging/test_foundation_config_logging_stack.py +46 -22
  56. tests/foundation/config/root/test_foundation_config_root_paths.py +37 -44
  57. tests/foundation/config/session/test_foundation_config_session.py +65 -20
  58. tests/foundation/config/startup/test_foundation_config_startup.py +37 -33
  59. tests/services/introspection/dependencies/test_reflect_dependencies.py +77 -25
  60. tests/services/introspection/reflection/test_reflection_abstract.py +403 -47
  61. /orionis/services/introspection/concretes/contracts/{concrete.py → reflection.py} +0 -0
  62. {orionis-0.436.0.dist-info → orionis-0.438.0.dist-info}/WHEEL +0 -0
  63. {orionis-0.436.0.dist-info → orionis-0.438.0.dist-info}/licenses/LICENCE +0 -0
  64. {orionis-0.436.0.dist-info → orionis-0.438.0.dist-info}/top_level.txt +0 -0
  65. {orionis-0.436.0.dist-info → orionis-0.438.0.dist-info}/zip-safe +0 -0
  66. /tests/container/{test_container.py → core/test_container.py} +0 -0
  67. /tests/container/{test_singleton.py → core/test_singleton.py} +0 -0
  68. /tests/container/{test_thread_safety.py → core/test_thread_safety.py} +0 -0
@@ -7,11 +7,16 @@ class TestFoundationConfigSession(AsyncTestCase):
7
7
 
8
8
  async def testDefaultInitialization(self):
9
9
  """
10
- Test that Session instance is initialized with correct default values.
10
+ Test default initialization of the Session instance.
11
+
12
+ Returns
13
+ -------
14
+ None
11
15
 
12
16
  Notes
13
17
  -----
14
- Verifies default values for all attributes including secret_key generation.
18
+ Checks that all attributes of the Session instance are set to their correct default values,
19
+ including the generation of the secret_key.
15
20
  """
16
21
  session = Session()
17
22
  self.assertIsInstance(session.secret_key, str)
@@ -24,11 +29,15 @@ class TestFoundationConfigSession(AsyncTestCase):
24
29
 
25
30
  async def testSecretKeyValidation(self):
26
31
  """
27
- Test validation for secret_key attribute.
32
+ Test validation of the secret_key attribute.
33
+
34
+ Returns
35
+ -------
36
+ None
28
37
 
29
38
  Notes
30
39
  -----
31
- Verifies that invalid secret keys raise OrionisIntegrityException.
40
+ Ensures that providing an invalid secret_key raises an OrionisIntegrityException.
32
41
  """
33
42
  with self.assertRaises(OrionisIntegrityException):
34
43
  Session(secret_key="") # Empty string
@@ -37,11 +46,15 @@ class TestFoundationConfigSession(AsyncTestCase):
37
46
 
38
47
  async def testSessionCookieValidation(self):
39
48
  """
40
- Test validation for session_cookie attribute.
49
+ Test validation of the session_cookie attribute.
50
+
51
+ Returns
52
+ -------
53
+ None
41
54
 
42
55
  Notes
43
56
  -----
44
- Verifies invalid cookie names raise OrionisIntegrityException.
57
+ Ensures that invalid session_cookie values raise an OrionisIntegrityException.
45
58
  """
46
59
  with self.assertRaises(OrionisIntegrityException):
47
60
  Session(session_cookie="") # Empty string
@@ -52,11 +65,16 @@ class TestFoundationConfigSession(AsyncTestCase):
52
65
 
53
66
  async def testMaxAgeValidation(self):
54
67
  """
55
- Test validation for max_age attribute.
68
+ Test validation of the max_age attribute.
69
+
70
+ Returns
71
+ -------
72
+ None
56
73
 
57
74
  Notes
58
75
  -----
59
- Verifies invalid max_age values raise OrionisIntegrityException.
76
+ Ensures that invalid max_age values raise an OrionisIntegrityException.
77
+ Also verifies that None is accepted as a valid value.
60
78
  """
61
79
  with self.assertRaises(OrionisIntegrityException):
62
80
  Session(max_age="3600") # String instead of int
@@ -68,11 +86,16 @@ class TestFoundationConfigSession(AsyncTestCase):
68
86
 
69
87
  async def testSameSiteValidation(self):
70
88
  """
71
- Test validation and normalization for same_site attribute.
89
+ Test validation and normalization of the same_site attribute.
90
+
91
+ Returns
92
+ -------
93
+ None
72
94
 
73
95
  Notes
74
96
  -----
75
- Verifies both string and enum inputs are properly handled.
97
+ Ensures that both string and enum inputs for same_site are handled correctly.
98
+ Also checks that invalid values raise an OrionisIntegrityException.
76
99
  """
77
100
  # Test string inputs (case-insensitive)
78
101
  session1 = Session(same_site="strict")
@@ -92,11 +115,15 @@ class TestFoundationConfigSession(AsyncTestCase):
92
115
 
93
116
  async def testPathValidation(self):
94
117
  """
95
- Test validation for path attribute.
118
+ Test validation of the path attribute.
119
+
120
+ Returns
121
+ -------
122
+ None
96
123
 
97
124
  Notes
98
125
  -----
99
- Verifies invalid paths raise OrionisIntegrityException.
126
+ Ensures that invalid path values raise an OrionisIntegrityException.
100
127
  """
101
128
  with self.assertRaises(OrionisIntegrityException):
102
129
  Session(path="") # Empty string
@@ -107,11 +134,15 @@ class TestFoundationConfigSession(AsyncTestCase):
107
134
 
108
135
  async def testHttpsOnlyValidation(self):
109
136
  """
110
- Test validation for https_only attribute.
137
+ Test validation of the https_only attribute.
138
+
139
+ Returns
140
+ -------
141
+ None
111
142
 
112
143
  Notes
113
144
  -----
114
- Verifies non-boolean values raise OrionisIntegrityException.
145
+ Ensures that non-boolean values for https_only raise an OrionisIntegrityException.
115
146
  """
116
147
  with self.assertRaises(OrionisIntegrityException):
117
148
  Session(https_only="true") # String instead of bool
@@ -120,11 +151,16 @@ class TestFoundationConfigSession(AsyncTestCase):
120
151
 
121
152
  async def testDomainValidation(self):
122
153
  """
123
- Test validation for domain attribute.
154
+ Test validation of the domain attribute.
155
+
156
+ Returns
157
+ -------
158
+ None
124
159
 
125
160
  Notes
126
161
  -----
127
- Verifies invalid domains raise OrionisIntegrityException.
162
+ Ensures that invalid domain values raise an OrionisIntegrityException.
163
+ Also verifies that None is accepted as a valid value.
128
164
  """
129
165
  with self.assertRaises(OrionisIntegrityException):
130
166
  Session(domain=".example.com") # Starts with dot
@@ -139,11 +175,15 @@ class TestFoundationConfigSession(AsyncTestCase):
139
175
 
140
176
  async def testToDictMethod(self):
141
177
  """
142
- Test the toDict method returns proper dictionary representation.
178
+ Test the toDict method of the Session instance.
179
+
180
+ Returns
181
+ -------
182
+ None
143
183
 
144
184
  Notes
145
185
  -----
146
- Verifies all fields are included with correct values.
186
+ Ensures that the toDict method returns a dictionary containing all fields with correct values.
147
187
  """
148
188
  session = Session()
149
189
  result = session.toDict()
@@ -158,11 +198,16 @@ class TestFoundationConfigSession(AsyncTestCase):
158
198
 
159
199
  async def testKwOnlyInitialization(self):
160
200
  """
161
- Test that Session requires keyword arguments for initialization.
201
+ Test enforcement of keyword-only initialization for Session.
202
+
203
+ Returns
204
+ -------
205
+ None
162
206
 
163
207
  Notes
164
208
  -----
165
- Verifies the class enforces kw_only=True in its dataclass decorator.
209
+ Ensures that the Session class enforces keyword-only arguments during initialization
210
+ by raising a TypeError when positional arguments are provided.
166
211
  """
167
212
  with self.assertRaises(TypeError):
168
213
  Session("key", "session")
@@ -18,33 +18,35 @@ from unittest.mock import Mock
18
18
 
19
19
  class TestFoundationConfigStartup(AsyncTestCase):
20
20
  """
21
- Test suite for the Configuration dataclass.
21
+ Test suite for the `Configuration` dataclass, validating its structure, initialization,
22
+ type enforcement, mutability, equality, and dictionary conversion.
22
23
 
23
24
  Methods
24
25
  -------
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.
26
+ testConfigurationIsDataclass
27
+ Verify that `Configuration` is a dataclass.
28
+ testDefaultInitialization
29
+ Ensure all fields of `Configuration` are initialized with their default factories and correct types.
30
+ testAllSectionsHaveDefaultFactories
31
+ Check that every field in `Configuration` has a callable default factory.
32
+ testTypeValidationInPostInit
33
+ Confirm that type validation and dictionary conversion occur in `__post_init__`,
34
+ and that invalid types raise `OrionisIntegrityException`.
35
+ testToDictReturnsCompleteDictionary
36
+ Assert that `toDict()` returns a dictionary containing all configuration sections.
37
+ testToDictReturnsNestedStructures
38
+ Ensure that nested configuration sections are represented as dictionaries in `toDict()` output.
39
+ testMetadataIsAccessible
40
+ Validate that field metadata is accessible and contains required keys and types.
41
+ testConfigurationIsMutable
42
+ Check that attributes of `Configuration` can be modified after initialization.
43
+ testConfigurationEquality
44
+ Test equality comparison between `Configuration` instances, especially with differing keys.
43
45
  """
44
46
 
45
47
  def testConfigurationIsDataclass(self):
46
48
  """
47
- Test that Configuration is a dataclass.
49
+ Verify that `Configuration` is implemented as a dataclass.
48
50
 
49
51
  Returns
50
52
  -------
@@ -54,9 +56,8 @@ class TestFoundationConfigStartup(AsyncTestCase):
54
56
 
55
57
  def testDefaultInitialization(self):
56
58
  """
57
- Test default initialization of Configuration.
58
-
59
- Ensures all fields are initialized with their default factories.
59
+ Ensure all fields of `Configuration` are initialized with their default factories
60
+ and are instances of their respective entity classes.
60
61
 
61
62
  Returns
62
63
  -------
@@ -79,7 +80,7 @@ class TestFoundationConfigStartup(AsyncTestCase):
79
80
 
80
81
  def testAllSectionsHaveDefaultFactories(self):
81
82
  """
82
- Test that all fields have default factories.
83
+ Check that every field in `Configuration` has a callable default factory.
83
84
 
84
85
  Returns
85
86
  -------
@@ -92,9 +93,9 @@ class TestFoundationConfigStartup(AsyncTestCase):
92
93
 
93
94
  def testTypeValidationInPostInit(self):
94
95
  """
95
- Test type validation and dict conversion in __post_init__.
96
-
97
- Ensures that dicts are converted to entities and wrong types raise OrionisIntegrityException.
96
+ Confirm that type validation and dictionary conversion occur in `__post_init__`.
97
+ Validates that dictionaries are converted to entity instances and invalid types
98
+ raise `OrionisIntegrityException`.
98
99
 
99
100
  Returns
100
101
  -------
@@ -104,7 +105,7 @@ class TestFoundationConfigStartup(AsyncTestCase):
104
105
  config = Configuration(app={"name": "TestApp"})
105
106
  self.assertIsInstance(config.app, App)
106
107
 
107
- # Invalid types
108
+ # Invalid types for each section should raise an exception
108
109
  sections = [
109
110
  ('app', 123),
110
111
  ('auth', 123),
@@ -127,7 +128,7 @@ class TestFoundationConfigStartup(AsyncTestCase):
127
128
 
128
129
  def testToDictReturnsCompleteDictionary(self):
129
130
  """
130
- Test that toDict() returns all configuration sections.
131
+ Assert that `toDict()` returns a dictionary containing all configuration sections.
131
132
 
132
133
  Returns
133
134
  -------
@@ -140,7 +141,8 @@ class TestFoundationConfigStartup(AsyncTestCase):
140
141
 
141
142
  def testToDictReturnsNestedStructures(self):
142
143
  """
143
- Test that toDict() returns nested structures as dicts.
144
+ Ensure that nested configuration sections are represented as dictionaries
145
+ in the output of `toDict()`.
144
146
 
145
147
  Returns
146
148
  -------
@@ -155,7 +157,8 @@ class TestFoundationConfigStartup(AsyncTestCase):
155
157
 
156
158
  def testMetadataIsAccessible(self):
157
159
  """
158
- Test that field metadata is accessible and correct.
160
+ Validate that field metadata is accessible and contains the 'description' key
161
+ as a string and the 'default' key.
159
162
 
160
163
  Returns
161
164
  -------
@@ -170,7 +173,7 @@ class TestFoundationConfigStartup(AsyncTestCase):
170
173
 
171
174
  def testConfigurationIsMutable(self):
172
175
  """
173
- Test that Configuration is mutable.
176
+ Check that attributes of `Configuration` can be modified after initialization.
174
177
 
175
178
  Returns
176
179
  -------
@@ -185,7 +188,8 @@ class TestFoundationConfigStartup(AsyncTestCase):
185
188
 
186
189
  def testConfigurationEquality(self):
187
190
  """
188
- Test equality of Configuration instances.
191
+ Test equality comparison between `Configuration` instances, ensuring that
192
+ instances with differing keys are not considered equal.
189
193
 
190
194
  Returns
191
195
  -------
@@ -13,21 +13,52 @@ from tests.services.introspection.dependencies.mocks.mock_users_permissions impo
13
13
 
14
14
  class TestReflectDependencies(AsyncTestCase):
15
15
  """
16
- Test suite for verifying the functionality of the ReflectDependencies class in resolving and reflecting dependencies for class constructors and methods.
17
- This test class covers:
18
- - Retrieval and resolution of constructor dependencies for the UserController class.
19
- - Validation that constructor dependencies are correctly identified as instances of ClassDependency.
20
- - Verification that resolved dependencies (such as 'user_repository') are instances of KnownDependency and have the expected module name, class name, full class path, and type.
21
- - Reflection and resolution of method dependencies for specific methods (e.g., 'createUserWithPermissions').
22
- - Validation that method dependencies are correctly identified as instances of MethodDependency.
23
- - Verification that resolved method dependencies (such as 'user_permissions' and 'permissions') are instances of KnownDependency and have the expected attributes.
24
- - Ensuring that unresolved dependencies lists are empty where appropriate.
16
+ Test suite for the ReflectDependencies class, which provides utilities for introspecting and resolving dependencies
17
+ in class constructors, methods, and callables.
18
+
19
+ This class contains asynchronous test cases that validate:
20
+ - The correct retrieval and resolution of constructor dependencies for the UserController class.
21
+ - The identification of constructor dependencies as instances of ClassDependency.
22
+ - The resolution of dependencies such as 'user_repository' as KnownDependency instances, including validation
23
+ of their module name, class name, full class path, and type.
24
+ - The reflection and resolution of method dependencies for specific methods (e.g., 'createUserWithPermissions'),
25
+ ensuring they are identified as MethodDependency instances.
26
+ - The resolution of method dependencies such as 'user_permissions' and 'permissions' as KnownDependency instances,
27
+ with correct attributes.
28
+ - That unresolved dependency lists are empty when all dependencies are resolved.
29
+
30
+ Attributes
31
+ ----------
32
+ Inherits from AsyncTestCase.
33
+
34
+ Methods
35
+ -------
36
+ testReflectionDependenciesGetConstructorDependencies()
37
+ Tests retrieval and validation of constructor dependencies for UserController.
38
+
39
+ testReflectionDependenciesGetMethodDependencies()
40
+ Tests retrieval and validation of method dependencies for the 'createUserWithPermissions' method.
41
+
42
+ testReflectionDependenciesGetCallableDependencies()
43
+ Tests retrieval and validation of dependencies for a sample asynchronous callable.
25
44
  """
26
45
 
27
46
  async def testReflectionDependenciesGetConstructorDependencies(self):
28
47
  """
29
- Test that ReflectDependencies correctly retrieves and resolves constructor dependencies for the UserController class.
30
- This test verifies:
48
+ Retrieves and validates the constructor dependencies for the UserController class using the ReflectDependencies utility.
49
+
50
+ Parameters
51
+ ----------
52
+ self : TestReflectDependencies
53
+ The test case instance.
54
+
55
+ Returns
56
+ -------
57
+ None
58
+
59
+ Notes
60
+ -----
61
+ This test ensures that:
31
62
  - The returned constructor dependencies are an instance of ClassDependency.
32
63
  - The list of unresolved dependencies is empty.
33
64
  - The 'user_repository' dependency is resolved as an instance of KnownDependency.
@@ -55,15 +86,25 @@ class TestReflectDependencies(AsyncTestCase):
55
86
 
56
87
  async def testReflectionDependenciesGetMethodDependencies(self):
57
88
  """
58
- Tests the `getMethodDependencies` method of the `ReflectDependencies` class for the 'createUserWithPermissions' method
59
- of the `UserController`.
60
- This test verifies:
61
- - The returned object is an instance of `MethodDependency`.
62
- - There are no unresolved dependencies.
63
- - The 'user_permissions' dependency is correctly resolved as an instance of `KnownDependency` with the expected
64
- module name, class name, full class path, and type (`FakeUserWithPermissions`).
65
- - The 'permissions' dependency is correctly resolved as an instance of `KnownDependency` with the expected
66
- module name, class name, full class path, and type (`list[str]`).
89
+ Retrieves and validates the dependencies for the 'createUserWithPermissions' method of the UserController class
90
+ using the ReflectDependencies utility.
91
+
92
+ This test ensures that:
93
+ - The returned object is an instance of MethodDependency.
94
+ - The unresolved dependencies list is empty.
95
+ - The 'user_permissions' dependency is resolved as a KnownDependency with the expected module name,
96
+ class name, full class path, and type (FakeUserWithPermissions).
97
+ - The 'permissions' dependency is resolved as a KnownDependency with the expected module name,
98
+ class name, full class path, and type (list[str]).
99
+
100
+ Parameters
101
+ ----------
102
+ self : TestReflectDependencies
103
+ The test case instance.
104
+
105
+ Returns
106
+ -------
107
+ None
67
108
  """
68
109
 
69
110
  depend = ReflectDependencies(UserController)
@@ -97,12 +138,23 @@ class TestReflectDependencies(AsyncTestCase):
97
138
 
98
139
  async def testReflectionDependenciesGetCallableDependencies(self):
99
140
  """
100
- Tests the `getCallableDependencies` method of the `ReflectDependencies` class for a callable function.
101
- This test verifies:
102
- - The returned dependencies are an instance of `MethodDependency`.
141
+ Tests the `getCallableDependencies` method of the `ReflectDependencies` class for a given asynchronous function.
142
+
143
+ Parameters
144
+ ----------
145
+ self : TestReflectDependencies
146
+ The test case instance.
147
+
148
+ Returns
149
+ -------
150
+ None
151
+
152
+ Notes
153
+ -----
154
+ This test checks that:
155
+ - The returned dependencies are an instance of `CallableDependency`.
103
156
  - There are no unresolved dependencies.
104
- - The 'x' and 'y' parameters are correctly resolved as instances of `KnownDependency` with the expected
105
- module name, class name, full class path, and type (`int`).
157
+ - The 'x' and 'y' parameters are resolved to their default integer values (3 and 4, respectively).
106
158
  """
107
159
 
108
160
  async def fake_function(x: int = 3, y: int = 4) -> int: