orionis 0.546.0__py3-none-any.whl → 0.548.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 (160) hide show
  1. orionis/console/base/scheduler_event_listener.py +0 -17
  2. orionis/console/contracts/schedule_event_listener.py +0 -18
  3. orionis/foundation/config/app/entities/app.py +3 -2
  4. orionis/foundation/config/app/enums/ciphers.py +5 -19
  5. orionis/foundation/config/session/entities/session.py +2 -2
  6. orionis/metadata/framework.py +1 -1
  7. orionis/services/encrypter/encrypter.py +115 -0
  8. orionis/services/environment/dynamic/caster.py +35 -27
  9. orionis/services/environment/key/key_generator.py +32 -11
  10. {orionis-0.546.0.dist-info → orionis-0.548.0.dist-info}/METADATA +1 -1
  11. {orionis-0.546.0.dist-info → orionis-0.548.0.dist-info}/RECORD +14 -159
  12. {orionis-0.546.0.dist-info → orionis-0.548.0.dist-info}/top_level.txt +0 -1
  13. orionis-0.546.0.dist-info/zip-safe +0 -1
  14. tests/container/__init__.py +0 -0
  15. tests/container/context/__init__.py +0 -0
  16. tests/container/context/test_manager.py +0 -38
  17. tests/container/context/test_scope.py +0 -32
  18. tests/container/core/__init__.py +0 -0
  19. tests/container/core/test_advanced_async.py +0 -234
  20. tests/container/core/test_async_optimizations.py +0 -268
  21. tests/container/core/test_container.py +0 -453
  22. tests/container/core/test_singleton.py +0 -122
  23. tests/container/core/test_thread_safety.py +0 -90
  24. tests/container/entities/__init__.py +0 -0
  25. tests/container/entities/test_binding.py +0 -242
  26. tests/container/enums/__init__.py +0 -0
  27. tests/container/enums/test_lifetimes.py +0 -97
  28. tests/container/facades/__init__.py +0 -0
  29. tests/container/facades/test_facade.py +0 -78
  30. tests/container/mocks/__init__.py +0 -0
  31. tests/container/mocks/mock_advanced_async.py +0 -332
  32. tests/container/mocks/mock_async_optimizations.py +0 -407
  33. tests/container/mocks/mock_auto_resolution.py +0 -192
  34. tests/container/mocks/mock_complex_classes.py +0 -792
  35. tests/container/mocks/mock_simple_classes.py +0 -98
  36. tests/container/providers/__init__.py +0 -0
  37. tests/container/providers/test_providers.py +0 -55
  38. tests/container/validators/__init__.py +0 -0
  39. tests/container/validators/test_implements.py +0 -186
  40. tests/container/validators/test_is_abstract_class.py +0 -147
  41. tests/container/validators/test_is_callable.py +0 -102
  42. tests/container/validators/test_is_concrete_class.py +0 -160
  43. tests/container/validators/test_is_instance.py +0 -150
  44. tests/container/validators/test_is_not_subclass.py +0 -49
  45. tests/container/validators/test_is_subclass.py +0 -178
  46. tests/container/validators/test_is_valid_alias.py +0 -147
  47. tests/container/validators/test_lifetime.py +0 -106
  48. tests/example/__init__.py +0 -0
  49. tests/example/test_example.py +0 -725
  50. tests/foundation/__init__.py +0 -0
  51. tests/foundation/config/__init__.py +0 -0
  52. tests/foundation/config/app/__init__.py +0 -0
  53. tests/foundation/config/app/test_foundation_config_app.py +0 -262
  54. tests/foundation/config/auth/__init__.py +0 -0
  55. tests/foundation/config/auth/test_foundation_config_auth.py +0 -29
  56. tests/foundation/config/cache/__init__.py +0 -0
  57. tests/foundation/config/cache/test_foundation_config_cache.py +0 -143
  58. tests/foundation/config/cache/test_foundation_config_cache_file.py +0 -126
  59. tests/foundation/config/cache/test_foundation_config_cache_stores.py +0 -156
  60. tests/foundation/config/cors/__init__.py +0 -0
  61. tests/foundation/config/cors/test_foundation_config_cors.py +0 -190
  62. tests/foundation/config/database/__init__.py +0 -0
  63. tests/foundation/config/database/test_foundation_config_database.py +0 -158
  64. tests/foundation/config/database/test_foundation_config_database_connections.py +0 -203
  65. tests/foundation/config/database/test_foundation_config_database_mysql.py +0 -354
  66. tests/foundation/config/database/test_foundation_config_database_oracle.py +0 -288
  67. tests/foundation/config/database/test_foundation_config_database_pgsql.py +0 -257
  68. tests/foundation/config/database/test_foundation_config_database_sqlite.py +0 -207
  69. tests/foundation/config/filesystems/__init__.py +0 -0
  70. tests/foundation/config/filesystems/test_foundation_config_filesystems.py +0 -160
  71. tests/foundation/config/filesystems/test_foundation_config_filesystems_aws.py +0 -189
  72. tests/foundation/config/filesystems/test_foundation_config_filesystems_disks.py +0 -184
  73. tests/foundation/config/filesystems/test_foundation_config_filesystems_local.py +0 -143
  74. tests/foundation/config/filesystems/test_foundation_config_filesystems_public.py +0 -184
  75. tests/foundation/config/logging/__init__.py +0 -0
  76. tests/foundation/config/logging/test_foundation_config_logging.py +0 -112
  77. tests/foundation/config/logging/test_foundation_config_logging_channels.py +0 -246
  78. tests/foundation/config/logging/test_foundation_config_logging_chunked.py +0 -217
  79. tests/foundation/config/logging/test_foundation_config_logging_daily.py +0 -220
  80. tests/foundation/config/logging/test_foundation_config_logging_hourly.py +0 -196
  81. tests/foundation/config/logging/test_foundation_config_logging_monthly.py +0 -214
  82. tests/foundation/config/logging/test_foundation_config_logging_stack.py +0 -178
  83. tests/foundation/config/logging/test_foundation_config_logging_weekly.py +0 -224
  84. tests/foundation/config/mail/__init__.py +0 -0
  85. tests/foundation/config/mail/test_foundation_config_mail.py +0 -145
  86. tests/foundation/config/mail/test_foundation_config_mail_file.py +0 -97
  87. tests/foundation/config/mail/test_foundation_config_mail_mailers.py +0 -106
  88. tests/foundation/config/mail/test_foundation_config_mail_smtp.py +0 -146
  89. tests/foundation/config/queue/__init__.py +0 -0
  90. tests/foundation/config/queue/test_foundation_config_queue.py +0 -88
  91. tests/foundation/config/queue/test_foundation_config_queue_brokers.py +0 -72
  92. tests/foundation/config/queue/test_foundation_config_queue_database.py +0 -134
  93. tests/foundation/config/root/__init__.py +0 -0
  94. tests/foundation/config/root/test_foundation_config_root_paths.py +0 -112
  95. tests/foundation/config/session/__init__.py +0 -0
  96. tests/foundation/config/session/test_foundation_config_session.py +0 -213
  97. tests/foundation/config/startup/__init__.py +0 -0
  98. tests/foundation/config/startup/test_foundation_config_startup.py +0 -202
  99. tests/foundation/config/testing/__init__.py +0 -0
  100. tests/foundation/config/testing/test_foundation_config_testing.py +0 -235
  101. tests/metadata/__init__.py +0 -0
  102. tests/metadata/test_metadata_framework.py +0 -140
  103. tests/metadata/test_metadata_package.py +0 -139
  104. tests/services/__init__.py +0 -0
  105. tests/services/asynchrony/__init__.py +0 -0
  106. tests/services/asynchrony/test_services_asynchrony_coroutine.py +0 -85
  107. tests/services/environment/__init__.py +0 -0
  108. tests/services/environment/test_services_environment.py +0 -226
  109. tests/services/introspection/__init__.py +0 -0
  110. tests/services/introspection/dependencies/__init__.py +0 -0
  111. tests/services/introspection/dependencies/mocks/__init__.py +0 -0
  112. tests/services/introspection/dependencies/mocks/mock_user.py +0 -30
  113. tests/services/introspection/dependencies/mocks/mock_user_controller.py +0 -27
  114. tests/services/introspection/dependencies/mocks/mock_users_permissions.py +0 -41
  115. tests/services/introspection/dependencies/test_reflect_dependencies.py +0 -261
  116. tests/services/introspection/reflection/__init__.py +0 -0
  117. tests/services/introspection/reflection/mock/__init__.py +0 -0
  118. tests/services/introspection/reflection/mock/fake_reflect_instance.py +0 -1115
  119. tests/services/introspection/reflection/test_reflection_abstract.py +0 -1011
  120. tests/services/introspection/reflection/test_reflection_callable.py +0 -206
  121. tests/services/introspection/reflection/test_reflection_concrete.py +0 -952
  122. tests/services/introspection/reflection/test_reflection_instance.py +0 -1233
  123. tests/services/introspection/reflection/test_reflection_module.py +0 -567
  124. tests/services/introspection/test_reflection.py +0 -462
  125. tests/services/log/__init__.py +0 -0
  126. tests/services/log/test_log.py +0 -97
  127. tests/services/system/__init__.py +0 -0
  128. tests/services/system/test_services_system_imports.py +0 -204
  129. tests/services/system/test_services_system_workers.py +0 -131
  130. tests/support/__init__.py +0 -0
  131. tests/support/entities/__init__.py +0 -0
  132. tests/support/entities/mock_dataclass.py +0 -40
  133. tests/support/entities/test_base.py +0 -64
  134. tests/support/patterns/__init__.py +0 -0
  135. tests/support/patterns/singleton/__init__.py +0 -0
  136. tests/support/patterns/singleton/test_patterns_singleton.py +0 -39
  137. tests/support/standard/__init__.py +0 -0
  138. tests/support/standard/test_services_std.py +0 -226
  139. tests/support/wrapper/__init__.py +0 -0
  140. tests/support/wrapper/test_services_wrapper_docdict.py +0 -202
  141. tests/testing/__init__.py +0 -0
  142. tests/testing/cases/__init__.py +0 -0
  143. tests/testing/cases/test_testing_asynchronous.py +0 -63
  144. tests/testing/cases/test_testing_synchronous.py +0 -57
  145. tests/testing/entities/__init__.py +0 -0
  146. tests/testing/entities/test_testing_result.py +0 -146
  147. tests/testing/enums/__init__.py +0 -0
  148. tests/testing/enums/test_testing_status.py +0 -63
  149. tests/testing/output/__init__.py +0 -0
  150. tests/testing/output/test_testing_dumper.py +0 -29
  151. tests/testing/output/test_testing_printer.py +0 -42
  152. tests/testing/records/__init__.py +0 -0
  153. tests/testing/records/test_testing_records.py +0 -171
  154. tests/testing/test_testing_unit.py +0 -164
  155. tests/testing/validators/__init__.py +0 -0
  156. tests/testing/validators/test_testing_validators.py +0 -392
  157. tests/testing/view/__init__.py +0 -0
  158. tests/testing/view/test_render.py +0 -30
  159. {orionis-0.546.0.dist-info → orionis-0.548.0.dist-info}/WHEEL +0 -0
  160. {orionis-0.546.0.dist-info → orionis-0.548.0.dist-info}/licenses/LICENCE +0 -0
@@ -1,407 +0,0 @@
1
- from abc import ABC, abstractmethod
2
- import asyncio
3
-
4
- class ITestService(ABC):
5
- """
6
- Interface for a test service that provides a method to retrieve a message.
7
-
8
- Methods
9
- -------
10
- get_message() : str
11
- Retrieve a message as a string.
12
-
13
- Returns
14
- -------
15
- str
16
- The message provided by the service.
17
- """
18
-
19
- @abstractmethod
20
- def get_message(self) -> str:
21
- """
22
- Retrieve a message as a string.
23
-
24
- Returns
25
- -------
26
- str
27
- The message provided by the service.
28
- """
29
- pass
30
-
31
- class TestService(ITestService):
32
- """
33
- Concrete implementation of ITestService for synchronous operations.
34
-
35
- Methods
36
- -------
37
- get_message() : str
38
- Returns a greeting message from the synchronous test service.
39
-
40
- Returns
41
- -------
42
- str
43
- A greeting message from the synchronous service.
44
- """
45
-
46
- def get_message(self) -> str:
47
- """
48
- Returns a greeting message from the synchronous service.
49
-
50
- Returns
51
- -------
52
- str
53
- A greeting message from the synchronous service.
54
- """
55
- return "Hello from sync service"
56
-
57
- class ITestServiceWithDependency(ABC):
58
- """
59
- Interface for a test service that depends on other components.
60
-
61
- Methods
62
- -------
63
- get_combined_message() : str
64
- Returns a combined message from the service and its dependencies.
65
-
66
- Returns
67
- -------
68
- str
69
- The combined message generated by the service and its dependencies.
70
- """
71
-
72
- @abstractmethod
73
- def get_combined_message(self) -> str:
74
- """
75
- Returns a combined message as a string.
76
-
77
- Returns
78
- -------
79
- str
80
- The combined message generated by the service and its dependencies.
81
- """
82
- pass
83
-
84
- class TestServiceWithDependency(ITestServiceWithDependency):
85
- """
86
- Test service class that depends on another service implementing ITestService.
87
-
88
- This class demonstrates dependency injection by accepting an instance of ITestService
89
- in its constructor and providing a method to return a combined message.
90
-
91
- Parameters
92
- ----------
93
- service : ITestService
94
- An instance of a service implementing the ITestService interface.
95
-
96
- Methods
97
- -------
98
- get_combined_message() : str
99
- Returns a string that combines a prefix with the message from the injected service.
100
-
101
- Returns
102
- -------
103
- str
104
- The combined message string.
105
- """
106
-
107
- def __init__(self, service: ITestService):
108
- """
109
- Initialize the class with the provided service.
110
-
111
- Parameters
112
- ----------
113
- service : ITestService
114
- An instance of ITestService to be used by this class.
115
- """
116
- self.service = service
117
-
118
- def get_combined_message(self) -> str:
119
- """
120
- Returns a combined message string by prefixing the message from the service with 'Combined:'.
121
-
122
- Returns
123
- -------
124
- str
125
- The combined message string, prefixed with 'Combined:'.
126
- """
127
- return f"Combined: {self.service.get_message()}"
128
-
129
- class IAsyncTestService(ABC):
130
- """
131
- Abstract base class that defines the interface for an asynchronous test service.
132
-
133
- Methods
134
- -------
135
- get_async_message() : str
136
- Asynchronously retrieves a message as a string.
137
-
138
- Returns
139
- -------
140
- str
141
- The message provided by the asynchronous service.
142
- """
143
-
144
- @abstractmethod
145
- async def get_async_message(self) -> str:
146
- """
147
- Asynchronously retrieve a message as a string.
148
-
149
- Returns
150
- -------
151
- str
152
- The message provided by the asynchronous service.
153
- """
154
- pass
155
-
156
- class AsyncTestService(IAsyncTestService):
157
- """
158
- Provides asynchronous test operations for demonstration purposes.
159
-
160
- Methods
161
- -------
162
- get_async_message() : str
163
- Asynchronously returns a test message after a short delay.
164
-
165
- Returns
166
- -------
167
- str
168
- A greeting message from the async service.
169
- """
170
-
171
- async def get_async_message(self) -> str:
172
- """
173
- Asynchronously retrieves a message after a short delay.
174
-
175
- Returns
176
- -------
177
- str
178
- A greeting message from the async service.
179
- """
180
- # Simulate asynchronous operation with a short delay
181
- await asyncio.sleep(0.1)
182
- return "Hello from async service"
183
-
184
- class IAsyncTestServiceWithDependency(ABC):
185
- """
186
- An abstract base class representing an asynchronous test service with dependencies.
187
- This interface defines a contract for services that provide a combined asynchronous message,
188
- potentially aggregating results from dependent services.
189
- Methods
190
- -------
191
- get_combined_async_message() -> str
192
- Asynchronously retrieves a combined message from the service and its dependencies.
193
- """
194
-
195
- @abstractmethod
196
- async def get_combined_async_message(self) -> str:
197
- """
198
- Asynchronously retrieves and returns a combined message as a string.
199
-
200
- Returns:
201
- str: The combined asynchronous message.
202
- """
203
- pass
204
-
205
- class AsyncTestServiceWithDependency(IAsyncTestServiceWithDependency):
206
- """
207
- AsyncTestServiceWithDependency is a service class that depends on another asynchronous test service.
208
-
209
- Parameters
210
- ----------
211
- service : IAsyncTestService
212
- An instance of a service implementing asynchronous message retrieval.
213
-
214
- Methods
215
- -------
216
- get_combined_async_message() -> str
217
- Asynchronously retrieves a message from the dependent service and returns it combined with a prefix.
218
- """
219
-
220
- def __init__(self, service: IAsyncTestService):
221
- """
222
- Initialize the AsyncTestServiceWithDependency with the provided asynchronous test service.
223
-
224
- Parameters
225
- ----------
226
- service : IAsyncTestService
227
- An instance of the asynchronous test service to be used by this class.
228
- """
229
-
230
- # Store the dependency for later use
231
- self.service = service
232
-
233
- async def get_combined_async_message(self) -> str:
234
- """
235
- Asynchronously retrieve a message from the dependent service and return it combined with a prefix.
236
-
237
- This method awaits the asynchronous message retrieval from the injected service and then
238
- formats the result by prefixing it with 'Combined: '.
239
-
240
- Returns
241
- -------
242
- str
243
- The combined message in the format "Combined: <message>", where <message> is the result
244
- from the dependent asynchronous service.
245
- """
246
-
247
- # Await the asynchronous message from the dependency
248
- msg = await self.service.get_async_message()
249
-
250
- # Combine the prefix with the retrieved message
251
- return f"Combined: {msg}"
252
-
253
- class MixedService:
254
- """
255
- Service that combines both synchronous and asynchronous test services.
256
-
257
- This class demonstrates how to work with both sync and async dependencies,
258
- providing methods to retrieve messages from each and a combined result.
259
-
260
- Parameters
261
- ----------
262
- sync_service : ITestService
263
- An instance of a synchronous test service.
264
- async_service : IAsyncTestService
265
- An instance of an asynchronous test service.
266
- """
267
-
268
- def __init__(self, sync_service: ITestService, async_service: IAsyncTestService):
269
- """
270
- Initialize MixedService with synchronous and asynchronous service dependencies.
271
-
272
- Parameters
273
- ----------
274
- sync_service : ITestService
275
- The synchronous service dependency.
276
- async_service : IAsyncTestService
277
- The asynchronous service dependency.
278
- """
279
- self.sync_service = sync_service
280
- self.async_service = async_service
281
-
282
- def get_sync_message(self) -> str:
283
- """
284
- Retrieve a message from the synchronous service and prefix it.
285
-
286
- Returns
287
- -------
288
- str
289
- The message from the synchronous service, prefixed with 'Mixed sync:'.
290
- """
291
-
292
- # Get message from the synchronous service and add a prefix
293
- return f"Mixed sync: {self.sync_service.get_message()}"
294
-
295
- async def get_async_message(self) -> str:
296
- """
297
- Asynchronously retrieve a message from the asynchronous service and prefix it.
298
-
299
- Returns
300
- -------
301
- str
302
- The message from the asynchronous service, prefixed with 'Mixed async:'.
303
- """
304
-
305
- # Await the message from the asynchronous service and add a prefix
306
- async_msg = await self.async_service.get_async_message()
307
- return f"Mixed async: {async_msg}"
308
-
309
- async def get_both_messages(self) -> str:
310
- """
311
- Retrieve messages from both the synchronous and asynchronous services and combine them.
312
-
313
- This method fetches the synchronous message and awaits the asynchronous message,
314
- then returns a formatted string containing both.
315
-
316
- Returns
317
- -------
318
- str
319
- A combined string in the format "Both: sync='<sync_msg>', async='<async_msg>'".
320
- """
321
-
322
- # Get the synchronous message
323
- sync_msg = self.sync_service.get_message()
324
-
325
- # Await the asynchronous message
326
- async_msg = await self.async_service.get_async_message()
327
-
328
- # Combine both messages in a formatted string
329
- return f"Both: sync='{sync_msg}', async='{async_msg}'"
330
-
331
- def sync_callable() -> str:
332
- """
333
- Returns a fixed string result from a synchronous callable.
334
-
335
- This function demonstrates a simple synchronous callable that does not take any arguments
336
- and returns a static string value.
337
-
338
- Returns
339
- -------
340
- str
341
- The result string from the synchronous callable, specifically "Sync callable result".
342
- """
343
- # Return a static string result
344
- return "Sync callable result"
345
-
346
- async def async_callable() -> str:
347
- """
348
- Asynchronously performs a simulated I/O-bound operation and returns a result string.
349
-
350
- This coroutine simulates an asynchronous operation by awaiting a short delay,
351
- then returns a static string value.
352
-
353
- Returns
354
- -------
355
- str
356
- The result of the asynchronous operation after a short delay, specifically "Async callable result".
357
- """
358
- # Simulate an asynchronous I/O operation with a short delay
359
- await asyncio.sleep(0.1)
360
- # Return a static string result
361
- return "Async callable result"
362
-
363
- def sync_callable_with_dependency(service: ITestService) -> str:
364
- """
365
- Returns a formatted message using a provided ITestService dependency.
366
-
367
- This synchronous callable accepts an instance of ITestService, retrieves its message,
368
- and returns a formatted string containing that message.
369
-
370
- Parameters
371
- ----------
372
- service : ITestService
373
- An instance of a service implementing the ITestService interface.
374
-
375
- Returns
376
- -------
377
- str
378
- A string containing the message from the provided service, formatted as
379
- "Callable with dependency: <service_message>".
380
- """
381
- # Retrieve the message from the dependency and format it
382
- return f"Callable with dependency: {service.get_message()}"
383
-
384
- async def async_callable_with_dependency(service: IAsyncTestService) -> str:
385
- """
386
- Asynchronously retrieves and formats a message from a provided IAsyncTestService dependency.
387
-
388
- This coroutine awaits the asynchronous message retrieval from the given service,
389
- then returns a formatted string containing that message.
390
-
391
- Parameters
392
- ----------
393
- service : IAsyncTestService
394
- An instance of a service implementing the asynchronous `get_async_message` method.
395
-
396
- Returns
397
- -------
398
- str
399
- A formatted string containing the message retrieved from the service, in the form
400
- "Async callable with dependency: <service_message>".
401
- """
402
-
403
- # Await the asynchronous message from the dependency
404
- msg = await service.get_async_message()
405
-
406
- # Return the formatted result
407
- return f"Async callable with dependency: {msg}"
@@ -1,192 +0,0 @@
1
- class MockAppService:
2
- """
3
- Mock service that can be auto-resolved by the dependency injection container.
4
-
5
- This class simulates a basic application service with no external dependencies,
6
- making it suitable for testing automatic resolution scenarios.
7
- """
8
-
9
- def __init__(self):
10
- # Set service identifier
11
- self.name = "MockAppService"
12
- # Mark as properly initialized
13
- self.initialized = True
14
-
15
- class MockDependency:
16
- """
17
- Mock dependency for testing dependency injection scenarios.
18
-
19
- This class represents a simple dependency that can be injected into other
20
- services during container resolution testing.
21
- """
22
-
23
- def __init__(self):
24
- # Set a test value that can be verified in dependent services
25
- self.value = "dependency_value"
26
-
27
- class MockServiceWithDependency:
28
- """
29
- Mock service that depends on another service for dependency injection testing.
30
-
31
- This class demonstrates single dependency injection where the container
32
- must resolve and inject the required MockDependency instance.
33
-
34
- Parameters
35
- ----------
36
- dependency : MockDependency
37
- The dependency instance to be injected by the container.
38
- """
39
-
40
- def __init__(self, dependency: MockDependency):
41
- # Store the injected dependency
42
- self.dependency = dependency
43
- # Set service identifier
44
- self.name = "MockServiceWithDependency"
45
-
46
- class MockServiceWithMultipleDependencies:
47
- """
48
- Mock service with multiple dependencies for complex injection testing.
49
-
50
- This class tests the container's ability to resolve and inject multiple
51
- dependencies simultaneously in the correct order.
52
-
53
- Parameters
54
- ----------
55
- dependency : MockDependency
56
- The primary dependency instance to be injected.
57
- app_service : MockAppService
58
- The application service instance to be injected.
59
- """
60
-
61
- def __init__(self, dependency: MockDependency, app_service: MockAppService):
62
- # Store the primary dependency
63
- self.dependency = dependency
64
- # Store the application service dependency
65
- self.app_service = app_service
66
- # Set service identifier
67
- self.name = "MockServiceWithMultipleDependencies"
68
-
69
- class MockServiceWithDefaultParam:
70
- """
71
- Mock service with a default parameter for optional dependency testing.
72
-
73
- This class tests the container's handling of services that have both
74
- required dependencies and optional parameters with default values.
75
- Parameters
76
- ----------
77
- dependency : MockDependency
78
- The required dependency instance to be injected.
79
- optional_param : str, default "default_value"
80
- An optional parameter that should not be resolved by the container.
81
- """
82
-
83
- def __init__(self, dependency: MockDependency, optional_param: str = "default_value"):
84
- # Store the required dependency
85
- self.dependency = dependency
86
- # Store the optional parameter (should use default if not provided)
87
- self.optional_param = optional_param
88
-
89
- class MockServiceWithUnresolvableDependency:
90
- """
91
- Mock service with a dependency that cannot be resolved by the container.
92
-
93
- This class is used to test error handling when the container encounters
94
- dependencies that cannot be automatically resolved (primitive types, etc.).
95
-
96
- Parameters
97
- ----------
98
- unresolvable_param : int
99
- A primitive type parameter that cannot be auto-resolved by the container.
100
- """
101
-
102
- def __init__(self, unresolvable_param: int):
103
- # Store the unresolvable parameter
104
- self.unresolvable_param = unresolvable_param
105
-
106
- class MockServiceWithMethodDependencies:
107
- """
108
- Mock service with methods that have dependencies for method injection testing.
109
-
110
- This class tests the container's ability to resolve dependencies for
111
- specific method calls rather than just constructor injection.
112
- """
113
-
114
- def __init__(self):
115
- # Set service identifier
116
- self.name = "MockServiceWithMethodDependencies"
117
-
118
- def process_data(self, dependency: MockDependency, data: str = "default") -> str:
119
- """
120
- Process data using an injected dependency.
121
-
122
- This method demonstrates dependency injection at the method level,
123
- where the container must resolve the dependency parameter while
124
- preserving optional parameters.
125
-
126
- Parameters
127
- ----------
128
- dependency : MockDependency
129
- The dependency instance to be injected for data processing.
130
- data : str, default "default"
131
- The data string to be processed.
132
-
133
- Returns
134
- -------
135
- str
136
- A formatted string containing the processed data and dependency value.
137
- """
138
- # Combine the input data with the dependency's value
139
- return f"Processed {data} with {dependency.value}"
140
-
141
- def complex_operation(self, dependency: MockDependency, app_service: MockAppService) -> dict:
142
- """
143
- Perform a complex operation using multiple injected dependencies.
144
-
145
- This method tests multiple dependency injection at the method level,
146
- ensuring the container can resolve multiple dependencies simultaneously.
147
-
148
- Parameters
149
- ----------
150
- dependency : MockDependency
151
- The primary dependency instance to be injected.
152
- app_service : MockAppService
153
- The application service instance to be injected.
154
-
155
- Returns
156
- -------
157
- dict
158
- A dictionary containing the dependency values and operation result.
159
- """
160
-
161
- # Return a structured result containing information from both dependencies
162
- return {
163
- "dependency": dependency.value,
164
- "app_service": app_service.name,
165
- "result": "complex_operation_result"
166
- }
167
-
168
- # Non-resolvable classes (outside valid namespaces)
169
- class ExternalLibraryClass:
170
- """
171
- Simulates an external library class that shouldn't be auto-resolved.
172
-
173
- This class represents dependencies from external libraries that should
174
- not be automatically resolved by the container due to namespace restrictions.
175
- """
176
-
177
- def __init__(self):
178
- # External classes typically have their own initialization logic
179
- pass
180
-
181
- # Configure module paths to simulate valid application namespaces
182
- # These assignments make the classes appear to be in valid app namespaces for testing
183
- MockAppService.__module__ = 'app.services.mock_app_service'
184
- MockDependency.__module__ = 'app.dependencies.mock_dependency'
185
- MockServiceWithDependency.__module__ = 'app.services.mock_service_with_dependency'
186
- MockServiceWithMultipleDependencies.__module__ = 'app.services.mock_service_with_multiple_dependencies'
187
- MockServiceWithDefaultParam.__module__ = 'app.services.mock_service_with_default_param'
188
- MockServiceWithUnresolvableDependency.__module__ = 'app.services.mock_service_with_unresolvable_dependency'
189
- MockServiceWithMethodDependencies.__module__ = 'app.services.mock_service_with_method_dependencies'
190
-
191
- # External class should not be auto-resolved due to invalid namespace
192
- ExternalLibraryClass.__module__ = 'external_library.some_module'