orionis 0.437.0__py3-none-any.whl → 0.439.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 (36) hide show
  1. orionis/container/context/scope.py +1 -1
  2. orionis/metadata/framework.py +1 -1
  3. {orionis-0.437.0.dist-info → orionis-0.439.0.dist-info}/METADATA +1 -1
  4. {orionis-0.437.0.dist-info → orionis-0.439.0.dist-info}/RECORD +36 -35
  5. tests/container/context/test_manager.py +1 -0
  6. tests/container/context/test_scope.py +1 -0
  7. tests/container/core/__init__.py +0 -0
  8. tests/container/{test_container.py → core/test_container.py} +45 -1
  9. tests/container/{test_singleton.py → core/test_singleton.py} +5 -0
  10. tests/container/{test_thread_safety.py → core/test_thread_safety.py} +2 -0
  11. tests/container/mocks/mock_complex_classes.py +502 -192
  12. tests/container/mocks/mock_simple_classes.py +72 -6
  13. tests/container/validators/test_is_not_subclass.py +0 -1
  14. tests/container/validators/test_is_valid_alias.py +1 -1
  15. tests/foundation/config/database/test_foundation_config_database.py +54 -28
  16. tests/foundation/config/filesystems/test_foundation_config_filesystems_aws.py +40 -22
  17. tests/foundation/config/filesystems/test_foundation_config_filesystems_public.py +75 -48
  18. tests/foundation/config/logging/test_foundation_config_logging_channels.py +49 -37
  19. tests/foundation/config/logging/test_foundation_config_logging_monthly.py +80 -42
  20. tests/foundation/config/logging/test_foundation_config_logging_stack.py +46 -22
  21. tests/foundation/config/queue/test_foundation_config_queue_brokers.py +1 -0
  22. tests/foundation/config/root/test_foundation_config_root_paths.py +37 -44
  23. tests/foundation/config/session/test_foundation_config_session.py +65 -20
  24. tests/foundation/config/startup/test_foundation_config_startup.py +37 -34
  25. tests/services/environment/test_services_environment.py +5 -4
  26. tests/services/introspection/dependencies/test_reflect_dependencies.py +77 -25
  27. tests/services/introspection/reflection/mock/fake_reflect_instance.py +750 -267
  28. tests/services/introspection/reflection/test_reflection_abstract.py +514 -83
  29. tests/services/introspection/reflection/test_reflection_callable.py +85 -35
  30. tests/services/introspection/reflection/test_reflection_concrete.py +345 -226
  31. tests/services/introspection/reflection/test_reflection_instance.py +627 -273
  32. tests/services/introspection/reflection/test_reflection_module.py +346 -175
  33. {orionis-0.437.0.dist-info → orionis-0.439.0.dist-info}/WHEEL +0 -0
  34. {orionis-0.437.0.dist-info → orionis-0.439.0.dist-info}/licenses/LICENCE +0 -0
  35. {orionis-0.437.0.dist-info → orionis-0.439.0.dist-info}/top_level.txt +0 -0
  36. {orionis-0.437.0.dist-info → orionis-0.439.0.dist-info}/zip-safe +0 -0
@@ -3,13 +3,27 @@ from orionis.services.introspection.modules.reflection import ReflectionModule
3
3
  from orionis.services.introspection.exceptions import ReflectionTypeError, ReflectionValueError
4
4
 
5
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
+ """
6
13
 
7
14
  module_name = 'tests.services.introspection.reflection.mock.fake_reflect_instance'
8
15
 
9
16
  async def testGetModule(self):
10
17
  """
11
- Test that the `getModule` method of the `ReflectionModule` class returns a module object
12
- whose `__name__` attribute matches the expected module name.
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.
13
27
  """
14
28
  reflection = ReflectionModule(self.module_name)
15
29
  module = reflection.getModule()
@@ -17,75 +31,102 @@ class TestServiceReflectionModule(AsyncTestCase):
17
31
 
18
32
  async def testHasClass(self):
19
33
  """
20
- Tests the hasClass method of the ReflectionModule.
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.
21
38
 
22
- This test verifies that hasClass correctly identifies the presence or absence of a class within the module:
23
- - Asserts that hasClass returns True for an existing class ('PublicFakeClass').
24
- - Asserts that hasClass returns False for a non-existent class ('NonExistentClass').
39
+ Raises
40
+ ------
41
+ AssertionError
42
+ If the class existence check returns incorrect boolean values.
25
43
  """
26
44
  reflection = ReflectionModule(self.module_name)
27
- self.assertTrue(reflection.hasClass('PublicFakeClass'))
28
- self.assertFalse(reflection.hasClass('NonExistentClass'))
45
+ self.assertTrue(reflection.hasClass('PublicFakeClass')) # Existing class should return True
46
+ self.assertFalse(reflection.hasClass('NonExistentClass')) # Non-existent class should return False
29
47
 
30
48
  async def testGetClass(self):
31
49
  """
32
- Test the `getClass` method of the ReflectionModule.
50
+ Test class object retrieval by name.
33
51
 
34
- This test verifies that:
35
- - The method returns the correct class object when given a valid class name ('PublicFakeClass').
36
- - The returned class object has the expected name.
37
- - The method returns None when given a non-existent class name ('NonExistentClass').
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.
38
59
  """
39
60
  reflection = ReflectionModule(self.module_name)
40
61
  cls = reflection.getClass('PublicFakeClass')
41
- self.assertIsNotNone(cls)
42
- self.assertEqual(cls.__name__, 'PublicFakeClass')
43
- self.assertIsNone(reflection.getClass('NonExistentClass'))
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
44
65
 
45
66
  async def testSetAndRemoveClass(self):
46
67
  """
47
- Test the functionality of setting, retrieving, and removing a class in the ReflectionModule.
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.
48
72
 
49
- This test verifies that:
50
- - A class can be registered with the ReflectionModule using setClass.
51
- - The presence of the class can be checked with hasClass.
52
- - The registered class can be retrieved with getClass.
53
- - The class can be removed with removeClass.
54
- - After removal, hasClass returns False for the class name.
73
+ Raises
74
+ ------
75
+ AssertionError
76
+ If class registration, retrieval, or removal operations fail.
55
77
  """
56
78
  reflection = ReflectionModule(self.module_name)
79
+
80
+ # Define a mock class for testing
57
81
  class MockClass:
58
82
  pass
83
+
84
+ # Test class registration
59
85
  reflection.setClass('MockClass', MockClass)
60
- self.assertTrue(reflection.hasClass('MockClass'))
61
- self.assertEqual(reflection.getClass('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
62
90
  reflection.removeClass('MockClass')
63
- self.assertFalse(reflection.hasClass('MockClass'))
91
+ self.assertFalse(reflection.hasClass('MockClass')) # Class should be removed
64
92
 
65
93
  async def testSetClassInvalid(self):
66
94
  """
67
- Test that the `setClass` method of `ReflectionModule` raises a `ReflectionValueError`
68
- when provided with invalid class names or class types.
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.
69
99
 
70
- Scenarios tested:
71
- - Class name starts with a digit.
72
- - Class name is a reserved keyword.
73
- - Class type is not a valid type (e.g., passing an integer instead of a class).
100
+ Raises
101
+ ------
102
+ AssertionError
103
+ If expected ReflectionValueError exceptions are not raised.
74
104
  """
75
105
  reflection = ReflectionModule(self.module_name)
106
+
107
+ # Test invalid class name starting with digit
76
108
  with self.assertRaises(ReflectionValueError):
77
109
  reflection.setClass('123Invalid', object)
110
+
111
+ # Test reserved keyword as class name
78
112
  with self.assertRaises(ReflectionValueError):
79
113
  reflection.setClass('class', object)
114
+
115
+ # Test non-class object registration
80
116
  with self.assertRaises(ReflectionValueError):
81
117
  reflection.setClass('ValidName', 123)
82
118
 
83
119
  async def testRemoveClassInvalid(self):
84
120
  """
85
- Test that attempting to remove a non-existent class from the ReflectionModule raises a ValueError.
121
+ Test error handling for invalid class removal attempts.
86
122
 
87
- This test verifies that the `removeClass` method correctly handles the case where the specified class
88
- does not exist in the module by raising a `ValueError` exception.
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.
89
130
  """
90
131
  reflection = ReflectionModule(self.module_name)
91
132
  with self.assertRaises(ValueError):
@@ -93,304 +134,434 @@ class TestServiceReflectionModule(AsyncTestCase):
93
134
 
94
135
  async def testInitClass(self):
95
136
  """
96
- Tests the initialization of a class using the ReflectionModule.
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.
97
141
 
98
- This test verifies that:
99
- - An instance of 'PublicFakeClass' can be successfully created using the initClass method.
100
- - The created instance has the correct class name.
101
- - Attempting to initialize a non-existent class ('NonExistentClass') raises a ReflectionValueError.
142
+ Raises
143
+ ------
144
+ AssertionError
145
+ If class instantiation fails or error handling is incorrect.
102
146
  """
103
147
  reflection = ReflectionModule(self.module_name)
148
+
149
+ # Test successful class instantiation
104
150
  instance = reflection.initClass('PublicFakeClass')
105
151
  self.assertEqual(instance.__class__.__name__, 'PublicFakeClass')
152
+
153
+ # Test error handling for non-existent class
106
154
  with self.assertRaises(ReflectionValueError):
107
155
  reflection.initClass('NonExistentClass')
108
156
 
109
157
  async def testGetClasses(self):
110
158
  """
111
- Test that the `getClasses` method of the `ReflectionModule` returns a list of class names
112
- defined in the module, including public, protected, and private classes.
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.
113
168
  """
114
169
  reflection = ReflectionModule(self.module_name)
115
170
  classes = reflection.getClasses()
116
- self.assertIn('PublicFakeClass', classes)
117
- self.assertIn('_ProtectedFakeClass', classes)
118
- self.assertIn('__PrivateFakeClass', classes)
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
119
174
 
120
175
  async def testGetPublicClasses(self):
121
176
  """
122
- Test that the `getPublicClasses` method of the `ReflectionModule` returns only public class names.
123
- Verifies that:
124
- - Public class names (e.g., 'PublicFakeClass') are included in the result.
125
- - Protected (e.g., '_ProtectedFakeClass') and private (e.g., '__PrivateFakeClass') class names are excluded.
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.
126
186
  """
127
187
  reflection = ReflectionModule(self.module_name)
128
188
  public_classes = reflection.getPublicClasses()
129
- self.assertIn('PublicFakeClass', public_classes)
130
- self.assertNotIn('_ProtectedFakeClass', public_classes)
131
- self.assertNotIn('__PrivateFakeClass', public_classes)
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
132
192
 
133
193
  async def testGetProtectedClasses(self):
134
194
  """
135
- Test that the ReflectionModule correctly identifies protected classes.
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).
136
199
 
137
- This test verifies that the `getProtectedClasses` method returns a list containing
138
- the names of protected classes (those prefixed with an underscore) and excludes
139
- public class names. Specifically, it checks that '_ProtectedFakeClass' is present
140
- in the returned list, while 'PublicFakeClass' is not.
200
+ Raises
201
+ ------
202
+ AssertionError
203
+ If public or private classes are included or protected classes are excluded.
141
204
  """
142
205
  reflection = ReflectionModule(self.module_name)
143
206
  protected_classes = reflection.getProtectedClasses()
144
- self.assertIn('_ProtectedFakeClass', protected_classes)
145
- self.assertNotIn('PublicFakeClass', protected_classes)
207
+ self.assertIn('_ProtectedFakeClass', protected_classes) # Protected class should be included
208
+ self.assertNotIn('PublicFakeClass', protected_classes) # Public class should be excluded
146
209
 
147
210
  async def testGetPrivateClasses(self):
148
211
  """
149
- Test that the `getPrivateClasses` method of the `ReflectionModule` correctly identifies private classes within the specified module.
212
+ Test retrieval of private classes only.
150
213
 
151
- This test verifies that:
152
- - The private class '__PrivateFakeClass' is present in the list of private classes returned.
153
- - The public class 'PublicFakeClass' is not included in the list of private classes.
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.
154
221
  """
155
222
  reflection = ReflectionModule(self.module_name)
156
223
  private_classes = reflection.getPrivateClasses()
157
- self.assertIn('__PrivateFakeClass', private_classes)
158
- self.assertNotIn('PublicFakeClass', private_classes)
224
+ self.assertIn('__PrivateFakeClass', private_classes) # Private class should be included
225
+ self.assertNotIn('PublicFakeClass', private_classes) # Public class should be excluded
159
226
 
160
227
  async def testGetConstants(self):
161
228
  """
162
- Test that the `getConstants` method of the `ReflectionModule` retrieves all types of constants
163
- (public, protected, and private) defined in the module.
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.
164
233
 
165
- Asserts:
166
- - 'PUBLIC_CONSTANT' is present in the returned constants.
167
- - '_PROTECTED_CONSTANT' is present in the returned constants.
168
- - '__PRIVATE_CONSTANT' is present in the returned constants.
234
+ Raises
235
+ ------
236
+ AssertionError
237
+ If expected constants are not found in the returned dictionary.
169
238
  """
170
239
  reflection = ReflectionModule(self.module_name)
171
240
  consts = reflection.getConstants()
172
- self.assertIn('PUBLIC_CONSTANT', consts)
173
- self.assertIn('_PROTECTED_CONSTANT', consts)
174
- self.assertIn('__PRIVATE_CONSTANT', consts)
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
175
244
 
176
245
  async def testGetPublicConstants(self):
177
246
  """
178
- Test that `getPublicConstants` returns only public constants from the module.
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).
179
251
 
180
- This test verifies that:
181
- - 'PUBLIC_CONSTANT' is present in the returned list of public constants.
182
- - '_PROTECTED_CONSTANT' and '__PRIVATE_CONSTANT' are not included in the list, ensuring that protected and private constants are excluded.
252
+ Raises
253
+ ------
254
+ AssertionError
255
+ If protected or private constants are included or public constants are excluded.
183
256
  """
184
257
  reflection = ReflectionModule(self.module_name)
185
258
  public_consts = reflection.getPublicConstants()
186
- self.assertIn('PUBLIC_CONSTANT', public_consts)
187
- self.assertNotIn('_PROTECTED_CONSTANT', public_consts)
188
- self.assertNotIn('__PRIVATE_CONSTANT', public_consts)
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
189
262
 
190
263
  async def testGetProtectedConstants(self):
191
264
  """
192
- Tests that the `getProtectedConstants` method of the `ReflectionModule` class
193
- correctly retrieves protected constants (those prefixed with an underscore) from the module.
265
+ Test retrieval of protected constants only.
194
266
 
195
- Asserts that '_PROTECTED_CONSTANT' is present in the returned list of protected constants,
196
- and that 'PUBLIC_CONSTANT' is not included.
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.
197
274
  """
198
275
  reflection = ReflectionModule(self.module_name)
199
276
  protected_consts = reflection.getProtectedConstants()
200
- self.assertIn('_PROTECTED_CONSTANT', protected_consts)
201
- self.assertNotIn('PUBLIC_CONSTANT', protected_consts)
277
+ self.assertIn('_PROTECTED_CONSTANT', protected_consts) # Protected constant should be included
278
+ self.assertNotIn('PUBLIC_CONSTANT', protected_consts) # Public constant should be excluded
202
279
 
203
280
  async def testGetPrivateConstants(self):
204
281
  """
205
- Test that the getPrivateConstants method of the ReflectionModule correctly retrieves private constants.
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).
206
286
 
207
- This test verifies that:
208
- - The private constant '__PRIVATE_CONSTANT' is present in the list of private constants.
209
- - The public constant 'PUBLIC_CONSTANT' is not included in the list of private constants.
287
+ Raises
288
+ ------
289
+ AssertionError
290
+ If public or protected constants are included or private constants are excluded.
210
291
  """
211
292
  reflection = ReflectionModule(self.module_name)
212
293
  private_consts = reflection.getPrivateConstants()
213
- self.assertIn('__PRIVATE_CONSTANT', private_consts)
214
- self.assertNotIn('PUBLIC_CONSTANT', private_consts)
294
+ self.assertIn('__PRIVATE_CONSTANT', private_consts) # Private constant should be included
295
+ self.assertNotIn('PUBLIC_CONSTANT', private_consts) # Public constant should be excluded
215
296
 
216
297
  async def testGetConstant(self):
217
298
  """
218
- Test the `getConstant` method of the ReflectionModule.
299
+ Test individual constant value retrieval by name.
219
300
 
220
- This test verifies that:
221
- - Retrieving an existing constant ('PUBLIC_CONSTANT') returns its expected value ('public constant').
222
- - Retrieving a non-existent constant ('NON_EXISTENT_CONST') returns None.
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.
223
308
  """
224
309
  reflection = ReflectionModule(self.module_name)
225
310
  value = reflection.getConstant('PUBLIC_CONSTANT')
226
- self.assertEqual(value, 'public constant')
227
- self.assertIsNone(reflection.getConstant('NON_EXISTENT_CONST'))
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
228
313
 
229
314
  async def testGetFunctions(self):
230
315
  """
231
- Test that the ReflectionModule correctly retrieves all function names, including public, protected, and private methods, from the specified module.
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.
232
326
  """
233
327
  reflection = ReflectionModule(self.module_name)
234
328
  funcs = reflection.getFunctions()
235
- self.assertIn('publicSyncFunction', funcs)
236
- self.assertIn('publicAsyncFunction', funcs)
237
- self.assertIn('_protectedSyncFunction', funcs)
238
- self.assertIn('_protectedAsyncFunction', funcs)
239
- self.assertIn('__privateSyncFunction', funcs)
240
- self.assertIn('__privateAsyncFunction', funcs)
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
241
338
 
242
339
  async def testGetPublicFunctions(self):
243
340
  """
244
- Test that ReflectionModule.getPublicFunctions() returns only public functions.
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.
245
346
 
246
- This test verifies that:
247
- - Public synchronous and asynchronous functions are included in the returned list.
248
- - Protected (prefixed with a single underscore) and private (prefixed with double underscores) functions are not included.
347
+ Raises
348
+ ------
349
+ AssertionError
350
+ If protected or private functions are included or public functions are excluded.
249
351
  """
250
352
  reflection = ReflectionModule(self.module_name)
251
353
  public_funcs = reflection.getPublicFunctions()
252
- self.assertIn('publicSyncFunction', public_funcs)
253
- self.assertIn('publicAsyncFunction', public_funcs)
254
- self.assertNotIn('_protectedSyncFunction', public_funcs)
255
- self.assertNotIn('__privateSyncFunction', public_funcs)
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
256
358
 
257
359
  async def testGetPublicSyncFunctions(self):
258
360
  """
259
- Test that `getPublicSyncFunctions` returns only public synchronous functions.
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).
260
365
 
261
- This test verifies that:
262
- - The list of public synchronous functions includes 'publicSyncFunction'.
263
- - The list does not include 'publicAsyncFunction', ensuring only synchronous functions are returned.
366
+ Raises
367
+ ------
368
+ AssertionError
369
+ If asynchronous functions are included or synchronous public functions are excluded.
264
370
  """
265
371
  reflection = ReflectionModule(self.module_name)
266
372
  sync_funcs = reflection.getPublicSyncFunctions()
267
- self.assertIn('publicSyncFunction', sync_funcs)
268
- self.assertNotIn('publicAsyncFunction', sync_funcs)
373
+ self.assertIn('publicSyncFunction', sync_funcs) # Public sync function should be included
374
+ self.assertNotIn('publicAsyncFunction', sync_funcs) # Public async function should be excluded
269
375
 
270
376
  async def testGetPublicAsyncFunctions(self):
271
377
  """
272
- Test that ReflectionModule.getPublicAsyncFunctions() returns a list containing the names of public asynchronous functions,
273
- including 'publicAsyncFunction', and excludes synchronous functions such as 'publicSyncFunction'.
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.
274
387
  """
275
388
  reflection = ReflectionModule(self.module_name)
276
389
  async_funcs = reflection.getPublicAsyncFunctions()
277
- self.assertIn('publicAsyncFunction', async_funcs)
278
- self.assertNotIn('publicSyncFunction', async_funcs)
390
+ self.assertIn('publicAsyncFunction', async_funcs) # Public async function should be included
391
+ self.assertNotIn('publicSyncFunction', async_funcs) # Public sync function should be excluded
279
392
 
280
393
  async def testGetProtectedFunctions(self):
281
394
  """
282
- Test that the ReflectionModule correctly identifies protected functions.
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.
283
400
 
284
- This test verifies that:
285
- - Protected functions (those prefixed with a single underscore) are included in the list returned by getProtectedFunctions().
286
- - Public functions (those without a leading underscore) are not included in the list of protected functions.
401
+ Raises
402
+ ------
403
+ AssertionError
404
+ If public functions are included or protected functions are excluded.
287
405
  """
288
406
  reflection = ReflectionModule(self.module_name)
289
407
  protected_funcs = reflection.getProtectedFunctions()
290
- self.assertIn('_protectedSyncFunction', protected_funcs)
291
- self.assertIn('_protectedAsyncFunction', protected_funcs)
292
- self.assertNotIn('publicSyncFunction', protected_funcs)
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
293
411
 
294
412
  async def testGetProtectedSyncFunctions(self):
295
413
  """
296
- Test that the `getProtectedSyncFunctions` method of the `ReflectionModule` class
297
- returns a list containing protected synchronous function names, specifically
298
- including '_protectedSyncFunction' and excluding '_protectedAsyncFunction'.
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.
299
423
  """
300
424
  reflection = ReflectionModule(self.module_name)
301
425
  sync_funcs = reflection.getProtectedSyncFunctions()
302
- self.assertIn('_protectedSyncFunction', sync_funcs)
303
- self.assertNotIn('_protectedAsyncFunction', sync_funcs)
426
+ self.assertIn('_protectedSyncFunction', sync_funcs) # Protected sync function should be included
427
+ self.assertNotIn('_protectedAsyncFunction', sync_funcs) # Protected async function should be excluded
304
428
 
305
429
  async def testGetProtectedAsyncFunctions(self):
306
430
  """
307
- Test that the ReflectionModule correctly identifies protected asynchronous functions.
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).
308
435
 
309
- This test verifies that:
310
- - The list of protected async functions returned by `getProtectedAsyncFunctions()` includes '_protectedAsyncFunction'.
311
- - The list does not include '_protectedSyncFunction', ensuring only async functions are returned.
436
+ Raises
437
+ ------
438
+ AssertionError
439
+ If synchronous functions are included or asynchronous protected functions are excluded.
312
440
  """
313
441
  reflection = ReflectionModule(self.module_name)
314
442
  async_funcs = reflection.getProtectedAsyncFunctions()
315
- self.assertIn('_protectedAsyncFunction', async_funcs)
316
- self.assertNotIn('_protectedSyncFunction', async_funcs)
443
+ self.assertIn('_protectedAsyncFunction', async_funcs) # Protected async function should be included
444
+ self.assertNotIn('_protectedSyncFunction', async_funcs) # Protected sync function should be excluded
317
445
 
318
446
  async def testGetPrivateFunctions(self):
319
447
  """
320
- Test that ReflectionModule.getPrivateFunctions correctly identifies private functions.
448
+ Test retrieval of private functions only.
321
449
 
322
- This test verifies that:
323
- - Private functions (e.g., '__privateSyncFunction', '__privateAsyncFunction') are included in the returned list.
324
- - Public functions (e.g., 'publicSyncFunction') are not included in the returned list.
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.
325
458
  """
326
459
  reflection = ReflectionModule(self.module_name)
327
460
  private_funcs = reflection.getPrivateFunctions()
328
- self.assertIn('__privateSyncFunction', private_funcs)
329
- self.assertIn('__privateAsyncFunction', private_funcs)
330
- self.assertNotIn('publicSyncFunction', private_funcs)
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
331
464
 
332
465
  async def testGetPrivateSyncFunctions(self):
333
466
  """
334
- Test that the getPrivateSyncFunctions method of ReflectionModule returns a list containing
335
- the names of private synchronous functions, specifically including '__privateSyncFunction'
336
- and excluding '__privateAsyncFunction'.
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.
337
476
  """
338
477
  reflection = ReflectionModule(self.module_name)
339
478
  sync_funcs = reflection.getPrivateSyncFunctions()
340
- self.assertIn('__privateSyncFunction', sync_funcs)
341
- self.assertNotIn('__privateAsyncFunction', sync_funcs)
479
+ self.assertIn('__privateSyncFunction', sync_funcs) # Private sync function should be included
480
+ self.assertNotIn('__privateAsyncFunction', sync_funcs) # Private async function should be excluded
342
481
 
343
482
  async def testGetPrivateAsyncFunctions(self):
344
483
  """
345
- Tests that the ReflectionModule correctly identifies private asynchronous functions.
484
+ Test retrieval of private asynchronous functions only.
346
485
 
347
- This test verifies that:
348
- - The list of private async functions returned by `getPrivateAsyncFunctions()` includes '__privateAsyncFunction'.
349
- - The list does not include '__privateSyncFunction', ensuring only async functions are returned.
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.
350
493
  """
351
494
  reflection = ReflectionModule(self.module_name)
352
495
  async_funcs = reflection.getPrivateAsyncFunctions()
353
- self.assertIn('__privateAsyncFunction', async_funcs)
354
- self.assertNotIn('__privateSyncFunction', async_funcs)
496
+ self.assertIn('__privateAsyncFunction', async_funcs) # Private async function should be included
497
+ self.assertNotIn('__privateSyncFunction', async_funcs) # Private sync function should be excluded
355
498
 
356
499
  async def testGetImports(self):
357
500
  """
358
- Test that the `getImports` method of the `ReflectionModule` correctly retrieves the list of imported modules.
359
- Asserts that 'asyncio' is present in the returned imports.
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.
360
510
  """
361
511
  reflection = ReflectionModule(self.module_name)
362
512
  imports = reflection.getImports()
363
- self.assertIn('asyncio', imports)
513
+ self.assertIn('asyncio', imports) # asyncio module should be imported
364
514
 
365
515
  async def testGetFile(self):
366
516
  """
367
- Tests that the `getFile` method of the `ReflectionModule` returns the correct file path.
517
+ Test retrieval of the module's file path.
368
518
 
369
- This test creates an instance of `ReflectionModule` with the specified module name,
370
- retrieves the file path using `getFile`, and asserts that the returned path ends with
371
- 'fake_reflect_instance.py', indicating the correct file is being referenced.
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.
372
526
  """
373
527
  reflection = ReflectionModule(self.module_name)
374
528
  file_path = reflection.getFile()
375
- self.assertTrue(file_path.endswith('fake_reflect_instance.py'))
529
+ self.assertTrue(file_path.endswith('fake_reflect_instance.py')) # Path should end with expected filename
376
530
 
377
531
  async def testGetSourceCode(self):
378
532
  """
379
- Tests that the `getSourceCode` method of the ReflectionModule retrieves the source code
380
- containing specific elements such as 'PUBLIC_CONSTANT' and the function definition
381
- 'def publicSyncFunction'. Asserts that these elements are present in the returned code.
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.
382
542
  """
383
543
  reflection = ReflectionModule(self.module_name)
384
544
  code = reflection.getSourceCode()
385
- self.assertIn('PUBLIC_CONSTANT', code)
386
- self.assertIn('def publicSyncFunction', code)
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
387
547
 
388
548
  async def test_invalid_module_name(self):
389
549
  """
390
- Test that ReflectionModule raises a ReflectionTypeError when initialized with an invalid module name,
391
- such as an empty string or a non-existent module path.
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.
392
560
  """
561
+ # Test empty string module name
393
562
  with self.assertRaises(ReflectionTypeError):
394
563
  ReflectionModule('')
564
+
565
+ # Test non-existent module path
395
566
  with self.assertRaises(ReflectionTypeError):
396
567
  ReflectionModule('nonexistent.module.name')