orionis 0.546.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.
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.547.0.dist-info}/METADATA +1 -1
  11. {orionis-0.546.0.dist-info → orionis-0.547.0.dist-info}/RECORD +15 -159
  12. {orionis-0.546.0.dist-info → orionis-0.547.0.dist-info}/top_level.txt +0 -1
  13. tests/container/__init__.py +0 -0
  14. tests/container/context/__init__.py +0 -0
  15. tests/container/context/test_manager.py +0 -38
  16. tests/container/context/test_scope.py +0 -32
  17. tests/container/core/__init__.py +0 -0
  18. tests/container/core/test_advanced_async.py +0 -234
  19. tests/container/core/test_async_optimizations.py +0 -268
  20. tests/container/core/test_container.py +0 -453
  21. tests/container/core/test_singleton.py +0 -122
  22. tests/container/core/test_thread_safety.py +0 -90
  23. tests/container/entities/__init__.py +0 -0
  24. tests/container/entities/test_binding.py +0 -242
  25. tests/container/enums/__init__.py +0 -0
  26. tests/container/enums/test_lifetimes.py +0 -97
  27. tests/container/facades/__init__.py +0 -0
  28. tests/container/facades/test_facade.py +0 -78
  29. tests/container/mocks/__init__.py +0 -0
  30. tests/container/mocks/mock_advanced_async.py +0 -332
  31. tests/container/mocks/mock_async_optimizations.py +0 -407
  32. tests/container/mocks/mock_auto_resolution.py +0 -192
  33. tests/container/mocks/mock_complex_classes.py +0 -792
  34. tests/container/mocks/mock_simple_classes.py +0 -98
  35. tests/container/providers/__init__.py +0 -0
  36. tests/container/providers/test_providers.py +0 -55
  37. tests/container/validators/__init__.py +0 -0
  38. tests/container/validators/test_implements.py +0 -186
  39. tests/container/validators/test_is_abstract_class.py +0 -147
  40. tests/container/validators/test_is_callable.py +0 -102
  41. tests/container/validators/test_is_concrete_class.py +0 -160
  42. tests/container/validators/test_is_instance.py +0 -150
  43. tests/container/validators/test_is_not_subclass.py +0 -49
  44. tests/container/validators/test_is_subclass.py +0 -178
  45. tests/container/validators/test_is_valid_alias.py +0 -147
  46. tests/container/validators/test_lifetime.py +0 -106
  47. tests/example/__init__.py +0 -0
  48. tests/example/test_example.py +0 -725
  49. tests/foundation/__init__.py +0 -0
  50. tests/foundation/config/__init__.py +0 -0
  51. tests/foundation/config/app/__init__.py +0 -0
  52. tests/foundation/config/app/test_foundation_config_app.py +0 -262
  53. tests/foundation/config/auth/__init__.py +0 -0
  54. tests/foundation/config/auth/test_foundation_config_auth.py +0 -29
  55. tests/foundation/config/cache/__init__.py +0 -0
  56. tests/foundation/config/cache/test_foundation_config_cache.py +0 -143
  57. tests/foundation/config/cache/test_foundation_config_cache_file.py +0 -126
  58. tests/foundation/config/cache/test_foundation_config_cache_stores.py +0 -156
  59. tests/foundation/config/cors/__init__.py +0 -0
  60. tests/foundation/config/cors/test_foundation_config_cors.py +0 -190
  61. tests/foundation/config/database/__init__.py +0 -0
  62. tests/foundation/config/database/test_foundation_config_database.py +0 -158
  63. tests/foundation/config/database/test_foundation_config_database_connections.py +0 -203
  64. tests/foundation/config/database/test_foundation_config_database_mysql.py +0 -354
  65. tests/foundation/config/database/test_foundation_config_database_oracle.py +0 -288
  66. tests/foundation/config/database/test_foundation_config_database_pgsql.py +0 -257
  67. tests/foundation/config/database/test_foundation_config_database_sqlite.py +0 -207
  68. tests/foundation/config/filesystems/__init__.py +0 -0
  69. tests/foundation/config/filesystems/test_foundation_config_filesystems.py +0 -160
  70. tests/foundation/config/filesystems/test_foundation_config_filesystems_aws.py +0 -189
  71. tests/foundation/config/filesystems/test_foundation_config_filesystems_disks.py +0 -184
  72. tests/foundation/config/filesystems/test_foundation_config_filesystems_local.py +0 -143
  73. tests/foundation/config/filesystems/test_foundation_config_filesystems_public.py +0 -184
  74. tests/foundation/config/logging/__init__.py +0 -0
  75. tests/foundation/config/logging/test_foundation_config_logging.py +0 -112
  76. tests/foundation/config/logging/test_foundation_config_logging_channels.py +0 -246
  77. tests/foundation/config/logging/test_foundation_config_logging_chunked.py +0 -217
  78. tests/foundation/config/logging/test_foundation_config_logging_daily.py +0 -220
  79. tests/foundation/config/logging/test_foundation_config_logging_hourly.py +0 -196
  80. tests/foundation/config/logging/test_foundation_config_logging_monthly.py +0 -214
  81. tests/foundation/config/logging/test_foundation_config_logging_stack.py +0 -178
  82. tests/foundation/config/logging/test_foundation_config_logging_weekly.py +0 -224
  83. tests/foundation/config/mail/__init__.py +0 -0
  84. tests/foundation/config/mail/test_foundation_config_mail.py +0 -145
  85. tests/foundation/config/mail/test_foundation_config_mail_file.py +0 -97
  86. tests/foundation/config/mail/test_foundation_config_mail_mailers.py +0 -106
  87. tests/foundation/config/mail/test_foundation_config_mail_smtp.py +0 -146
  88. tests/foundation/config/queue/__init__.py +0 -0
  89. tests/foundation/config/queue/test_foundation_config_queue.py +0 -88
  90. tests/foundation/config/queue/test_foundation_config_queue_brokers.py +0 -72
  91. tests/foundation/config/queue/test_foundation_config_queue_database.py +0 -134
  92. tests/foundation/config/root/__init__.py +0 -0
  93. tests/foundation/config/root/test_foundation_config_root_paths.py +0 -112
  94. tests/foundation/config/session/__init__.py +0 -0
  95. tests/foundation/config/session/test_foundation_config_session.py +0 -213
  96. tests/foundation/config/startup/__init__.py +0 -0
  97. tests/foundation/config/startup/test_foundation_config_startup.py +0 -202
  98. tests/foundation/config/testing/__init__.py +0 -0
  99. tests/foundation/config/testing/test_foundation_config_testing.py +0 -235
  100. tests/metadata/__init__.py +0 -0
  101. tests/metadata/test_metadata_framework.py +0 -140
  102. tests/metadata/test_metadata_package.py +0 -139
  103. tests/services/__init__.py +0 -0
  104. tests/services/asynchrony/__init__.py +0 -0
  105. tests/services/asynchrony/test_services_asynchrony_coroutine.py +0 -85
  106. tests/services/environment/__init__.py +0 -0
  107. tests/services/environment/test_services_environment.py +0 -226
  108. tests/services/introspection/__init__.py +0 -0
  109. tests/services/introspection/dependencies/__init__.py +0 -0
  110. tests/services/introspection/dependencies/mocks/__init__.py +0 -0
  111. tests/services/introspection/dependencies/mocks/mock_user.py +0 -30
  112. tests/services/introspection/dependencies/mocks/mock_user_controller.py +0 -27
  113. tests/services/introspection/dependencies/mocks/mock_users_permissions.py +0 -41
  114. tests/services/introspection/dependencies/test_reflect_dependencies.py +0 -261
  115. tests/services/introspection/reflection/__init__.py +0 -0
  116. tests/services/introspection/reflection/mock/__init__.py +0 -0
  117. tests/services/introspection/reflection/mock/fake_reflect_instance.py +0 -1115
  118. tests/services/introspection/reflection/test_reflection_abstract.py +0 -1011
  119. tests/services/introspection/reflection/test_reflection_callable.py +0 -206
  120. tests/services/introspection/reflection/test_reflection_concrete.py +0 -952
  121. tests/services/introspection/reflection/test_reflection_instance.py +0 -1233
  122. tests/services/introspection/reflection/test_reflection_module.py +0 -567
  123. tests/services/introspection/test_reflection.py +0 -462
  124. tests/services/log/__init__.py +0 -0
  125. tests/services/log/test_log.py +0 -97
  126. tests/services/system/__init__.py +0 -0
  127. tests/services/system/test_services_system_imports.py +0 -204
  128. tests/services/system/test_services_system_workers.py +0 -131
  129. tests/support/__init__.py +0 -0
  130. tests/support/entities/__init__.py +0 -0
  131. tests/support/entities/mock_dataclass.py +0 -40
  132. tests/support/entities/test_base.py +0 -64
  133. tests/support/patterns/__init__.py +0 -0
  134. tests/support/patterns/singleton/__init__.py +0 -0
  135. tests/support/patterns/singleton/test_patterns_singleton.py +0 -39
  136. tests/support/standard/__init__.py +0 -0
  137. tests/support/standard/test_services_std.py +0 -226
  138. tests/support/wrapper/__init__.py +0 -0
  139. tests/support/wrapper/test_services_wrapper_docdict.py +0 -202
  140. tests/testing/__init__.py +0 -0
  141. tests/testing/cases/__init__.py +0 -0
  142. tests/testing/cases/test_testing_asynchronous.py +0 -63
  143. tests/testing/cases/test_testing_synchronous.py +0 -57
  144. tests/testing/entities/__init__.py +0 -0
  145. tests/testing/entities/test_testing_result.py +0 -146
  146. tests/testing/enums/__init__.py +0 -0
  147. tests/testing/enums/test_testing_status.py +0 -63
  148. tests/testing/output/__init__.py +0 -0
  149. tests/testing/output/test_testing_dumper.py +0 -29
  150. tests/testing/output/test_testing_printer.py +0 -42
  151. tests/testing/records/__init__.py +0 -0
  152. tests/testing/records/test_testing_records.py +0 -171
  153. tests/testing/test_testing_unit.py +0 -164
  154. tests/testing/validators/__init__.py +0 -0
  155. tests/testing/validators/test_testing_validators.py +0 -392
  156. tests/testing/view/__init__.py +0 -0
  157. tests/testing/view/test_render.py +0 -30
  158. {orionis-0.546.0.dist-info → orionis-0.547.0.dist-info}/WHEEL +0 -0
  159. {orionis-0.546.0.dist-info → orionis-0.547.0.dist-info}/licenses/LICENCE +0 -0
  160. {orionis-0.546.0.dist-info → orionis-0.547.0.dist-info}/zip-safe +0 -0
@@ -1,567 +0,0 @@
1
- from orionis.test.cases.asynchronous import AsyncTestCase
2
- from orionis.services.introspection.modules.reflection import ReflectionModule
3
- from orionis.services.introspection.exceptions import ReflectionTypeError, ReflectionValueError
4
-
5
- class TestServiceReflectionModule(AsyncTestCase):
6
- """
7
- Test suite for the ReflectionModule class functionality.
8
-
9
- This test class validates the introspection capabilities of the ReflectionModule
10
- which provides reflection functionality for Python modules including class,
11
- function, and constant discovery and manipulation.
12
- """
13
-
14
- module_name = 'tests.services.introspection.reflection.mock.fake_reflect_instance'
15
-
16
- async def testGetModule(self):
17
- """
18
- Test retrieval of the underlying module object.
19
-
20
- Validates that the getModule method returns the correct module object
21
- and that the module's __name__ attribute matches the expected name.
22
-
23
- Raises
24
- ------
25
- AssertionError
26
- If the module name does not match the expected value.
27
- """
28
- reflection = ReflectionModule(self.module_name)
29
- module = reflection.getModule()
30
- self.assertEqual(module.__name__, self.module_name)
31
-
32
- async def testHasClass(self):
33
- """
34
- Test class existence detection within the module.
35
-
36
- Verifies that the hasClass method correctly identifies the presence
37
- or absence of classes within the reflected module.
38
-
39
- Raises
40
- ------
41
- AssertionError
42
- If the class existence check returns incorrect boolean values.
43
- """
44
- reflection = ReflectionModule(self.module_name)
45
- self.assertTrue(reflection.hasClass('PublicFakeClass')) # Existing class should return True
46
- self.assertFalse(reflection.hasClass('NonExistentClass')) # Non-existent class should return False
47
-
48
- async def testGetClass(self):
49
- """
50
- Test class object retrieval by name.
51
-
52
- Validates that the getClass method returns the correct class object
53
- for existing classes and None for non-existent classes.
54
-
55
- Raises
56
- ------
57
- AssertionError
58
- If the retrieved class object is incorrect or None when it should exist.
59
- """
60
- reflection = ReflectionModule(self.module_name)
61
- cls = reflection.getClass('PublicFakeClass')
62
- self.assertIsNotNone(cls) # Class should exist and be returned
63
- self.assertEqual(cls.__name__, 'PublicFakeClass') # Class name should match
64
- self.assertIsNone(reflection.getClass('NonExistentClass')) # Non-existent class should return None
65
-
66
- async def testSetAndRemoveClass(self):
67
- """
68
- Test dynamic class registration and removal operations.
69
-
70
- Validates the complete lifecycle of dynamically adding and removing
71
- classes from the module through the ReflectionModule interface.
72
-
73
- Raises
74
- ------
75
- AssertionError
76
- If class registration, retrieval, or removal operations fail.
77
- """
78
- reflection = ReflectionModule(self.module_name)
79
-
80
- # Define a mock class for testing
81
- class MockClass:
82
- pass
83
-
84
- # Test class registration
85
- reflection.setClass('MockClass', MockClass)
86
- self.assertTrue(reflection.hasClass('MockClass')) # Class should be registered
87
- self.assertEqual(reflection.getClass('MockClass'), MockClass) # Retrieved class should match
88
-
89
- # Test class removal
90
- reflection.removeClass('MockClass')
91
- self.assertFalse(reflection.hasClass('MockClass')) # Class should be removed
92
-
93
- async def testSetClassInvalid(self):
94
- """
95
- Test error handling for invalid class registration attempts.
96
-
97
- Validates that the setClass method properly raises ReflectionValueError
98
- when provided with invalid class names or non-class objects.
99
-
100
- Raises
101
- ------
102
- AssertionError
103
- If expected ReflectionValueError exceptions are not raised.
104
- """
105
- reflection = ReflectionModule(self.module_name)
106
-
107
- # Test invalid class name starting with digit
108
- with self.assertRaises(ReflectionValueError):
109
- reflection.setClass('123Invalid', object)
110
-
111
- # Test reserved keyword as class name
112
- with self.assertRaises(ReflectionValueError):
113
- reflection.setClass('class', object)
114
-
115
- # Test non-class object registration
116
- with self.assertRaises(ReflectionValueError):
117
- reflection.setClass('ValidName', 123)
118
-
119
- async def testRemoveClassInvalid(self):
120
- """
121
- Test error handling for invalid class removal attempts.
122
-
123
- Validates that the removeClass method properly raises ValueError
124
- when attempting to remove a non-existent class from the module.
125
-
126
- Raises
127
- ------
128
- AssertionError
129
- If the expected ValueError exception is not raised.
130
- """
131
- reflection = ReflectionModule(self.module_name)
132
- with self.assertRaises(ValueError):
133
- reflection.removeClass('NonExistentClass')
134
-
135
- async def testInitClass(self):
136
- """
137
- Test class instantiation through reflection.
138
-
139
- Validates that the initClass method can successfully create instances
140
- of existing classes and properly handles non-existent class errors.
141
-
142
- Raises
143
- ------
144
- AssertionError
145
- If class instantiation fails or error handling is incorrect.
146
- """
147
- reflection = ReflectionModule(self.module_name)
148
-
149
- # Test successful class instantiation
150
- instance = reflection.initClass('PublicFakeClass')
151
- self.assertEqual(instance.__class__.__name__, 'PublicFakeClass')
152
-
153
- # Test error handling for non-existent class
154
- with self.assertRaises(ReflectionValueError):
155
- reflection.initClass('NonExistentClass')
156
-
157
- async def testGetClasses(self):
158
- """
159
- Test retrieval of all classes defined in the module.
160
-
161
- Validates that the getClasses method returns a complete dictionary
162
- of all class definitions including public, protected, and private classes.
163
-
164
- Raises
165
- ------
166
- AssertionError
167
- If expected classes are not found in the returned dictionary.
168
- """
169
- reflection = ReflectionModule(self.module_name)
170
- classes = reflection.getClasses()
171
- self.assertIn('PublicFakeClass', classes) # Public class should be included
172
- self.assertIn('_ProtectedFakeClass', classes) # Protected class should be included
173
- self.assertIn('__PrivateFakeClass', classes) # Private class should be included
174
-
175
- async def testGetPublicClasses(self):
176
- """
177
- Test retrieval of public classes only.
178
-
179
- Validates that the getPublicClasses method returns only classes
180
- with public visibility (not prefixed with underscores).
181
-
182
- Raises
183
- ------
184
- AssertionError
185
- If protected or private classes are included or public classes are excluded.
186
- """
187
- reflection = ReflectionModule(self.module_name)
188
- public_classes = reflection.getPublicClasses()
189
- self.assertIn('PublicFakeClass', public_classes) # Public class should be included
190
- self.assertNotIn('_ProtectedFakeClass', public_classes) # Protected class should be excluded
191
- self.assertNotIn('__PrivateFakeClass', public_classes) # Private class should be excluded
192
-
193
- async def testGetProtectedClasses(self):
194
- """
195
- Test retrieval of protected classes only.
196
-
197
- Validates that the getProtectedClasses method returns only classes
198
- with protected visibility (prefixed with single underscore).
199
-
200
- Raises
201
- ------
202
- AssertionError
203
- If public or private classes are included or protected classes are excluded.
204
- """
205
- reflection = ReflectionModule(self.module_name)
206
- protected_classes = reflection.getProtectedClasses()
207
- self.assertIn('_ProtectedFakeClass', protected_classes) # Protected class should be included
208
- self.assertNotIn('PublicFakeClass', protected_classes) # Public class should be excluded
209
-
210
- async def testGetPrivateClasses(self):
211
- """
212
- Test retrieval of private classes only.
213
-
214
- Validates that the getPrivateClasses method returns only classes
215
- with private visibility (prefixed with double underscores, not ending with them).
216
-
217
- Raises
218
- ------
219
- AssertionError
220
- If public or protected classes are included or private classes are excluded.
221
- """
222
- reflection = ReflectionModule(self.module_name)
223
- private_classes = reflection.getPrivateClasses()
224
- self.assertIn('__PrivateFakeClass', private_classes) # Private class should be included
225
- self.assertNotIn('PublicFakeClass', private_classes) # Public class should be excluded
226
-
227
- async def testGetConstants(self):
228
- """
229
- Test retrieval of all constants defined in the module.
230
-
231
- Validates that the getConstants method returns a complete dictionary
232
- of all constant definitions including public, protected, and private constants.
233
-
234
- Raises
235
- ------
236
- AssertionError
237
- If expected constants are not found in the returned dictionary.
238
- """
239
- reflection = ReflectionModule(self.module_name)
240
- consts = reflection.getConstants()
241
- self.assertIn('PUBLIC_CONSTANT', consts) # Public constant should be included
242
- self.assertIn('_PROTECTED_CONSTANT', consts) # Protected constant should be included
243
- self.assertIn('__PRIVATE_CONSTANT', consts) # Private constant should be included
244
-
245
- async def testGetPublicConstants(self):
246
- """
247
- Test retrieval of public constants only.
248
-
249
- Validates that the getPublicConstants method returns only constants
250
- with public visibility (not prefixed with underscores).
251
-
252
- Raises
253
- ------
254
- AssertionError
255
- If protected or private constants are included or public constants are excluded.
256
- """
257
- reflection = ReflectionModule(self.module_name)
258
- public_consts = reflection.getPublicConstants()
259
- self.assertIn('PUBLIC_CONSTANT', public_consts) # Public constant should be included
260
- self.assertNotIn('_PROTECTED_CONSTANT', public_consts) # Protected constant should be excluded
261
- self.assertNotIn('__PRIVATE_CONSTANT', public_consts) # Private constant should be excluded
262
-
263
- async def testGetProtectedConstants(self):
264
- """
265
- Test retrieval of protected constants only.
266
-
267
- Validates that the getProtectedConstants method returns only constants
268
- with protected visibility (prefixed with single underscore).
269
-
270
- Raises
271
- ------
272
- AssertionError
273
- If public or private constants are included or protected constants are excluded.
274
- """
275
- reflection = ReflectionModule(self.module_name)
276
- protected_consts = reflection.getProtectedConstants()
277
- self.assertIn('_PROTECTED_CONSTANT', protected_consts) # Protected constant should be included
278
- self.assertNotIn('PUBLIC_CONSTANT', protected_consts) # Public constant should be excluded
279
-
280
- async def testGetPrivateConstants(self):
281
- """
282
- Test retrieval of private constants only.
283
-
284
- Validates that the getPrivateConstants method returns only constants
285
- with private visibility (prefixed with double underscores, not ending with them).
286
-
287
- Raises
288
- ------
289
- AssertionError
290
- If public or protected constants are included or private constants are excluded.
291
- """
292
- reflection = ReflectionModule(self.module_name)
293
- private_consts = reflection.getPrivateConstants()
294
- self.assertIn('__PRIVATE_CONSTANT', private_consts) # Private constant should be included
295
- self.assertNotIn('PUBLIC_CONSTANT', private_consts) # Public constant should be excluded
296
-
297
- async def testGetConstant(self):
298
- """
299
- Test individual constant value retrieval by name.
300
-
301
- Validates that the getConstant method returns the correct value
302
- for existing constants and None for non-existent constants.
303
-
304
- Raises
305
- ------
306
- AssertionError
307
- If the retrieved constant value is incorrect or None when it should exist.
308
- """
309
- reflection = ReflectionModule(self.module_name)
310
- value = reflection.getConstant('PUBLIC_CONSTANT')
311
- self.assertEqual(value, 'public constant') # Constant value should match expected
312
- self.assertIsNone(reflection.getConstant('NON_EXISTENT_CONST')) # Non-existent constant should return None
313
-
314
- async def testGetFunctions(self):
315
- """
316
- Test retrieval of all functions defined in the module.
317
-
318
- Validates that the getFunctions method returns a complete dictionary
319
- of all function definitions including public, protected, and private functions
320
- of both synchronous and asynchronous types.
321
-
322
- Raises
323
- ------
324
- AssertionError
325
- If expected functions are not found in the returned dictionary.
326
- """
327
- reflection = ReflectionModule(self.module_name)
328
- funcs = reflection.getFunctions()
329
- # Test public functions
330
- self.assertIn('publicSyncFunction', funcs) # Public sync function should be included
331
- self.assertIn('publicAsyncFunction', funcs) # Public async function should be included
332
- # Test protected functions
333
- self.assertIn('_protectedSyncFunction', funcs) # Protected sync function should be included
334
- self.assertIn('_protectedAsyncFunction', funcs) # Protected async function should be included
335
- # Test private functions
336
- self.assertIn('__privateSyncFunction', funcs) # Private sync function should be included
337
- self.assertIn('__privateAsyncFunction', funcs) # Private async function should be included
338
-
339
- async def testGetPublicFunctions(self):
340
- """
341
- Test retrieval of public functions only.
342
-
343
- Validates that the getPublicFunctions method returns only functions
344
- with public visibility (not prefixed with underscores) including
345
- both synchronous and asynchronous functions.
346
-
347
- Raises
348
- ------
349
- AssertionError
350
- If protected or private functions are included or public functions are excluded.
351
- """
352
- reflection = ReflectionModule(self.module_name)
353
- public_funcs = reflection.getPublicFunctions()
354
- self.assertIn('publicSyncFunction', public_funcs) # Public sync function should be included
355
- self.assertIn('publicAsyncFunction', public_funcs) # Public async function should be included
356
- self.assertNotIn('_protectedSyncFunction', public_funcs) # Protected function should be excluded
357
- self.assertNotIn('__privateSyncFunction', public_funcs) # Private function should be excluded
358
-
359
- async def testGetPublicSyncFunctions(self):
360
- """
361
- Test retrieval of public synchronous functions only.
362
-
363
- Validates that the getPublicSyncFunctions method returns only functions
364
- with public visibility that are synchronous (non-async).
365
-
366
- Raises
367
- ------
368
- AssertionError
369
- If asynchronous functions are included or synchronous public functions are excluded.
370
- """
371
- reflection = ReflectionModule(self.module_name)
372
- sync_funcs = reflection.getPublicSyncFunctions()
373
- self.assertIn('publicSyncFunction', sync_funcs) # Public sync function should be included
374
- self.assertNotIn('publicAsyncFunction', sync_funcs) # Public async function should be excluded
375
-
376
- async def testGetPublicAsyncFunctions(self):
377
- """
378
- Test retrieval of public asynchronous functions only.
379
-
380
- Validates that the getPublicAsyncFunctions method returns only functions
381
- with public visibility that are asynchronous (async def).
382
-
383
- Raises
384
- ------
385
- AssertionError
386
- If synchronous functions are included or asynchronous public functions are excluded.
387
- """
388
- reflection = ReflectionModule(self.module_name)
389
- async_funcs = reflection.getPublicAsyncFunctions()
390
- self.assertIn('publicAsyncFunction', async_funcs) # Public async function should be included
391
- self.assertNotIn('publicSyncFunction', async_funcs) # Public sync function should be excluded
392
-
393
- async def testGetProtectedFunctions(self):
394
- """
395
- Test retrieval of protected functions only.
396
-
397
- Validates that the getProtectedFunctions method returns only functions
398
- with protected visibility (prefixed with single underscore) including
399
- both synchronous and asynchronous functions.
400
-
401
- Raises
402
- ------
403
- AssertionError
404
- If public functions are included or protected functions are excluded.
405
- """
406
- reflection = ReflectionModule(self.module_name)
407
- protected_funcs = reflection.getProtectedFunctions()
408
- self.assertIn('_protectedSyncFunction', protected_funcs) # Protected sync function should be included
409
- self.assertIn('_protectedAsyncFunction', protected_funcs) # Protected async function should be included
410
- self.assertNotIn('publicSyncFunction', protected_funcs) # Public function should be excluded
411
-
412
- async def testGetProtectedSyncFunctions(self):
413
- """
414
- Test retrieval of protected synchronous functions only.
415
-
416
- Validates that the getProtectedSyncFunctions method returns only functions
417
- with protected visibility that are synchronous (non-async).
418
-
419
- Raises
420
- ------
421
- AssertionError
422
- If asynchronous functions are included or synchronous protected functions are excluded.
423
- """
424
- reflection = ReflectionModule(self.module_name)
425
- sync_funcs = reflection.getProtectedSyncFunctions()
426
- self.assertIn('_protectedSyncFunction', sync_funcs) # Protected sync function should be included
427
- self.assertNotIn('_protectedAsyncFunction', sync_funcs) # Protected async function should be excluded
428
-
429
- async def testGetProtectedAsyncFunctions(self):
430
- """
431
- Test retrieval of protected asynchronous functions only.
432
-
433
- Validates that the getProtectedAsyncFunctions method returns only functions
434
- with protected visibility that are asynchronous (async def).
435
-
436
- Raises
437
- ------
438
- AssertionError
439
- If synchronous functions are included or asynchronous protected functions are excluded.
440
- """
441
- reflection = ReflectionModule(self.module_name)
442
- async_funcs = reflection.getProtectedAsyncFunctions()
443
- self.assertIn('_protectedAsyncFunction', async_funcs) # Protected async function should be included
444
- self.assertNotIn('_protectedSyncFunction', async_funcs) # Protected sync function should be excluded
445
-
446
- async def testGetPrivateFunctions(self):
447
- """
448
- Test retrieval of private functions only.
449
-
450
- Validates that the getPrivateFunctions method returns only functions
451
- with private visibility (prefixed with double underscores, not ending with them)
452
- including both synchronous and asynchronous functions.
453
-
454
- Raises
455
- ------
456
- AssertionError
457
- If public functions are included or private functions are excluded.
458
- """
459
- reflection = ReflectionModule(self.module_name)
460
- private_funcs = reflection.getPrivateFunctions()
461
- self.assertIn('__privateSyncFunction', private_funcs) # Private sync function should be included
462
- self.assertIn('__privateAsyncFunction', private_funcs) # Private async function should be included
463
- self.assertNotIn('publicSyncFunction', private_funcs) # Public function should be excluded
464
-
465
- async def testGetPrivateSyncFunctions(self):
466
- """
467
- Test retrieval of private synchronous functions only.
468
-
469
- Validates that the getPrivateSyncFunctions method returns only functions
470
- with private visibility that are synchronous (non-async).
471
-
472
- Raises
473
- ------
474
- AssertionError
475
- If asynchronous functions are included or synchronous private functions are excluded.
476
- """
477
- reflection = ReflectionModule(self.module_name)
478
- sync_funcs = reflection.getPrivateSyncFunctions()
479
- self.assertIn('__privateSyncFunction', sync_funcs) # Private sync function should be included
480
- self.assertNotIn('__privateAsyncFunction', sync_funcs) # Private async function should be excluded
481
-
482
- async def testGetPrivateAsyncFunctions(self):
483
- """
484
- Test retrieval of private asynchronous functions only.
485
-
486
- Validates that the getPrivateAsyncFunctions method returns only functions
487
- with private visibility that are asynchronous (async def).
488
-
489
- Raises
490
- ------
491
- AssertionError
492
- If synchronous functions are included or asynchronous private functions are excluded.
493
- """
494
- reflection = ReflectionModule(self.module_name)
495
- async_funcs = reflection.getPrivateAsyncFunctions()
496
- self.assertIn('__privateAsyncFunction', async_funcs) # Private async function should be included
497
- self.assertNotIn('__privateSyncFunction', async_funcs) # Private sync function should be excluded
498
-
499
- async def testGetImports(self):
500
- """
501
- Test retrieval of imported modules within the reflected module.
502
-
503
- Validates that the getImports method correctly identifies and returns
504
- all imported module objects from the module's namespace.
505
-
506
- Raises
507
- ------
508
- AssertionError
509
- If expected imported modules are not found in the returned dictionary.
510
- """
511
- reflection = ReflectionModule(self.module_name)
512
- imports = reflection.getImports()
513
- self.assertIn('asyncio', imports) # asyncio module should be imported
514
-
515
- async def testGetFile(self):
516
- """
517
- Test retrieval of the module's file path.
518
-
519
- Validates that the getFile method returns the correct absolute path
520
- to the module's source file.
521
-
522
- Raises
523
- ------
524
- AssertionError
525
- If the returned file path does not end with the expected filename.
526
- """
527
- reflection = ReflectionModule(self.module_name)
528
- file_path = reflection.getFile()
529
- self.assertTrue(file_path.endswith('fake_reflect_instance.py')) # Path should end with expected filename
530
-
531
- async def testGetSourceCode(self):
532
- """
533
- Test retrieval of the module's complete source code.
534
-
535
- Validates that the getSourceCode method returns the entire source code
536
- content of the module file and contains expected code elements.
537
-
538
- Raises
539
- ------
540
- AssertionError
541
- If expected code elements are not found in the returned source code.
542
- """
543
- reflection = ReflectionModule(self.module_name)
544
- code = reflection.getSourceCode()
545
- self.assertIn('PUBLIC_CONSTANT', code) # Constant should be present in source
546
- self.assertIn('def publicSyncFunction', code) # Function definition should be present in source
547
-
548
- async def test_invalid_module_name(self):
549
- """
550
- Test error handling for invalid module initialization.
551
-
552
- Validates that ReflectionModule properly raises ReflectionTypeError
553
- when initialized with invalid module names such as empty strings
554
- or non-existent module paths.
555
-
556
- Raises
557
- ------
558
- AssertionError
559
- If expected ReflectionTypeError exceptions are not raised.
560
- """
561
- # Test empty string module name
562
- with self.assertRaises(ReflectionTypeError):
563
- ReflectionModule('')
564
-
565
- # Test non-existent module path
566
- with self.assertRaises(ReflectionTypeError):
567
- ReflectionModule('nonexistent.module.name')