orionis 0.545.0__py3-none-any.whl → 0.547.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/console/base/scheduler_event_listener.py +0 -17
- orionis/console/contracts/schedule_event_listener.py +0 -18
- orionis/console/request/cli_request.py +2 -2
- orionis/foundation/config/app/entities/app.py +3 -2
- orionis/foundation/config/app/enums/ciphers.py +5 -19
- orionis/foundation/config/session/entities/session.py +2 -2
- orionis/foundation/providers/cli_request_provider.py +44 -0
- orionis/metadata/framework.py +1 -1
- orionis/services/encrypter/encrypter.py +115 -0
- orionis/services/environment/dynamic/caster.py +35 -27
- orionis/services/environment/key/key_generator.py +32 -11
- {orionis-0.545.0.dist-info → orionis-0.547.0.dist-info}/METADATA +1 -1
- {orionis-0.545.0.dist-info → orionis-0.547.0.dist-info}/RECORD +17 -160
- {orionis-0.545.0.dist-info → orionis-0.547.0.dist-info}/top_level.txt +0 -1
- tests/container/__init__.py +0 -0
- tests/container/context/__init__.py +0 -0
- tests/container/context/test_manager.py +0 -38
- tests/container/context/test_scope.py +0 -32
- tests/container/core/__init__.py +0 -0
- tests/container/core/test_advanced_async.py +0 -234
- tests/container/core/test_async_optimizations.py +0 -268
- tests/container/core/test_container.py +0 -453
- tests/container/core/test_singleton.py +0 -122
- tests/container/core/test_thread_safety.py +0 -90
- tests/container/entities/__init__.py +0 -0
- tests/container/entities/test_binding.py +0 -242
- tests/container/enums/__init__.py +0 -0
- tests/container/enums/test_lifetimes.py +0 -97
- tests/container/facades/__init__.py +0 -0
- tests/container/facades/test_facade.py +0 -78
- tests/container/mocks/__init__.py +0 -0
- tests/container/mocks/mock_advanced_async.py +0 -332
- tests/container/mocks/mock_async_optimizations.py +0 -407
- tests/container/mocks/mock_auto_resolution.py +0 -192
- tests/container/mocks/mock_complex_classes.py +0 -792
- tests/container/mocks/mock_simple_classes.py +0 -98
- tests/container/providers/__init__.py +0 -0
- tests/container/providers/test_providers.py +0 -55
- tests/container/validators/__init__.py +0 -0
- tests/container/validators/test_implements.py +0 -186
- tests/container/validators/test_is_abstract_class.py +0 -147
- tests/container/validators/test_is_callable.py +0 -102
- tests/container/validators/test_is_concrete_class.py +0 -160
- tests/container/validators/test_is_instance.py +0 -150
- tests/container/validators/test_is_not_subclass.py +0 -49
- tests/container/validators/test_is_subclass.py +0 -178
- tests/container/validators/test_is_valid_alias.py +0 -147
- tests/container/validators/test_lifetime.py +0 -106
- tests/example/__init__.py +0 -0
- tests/example/test_example.py +0 -725
- tests/foundation/__init__.py +0 -0
- tests/foundation/config/__init__.py +0 -0
- tests/foundation/config/app/__init__.py +0 -0
- tests/foundation/config/app/test_foundation_config_app.py +0 -262
- tests/foundation/config/auth/__init__.py +0 -0
- tests/foundation/config/auth/test_foundation_config_auth.py +0 -29
- tests/foundation/config/cache/__init__.py +0 -0
- tests/foundation/config/cache/test_foundation_config_cache.py +0 -143
- tests/foundation/config/cache/test_foundation_config_cache_file.py +0 -126
- tests/foundation/config/cache/test_foundation_config_cache_stores.py +0 -156
- tests/foundation/config/cors/__init__.py +0 -0
- tests/foundation/config/cors/test_foundation_config_cors.py +0 -190
- tests/foundation/config/database/__init__.py +0 -0
- tests/foundation/config/database/test_foundation_config_database.py +0 -158
- tests/foundation/config/database/test_foundation_config_database_connections.py +0 -203
- tests/foundation/config/database/test_foundation_config_database_mysql.py +0 -354
- tests/foundation/config/database/test_foundation_config_database_oracle.py +0 -288
- tests/foundation/config/database/test_foundation_config_database_pgsql.py +0 -257
- tests/foundation/config/database/test_foundation_config_database_sqlite.py +0 -207
- tests/foundation/config/filesystems/__init__.py +0 -0
- tests/foundation/config/filesystems/test_foundation_config_filesystems.py +0 -160
- tests/foundation/config/filesystems/test_foundation_config_filesystems_aws.py +0 -189
- tests/foundation/config/filesystems/test_foundation_config_filesystems_disks.py +0 -184
- tests/foundation/config/filesystems/test_foundation_config_filesystems_local.py +0 -143
- tests/foundation/config/filesystems/test_foundation_config_filesystems_public.py +0 -184
- tests/foundation/config/logging/__init__.py +0 -0
- tests/foundation/config/logging/test_foundation_config_logging.py +0 -112
- tests/foundation/config/logging/test_foundation_config_logging_channels.py +0 -246
- tests/foundation/config/logging/test_foundation_config_logging_chunked.py +0 -217
- tests/foundation/config/logging/test_foundation_config_logging_daily.py +0 -220
- tests/foundation/config/logging/test_foundation_config_logging_hourly.py +0 -196
- tests/foundation/config/logging/test_foundation_config_logging_monthly.py +0 -214
- tests/foundation/config/logging/test_foundation_config_logging_stack.py +0 -178
- tests/foundation/config/logging/test_foundation_config_logging_weekly.py +0 -224
- tests/foundation/config/mail/__init__.py +0 -0
- tests/foundation/config/mail/test_foundation_config_mail.py +0 -145
- tests/foundation/config/mail/test_foundation_config_mail_file.py +0 -97
- tests/foundation/config/mail/test_foundation_config_mail_mailers.py +0 -106
- tests/foundation/config/mail/test_foundation_config_mail_smtp.py +0 -146
- tests/foundation/config/queue/__init__.py +0 -0
- tests/foundation/config/queue/test_foundation_config_queue.py +0 -88
- tests/foundation/config/queue/test_foundation_config_queue_brokers.py +0 -72
- tests/foundation/config/queue/test_foundation_config_queue_database.py +0 -134
- tests/foundation/config/root/__init__.py +0 -0
- tests/foundation/config/root/test_foundation_config_root_paths.py +0 -112
- tests/foundation/config/session/__init__.py +0 -0
- tests/foundation/config/session/test_foundation_config_session.py +0 -213
- tests/foundation/config/startup/__init__.py +0 -0
- tests/foundation/config/startup/test_foundation_config_startup.py +0 -202
- tests/foundation/config/testing/__init__.py +0 -0
- tests/foundation/config/testing/test_foundation_config_testing.py +0 -235
- tests/metadata/__init__.py +0 -0
- tests/metadata/test_metadata_framework.py +0 -140
- tests/metadata/test_metadata_package.py +0 -139
- tests/services/__init__.py +0 -0
- tests/services/asynchrony/__init__.py +0 -0
- tests/services/asynchrony/test_services_asynchrony_coroutine.py +0 -85
- tests/services/environment/__init__.py +0 -0
- tests/services/environment/test_services_environment.py +0 -226
- tests/services/introspection/__init__.py +0 -0
- tests/services/introspection/dependencies/__init__.py +0 -0
- tests/services/introspection/dependencies/mocks/__init__.py +0 -0
- tests/services/introspection/dependencies/mocks/mock_user.py +0 -30
- tests/services/introspection/dependencies/mocks/mock_user_controller.py +0 -27
- tests/services/introspection/dependencies/mocks/mock_users_permissions.py +0 -41
- tests/services/introspection/dependencies/test_reflect_dependencies.py +0 -261
- tests/services/introspection/reflection/__init__.py +0 -0
- tests/services/introspection/reflection/mock/__init__.py +0 -0
- tests/services/introspection/reflection/mock/fake_reflect_instance.py +0 -1115
- tests/services/introspection/reflection/test_reflection_abstract.py +0 -1011
- tests/services/introspection/reflection/test_reflection_callable.py +0 -206
- tests/services/introspection/reflection/test_reflection_concrete.py +0 -952
- tests/services/introspection/reflection/test_reflection_instance.py +0 -1233
- tests/services/introspection/reflection/test_reflection_module.py +0 -567
- tests/services/introspection/test_reflection.py +0 -462
- tests/services/log/__init__.py +0 -0
- tests/services/log/test_log.py +0 -97
- tests/services/system/__init__.py +0 -0
- tests/services/system/test_services_system_imports.py +0 -204
- tests/services/system/test_services_system_workers.py +0 -131
- tests/support/__init__.py +0 -0
- tests/support/entities/__init__.py +0 -0
- tests/support/entities/mock_dataclass.py +0 -40
- tests/support/entities/test_base.py +0 -64
- tests/support/patterns/__init__.py +0 -0
- tests/support/patterns/singleton/__init__.py +0 -0
- tests/support/patterns/singleton/test_patterns_singleton.py +0 -39
- tests/support/standard/__init__.py +0 -0
- tests/support/standard/test_services_std.py +0 -226
- tests/support/wrapper/__init__.py +0 -0
- tests/support/wrapper/test_services_wrapper_docdict.py +0 -202
- tests/testing/__init__.py +0 -0
- tests/testing/cases/__init__.py +0 -0
- tests/testing/cases/test_testing_asynchronous.py +0 -63
- tests/testing/cases/test_testing_synchronous.py +0 -57
- tests/testing/entities/__init__.py +0 -0
- tests/testing/entities/test_testing_result.py +0 -146
- tests/testing/enums/__init__.py +0 -0
- tests/testing/enums/test_testing_status.py +0 -63
- tests/testing/output/__init__.py +0 -0
- tests/testing/output/test_testing_dumper.py +0 -29
- tests/testing/output/test_testing_printer.py +0 -42
- tests/testing/records/__init__.py +0 -0
- tests/testing/records/test_testing_records.py +0 -171
- tests/testing/test_testing_unit.py +0 -164
- tests/testing/validators/__init__.py +0 -0
- tests/testing/validators/test_testing_validators.py +0 -392
- tests/testing/view/__init__.py +0 -0
- tests/testing/view/test_render.py +0 -30
- {orionis-0.545.0.dist-info → orionis-0.547.0.dist-info}/WHEEL +0 -0
- {orionis-0.545.0.dist-info → orionis-0.547.0.dist-info}/licenses/LICENCE +0 -0
- {orionis-0.545.0.dist-info → orionis-0.547.0.dist-info}/zip-safe +0 -0
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
class FakeUserWithPermissions:
|
|
2
|
-
"""
|
|
3
|
-
A fake user class for testing permission-based logic.
|
|
4
|
-
This class simulates a user object with a set of permissions, providing methods to add and check permissions.
|
|
5
|
-
permissions (set): A set containing the permissions assigned to the user.
|
|
6
|
-
Methods:
|
|
7
|
-
addPermission(permission: str):
|
|
8
|
-
Adds a permission to the user's set of permissions.
|
|
9
|
-
hasPermission(permission: str) -> bool:
|
|
10
|
-
Checks if the user has a specific permission.
|
|
11
|
-
"""
|
|
12
|
-
|
|
13
|
-
def __init__(self):
|
|
14
|
-
"""
|
|
15
|
-
Initializes the object with an empty set of permissions.
|
|
16
|
-
|
|
17
|
-
Attributes:
|
|
18
|
-
permissions (set): A set to store permission values.
|
|
19
|
-
"""
|
|
20
|
-
self.permissions = set()
|
|
21
|
-
|
|
22
|
-
def addPermission(self, permission: str):
|
|
23
|
-
"""
|
|
24
|
-
Adds a permission to the set of permissions.
|
|
25
|
-
|
|
26
|
-
Args:
|
|
27
|
-
permission (str): The permission to add.
|
|
28
|
-
"""
|
|
29
|
-
self.permissions.add(permission)
|
|
30
|
-
|
|
31
|
-
def hasPermission(self, permission: str) -> bool:
|
|
32
|
-
"""
|
|
33
|
-
Check if the specified permission exists in the user's permissions.
|
|
34
|
-
|
|
35
|
-
Args:
|
|
36
|
-
permission (str): The permission to check for.
|
|
37
|
-
|
|
38
|
-
Returns:
|
|
39
|
-
bool: True if the permission exists, False otherwise.
|
|
40
|
-
"""
|
|
41
|
-
return permission in self.permissions
|
|
@@ -1,261 +0,0 @@
|
|
|
1
|
-
import asyncio
|
|
2
|
-
from orionis.services.introspection.dependencies.entities.argument import Argument
|
|
3
|
-
from orionis.services.introspection.dependencies.entities.resolve_argument import ResolveArguments
|
|
4
|
-
from orionis.services.introspection.dependencies.reflection import ReflectDependencies
|
|
5
|
-
from orionis.test.cases.asynchronous import AsyncTestCase
|
|
6
|
-
from tests.services.introspection.dependencies.mocks.mock_user import FakeUser
|
|
7
|
-
from tests.services.introspection.dependencies.mocks.mock_user_controller import UserController
|
|
8
|
-
from tests.services.introspection.dependencies.mocks.mock_users_permissions import FakeUserWithPermissions
|
|
9
|
-
|
|
10
|
-
class TestReflectDependencies(AsyncTestCase):
|
|
11
|
-
"""
|
|
12
|
-
Test suite for the ReflectDependencies class, which provides utilities for introspecting and resolving dependencies
|
|
13
|
-
in class constructors, methods, and callables.
|
|
14
|
-
|
|
15
|
-
This class contains asynchronous test cases that validate:
|
|
16
|
-
- The correct retrieval and resolution of constructor dependencies for the UserController class.
|
|
17
|
-
- The identification of constructor dependencies as instances of ClassDependency.
|
|
18
|
-
- The resolution of dependencies such as 'user_repository' as KnownDependency instances, including validation
|
|
19
|
-
of their module name, class name, full class path, and type.
|
|
20
|
-
- The reflection and resolution of method dependencies for specific methods (e.g., 'createUserWithPermissions'),
|
|
21
|
-
ensuring they are identified as MethodDependency instances.
|
|
22
|
-
- The resolution of method dependencies such as 'user_permissions' and 'permissions' as KnownDependency instances,
|
|
23
|
-
with correct attributes.
|
|
24
|
-
- That unresolved dependency lists are empty when all dependencies are resolved.
|
|
25
|
-
|
|
26
|
-
Attributes
|
|
27
|
-
----------
|
|
28
|
-
Inherits from AsyncTestCase.
|
|
29
|
-
|
|
30
|
-
Methods
|
|
31
|
-
-------
|
|
32
|
-
testReflectionDependenciesGetConstructorDependencies()
|
|
33
|
-
Tests retrieval and validation of constructor dependencies for UserController.
|
|
34
|
-
|
|
35
|
-
testReflectionDependenciesGetMethodDependencies()
|
|
36
|
-
Tests retrieval and validation of method dependencies for the 'createUserWithPermissions' method.
|
|
37
|
-
|
|
38
|
-
testReflectionDependenciesGetCallableDependencies()
|
|
39
|
-
Tests retrieval and validation of dependencies for a sample asynchronous callable.
|
|
40
|
-
"""
|
|
41
|
-
|
|
42
|
-
async def testReflectionDependenciesGetConstructorDependencies(self):
|
|
43
|
-
"""
|
|
44
|
-
Retrieves and validates the constructor dependencies for the UserController class using the ReflectDependencies utility.
|
|
45
|
-
|
|
46
|
-
This test method verifies the correct functioning of dependency introspection for class constructors.
|
|
47
|
-
It ensures that the ReflectDependencies class can properly analyze and resolve constructor parameters,
|
|
48
|
-
returning them in the expected format with correct type information and metadata.
|
|
49
|
-
|
|
50
|
-
Parameters
|
|
51
|
-
----------
|
|
52
|
-
self : TestReflectDependencies
|
|
53
|
-
The test case instance containing the test context and assertion methods.
|
|
54
|
-
|
|
55
|
-
Returns
|
|
56
|
-
-------
|
|
57
|
-
None
|
|
58
|
-
This test method does not return any value. It performs assertions to validate the dependency
|
|
59
|
-
resolution functionality and will raise AssertionError if any validation fails.
|
|
60
|
-
|
|
61
|
-
Notes
|
|
62
|
-
-----
|
|
63
|
-
This test validates the following aspects of constructor dependency resolution:
|
|
64
|
-
- The returned constructor dependencies are an instance of ResolveArguments.
|
|
65
|
-
- The unresolved dependencies dictionary is properly structured.
|
|
66
|
-
- The 'user_repository' dependency is resolved as an instance of Argument.
|
|
67
|
-
- The resolved dependency for 'user_repository' contains accurate metadata including
|
|
68
|
-
module name, class name, full class path, and type reference (FakeUser).
|
|
69
|
-
"""
|
|
70
|
-
|
|
71
|
-
# Initialize the ReflectDependencies utility with the UserController class
|
|
72
|
-
depend = ReflectDependencies(UserController)
|
|
73
|
-
|
|
74
|
-
# Retrieve constructor dependencies for analysis
|
|
75
|
-
constructor_dependencies = depend.getConstructorDependencies()
|
|
76
|
-
|
|
77
|
-
# Validate that the result is an instance of ResolveArguments
|
|
78
|
-
self.assertIsInstance(constructor_dependencies, ResolveArguments)
|
|
79
|
-
|
|
80
|
-
# Verify that unresolved dependencies are returned as a dictionary structure
|
|
81
|
-
self.assertIsInstance(constructor_dependencies.unresolved, dict)
|
|
82
|
-
|
|
83
|
-
# Extract the 'user_repository' dependency from resolved dependencies
|
|
84
|
-
dep_user_repository = constructor_dependencies.resolved.get('user_repository')
|
|
85
|
-
|
|
86
|
-
# Validate that the dependency is properly resolved as an Argument instance
|
|
87
|
-
self.assertIsInstance(dep_user_repository, Argument)
|
|
88
|
-
|
|
89
|
-
# Perform detailed validation of the resolved dependency metadata
|
|
90
|
-
dependencies: Argument = dep_user_repository
|
|
91
|
-
|
|
92
|
-
# Verify the module name matches the expected mock module
|
|
93
|
-
self.assertEqual(dependencies.module_name, 'tests.services.introspection.dependencies.mocks.mock_user')
|
|
94
|
-
|
|
95
|
-
# Verify the class name matches the expected FakeUser class
|
|
96
|
-
self.assertEqual(dependencies.class_name, 'FakeUser')
|
|
97
|
-
|
|
98
|
-
# Verify the full class path is correctly constructed
|
|
99
|
-
self.assertEqual(dependencies.full_class_path, 'tests.services.introspection.dependencies.mocks.mock_user.FakeUser')
|
|
100
|
-
|
|
101
|
-
# Verify the type reference points to the actual FakeUser class
|
|
102
|
-
self.assertEqual(dependencies.type, FakeUser)
|
|
103
|
-
|
|
104
|
-
async def testReflectionDependenciesGetMethodDependencies(self):
|
|
105
|
-
"""
|
|
106
|
-
Test the retrieval and validation of method dependencies for the UserController class.
|
|
107
|
-
|
|
108
|
-
This test method validates the ReflectDependencies utility's ability to introspect and resolve
|
|
109
|
-
dependencies for a specific method ('createUserWithPermissions') within a target class.
|
|
110
|
-
It ensures that all method parameters are correctly identified, resolved, and contain
|
|
111
|
-
accurate metadata including module information, class names, and type references.
|
|
112
|
-
|
|
113
|
-
The test performs comprehensive validation of:
|
|
114
|
-
- The returned dependency resolution object structure and type
|
|
115
|
-
- The absence of unresolved dependencies when all parameters can be resolved
|
|
116
|
-
- The correct resolution of complex type dependencies (custom classes)
|
|
117
|
-
- The accurate resolution of built-in type dependencies (generic types with parameters)
|
|
118
|
-
- The proper extraction of module paths, class names, and full qualified paths
|
|
119
|
-
- The correct type reference mapping for both custom and built-in types
|
|
120
|
-
|
|
121
|
-
Parameters
|
|
122
|
-
----------
|
|
123
|
-
self : TestReflectDependencies
|
|
124
|
-
The test case instance containing assertion methods and test context.
|
|
125
|
-
|
|
126
|
-
Returns
|
|
127
|
-
-------
|
|
128
|
-
None
|
|
129
|
-
This method performs assertions and does not return any value. Test failure
|
|
130
|
-
will raise AssertionError if any validation fails.
|
|
131
|
-
|
|
132
|
-
Notes
|
|
133
|
-
-----
|
|
134
|
-
This test specifically validates two types of dependencies:
|
|
135
|
-
- Custom class dependencies (FakeUserWithPermissions) with full module path resolution
|
|
136
|
-
- Built-in generic type dependencies (list[str]) with proper type parameter handling
|
|
137
|
-
|
|
138
|
-
The test ensures that the ReflectDependencies utility correctly handles both
|
|
139
|
-
user-defined classes and Python built-in generic types when analyzing method signatures.
|
|
140
|
-
"""
|
|
141
|
-
|
|
142
|
-
# Initialize the ReflectDependencies utility with UserController as the target class
|
|
143
|
-
depend = ReflectDependencies(UserController)
|
|
144
|
-
|
|
145
|
-
# Retrieve method dependencies for the 'createUserWithPermissions' method
|
|
146
|
-
method_dependencies = depend.getMethodDependencies('createUserWithPermissions')
|
|
147
|
-
|
|
148
|
-
# Validate that the result is an instance of ResolveArguments (dependency resolution container)
|
|
149
|
-
self.assertIsInstance(method_dependencies, ResolveArguments)
|
|
150
|
-
|
|
151
|
-
# Verify that unresolved dependencies are returned as a dictionary structure
|
|
152
|
-
self.assertIsInstance(method_dependencies.unresolved, dict)
|
|
153
|
-
|
|
154
|
-
# Extract and validate the 'user_permissions' dependency from resolved dependencies
|
|
155
|
-
dep_user_permissions: Argument = method_dependencies.resolved.get('user_permissions')
|
|
156
|
-
|
|
157
|
-
# Ensure the dependency is properly resolved as an Argument instance
|
|
158
|
-
self.assertIsInstance(dep_user_permissions, Argument)
|
|
159
|
-
|
|
160
|
-
# Validate the module name for the custom FakeUserWithPermissions class
|
|
161
|
-
self.assertEqual(dep_user_permissions.module_name, 'tests.services.introspection.dependencies.mocks.mock_users_permissions')
|
|
162
|
-
|
|
163
|
-
# Validate the class name extraction for the custom class
|
|
164
|
-
self.assertEqual(dep_user_permissions.class_name, 'FakeUserWithPermissions')
|
|
165
|
-
|
|
166
|
-
# Validate the full qualified class path construction
|
|
167
|
-
self.assertEqual(dep_user_permissions.full_class_path, 'tests.services.introspection.dependencies.mocks.mock_users_permissions.FakeUserWithPermissions')
|
|
168
|
-
|
|
169
|
-
# Validate the type reference points to the actual FakeUserWithPermissions class
|
|
170
|
-
self.assertEqual(dep_user_permissions.type, FakeUserWithPermissions)
|
|
171
|
-
|
|
172
|
-
# Extract and validate the 'permissions' dependency (built-in generic type)
|
|
173
|
-
dep_permissions: Argument = method_dependencies.unresolved.get('permissions')
|
|
174
|
-
|
|
175
|
-
# Ensure the built-in type dependency is properly resolved as an Argument instance
|
|
176
|
-
self.assertIsInstance(dep_permissions, Argument)
|
|
177
|
-
|
|
178
|
-
# Validate the module name for built-in types (should be 'builtins')
|
|
179
|
-
self.assertEqual(dep_permissions.module_name, 'builtins')
|
|
180
|
-
|
|
181
|
-
# Validate the base class name for the generic list type
|
|
182
|
-
self.assertEqual(dep_permissions.class_name, 'list')
|
|
183
|
-
|
|
184
|
-
# Validate the full qualified path for built-in types
|
|
185
|
-
self.assertEqual(dep_permissions.full_class_path, 'builtins.list')
|
|
186
|
-
|
|
187
|
-
# Validate the type reference includes generic type parameters (list[str])
|
|
188
|
-
self.assertEqual(dep_permissions.type, list[str])
|
|
189
|
-
|
|
190
|
-
async def testReflectionDependenciesGetCallableDependencies(self):
|
|
191
|
-
"""
|
|
192
|
-
Test the retrieval and validation of callable dependencies for a standalone asynchronous function.
|
|
193
|
-
|
|
194
|
-
This test method validates the ReflectDependencies utility's ability to introspect and resolve
|
|
195
|
-
dependencies for a standalone callable function (not bound to a class). It ensures that function
|
|
196
|
-
parameters with default values are correctly identified and resolved, and that the dependency
|
|
197
|
-
resolution process handles callable introspection appropriately.
|
|
198
|
-
|
|
199
|
-
The test performs comprehensive validation of:
|
|
200
|
-
- The returned dependency resolution object structure and type
|
|
201
|
-
- The absence of unresolved dependencies when all parameters have default values
|
|
202
|
-
- The correct resolution of parameters with default values to their actual default values
|
|
203
|
-
- The proper handling of built-in type annotations (int) for function parameters
|
|
204
|
-
- The validation that resolved dependencies contain the expected default values
|
|
205
|
-
|
|
206
|
-
Parameters
|
|
207
|
-
----------
|
|
208
|
-
self : TestReflectDependencies
|
|
209
|
-
The test case instance containing assertion methods and test context.
|
|
210
|
-
|
|
211
|
-
Returns
|
|
212
|
-
-------
|
|
213
|
-
None
|
|
214
|
-
This method performs assertions and does not return any value. Test failure
|
|
215
|
-
will raise AssertionError if any validation fails.
|
|
216
|
-
|
|
217
|
-
Notes
|
|
218
|
-
-----
|
|
219
|
-
This test specifically validates callable dependency resolution for:
|
|
220
|
-
- Asynchronous functions with type-annotated parameters
|
|
221
|
-
- Parameters with default values (integers in this case)
|
|
222
|
-
- The correct mapping of parameter names to their default values
|
|
223
|
-
|
|
224
|
-
The test ensures that the ReflectDependencies utility correctly handles standalone
|
|
225
|
-
callable functions and resolves their parameters to appropriate default values
|
|
226
|
-
when those defaults are provided in the function signature.
|
|
227
|
-
"""
|
|
228
|
-
|
|
229
|
-
# Define a sample asynchronous function with default parameter values for testing
|
|
230
|
-
async def fake_function(x: int = 3, y: int = 4) -> int:
|
|
231
|
-
"""Asynchronously adds two integers with a short delay."""
|
|
232
|
-
await asyncio.sleep(0.1)
|
|
233
|
-
return x + y
|
|
234
|
-
|
|
235
|
-
# Initialize the ReflectDependencies utility with the callable function as target
|
|
236
|
-
depend = ReflectDependencies(fake_function)
|
|
237
|
-
|
|
238
|
-
# Retrieve callable dependencies for analysis
|
|
239
|
-
callable_dependencies = depend.getCallableDependencies()
|
|
240
|
-
|
|
241
|
-
# Validate that the result is an instance of ResolveArguments (dependency resolution container)
|
|
242
|
-
self.assertIsInstance(callable_dependencies, ResolveArguments)
|
|
243
|
-
|
|
244
|
-
# Verify that unresolved dependencies are returned as a dictionary structure
|
|
245
|
-
self.assertIsInstance(callable_dependencies.unresolved, dict)
|
|
246
|
-
|
|
247
|
-
# Extract and validate the 'x' parameter dependency from resolved dependencies
|
|
248
|
-
dep_x: Argument = callable_dependencies.resolved.get('x')
|
|
249
|
-
|
|
250
|
-
# Verify that the 'x' parameter resolves to its default value of 3
|
|
251
|
-
self.assertIsInstance(dep_x, Argument)
|
|
252
|
-
self.assertTrue(dep_x.resolved)
|
|
253
|
-
self.assertEqual(dep_x.default, 3)
|
|
254
|
-
|
|
255
|
-
# Extract and validate the 'y' parameter dependency from resolved dependencies
|
|
256
|
-
dep_y: Argument = callable_dependencies.resolved.get('y')
|
|
257
|
-
|
|
258
|
-
# Verify that the 'y' parameter resolves to its default value of 4
|
|
259
|
-
self.assertIsInstance(dep_y, Argument)
|
|
260
|
-
self.assertTrue(dep_y.resolved)
|
|
261
|
-
self.assertEqual(dep_y.default, 4)
|
|
File without changes
|
|
File without changes
|