orionis 0.306.0__py3-none-any.whl → 0.307.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.
@@ -0,0 +1,842 @@
1
+ from orionis.services.introspection.concretes.reflection_concrete import ReflectionConcrete
2
+ from orionis.services.introspection.dependencies.entities.class_dependencies import ClassDependency
3
+ from tests.services.inspection.reflection.mock.fake_reflect_instance import FakeClass
4
+ from orionis.unittesting import TestCase
5
+
6
+ class TestServiceReflectionConcrete(TestCase):
7
+
8
+ async def testGetInstance(self):
9
+ """
10
+ Tests that the ReflectionConcrete class correctly creates an instance of FakeClass
11
+ using the getInstance method.
12
+
13
+ Asserts:
14
+ The returned instance is of type FakeClass.
15
+ """
16
+ reflect = ReflectionConcrete(FakeClass)
17
+ instance = reflect.getInstance()
18
+ self.assertIsInstance(instance, FakeClass)
19
+
20
+ async def testGetClass(self):
21
+ """
22
+ Tests that the ReflectionConcrete.getClass() method returns the correct class object.
23
+
24
+ This test creates a ReflectionConcrete instance with FakeClass, calls getClass(),
25
+ and asserts that the returned class is FakeClass.
26
+ """
27
+ reflect = ReflectionConcrete(FakeClass)
28
+ cls = reflect.getClass()
29
+ self.assertEqual(cls, FakeClass)
30
+
31
+ async def testGetClassName(self):
32
+ """
33
+ Tests that the ReflectionConcrete class correctly retrieves the name of the provided class.
34
+
35
+ This test creates a ReflectionConcrete instance using the FakeClass,
36
+ calls the getClassName() method, and asserts that the returned class name
37
+ matches the expected string 'FakeClass'.
38
+ """
39
+ reflect = ReflectionConcrete(FakeClass)
40
+ class_name = reflect.getClassName()
41
+ self.assertEqual(class_name, 'FakeClass')
42
+
43
+ async def testGetModuleName(self):
44
+ """
45
+ Tests that the getModuleName method of the ReflectionConcrete class returns the correct module name
46
+ for the provided FakeClass. Asserts that the returned module name matches the expected string
47
+ 'tests.services.inspection.reflection.mock.fake_reflect_instance'.
48
+ """
49
+ reflect = ReflectionConcrete(FakeClass)
50
+ module_name = reflect.getModuleName()
51
+ self.assertEqual(module_name, 'tests.services.inspection.reflection.mock.fake_reflect_instance')
52
+
53
+ async def testGetModuleWithClassName(self):
54
+ """
55
+ Tests that the `getModuleWithClassName` method of the `ReflectionConcrete` class
56
+ returns the fully qualified module and class name for the given `FakeClass`.
57
+
58
+ Asserts:
59
+ The returned string matches the expected module path and class name:
60
+ 'tests.services.inspection.reflection.mock.fake_reflect_instance.FakeClass'
61
+ """
62
+ reflect = ReflectionConcrete(FakeClass)
63
+ module_with_class_name = reflect.getModuleWithClassName()
64
+ self.assertEqual(module_with_class_name, 'tests.services.inspection.reflection.mock.fake_reflect_instance.FakeClass')
65
+
66
+ async def testGetDocstring(self):
67
+ """
68
+ Tests that the getDocstring method of ReflectionConcrete returns the correct docstring
69
+ for the given class (FakeClass) by comparing it to the class's __doc__ attribute.
70
+ """
71
+ reflect = ReflectionConcrete(FakeClass)
72
+ docstring = reflect.getDocstring()
73
+ self.assertEqual(docstring, FakeClass.__doc__)
74
+
75
+ async def testGetBaseClasses(self):
76
+ """
77
+ Tests that the getBaseClasses method of the ReflectionConcrete class returns the base classes of the given class.
78
+
79
+ This test creates a ReflectionConcrete instance for the FakeClass, retrieves its base classes using getBaseClasses(),
80
+ and asserts that the direct base class of FakeClass is included in the returned list.
81
+ """
82
+ reflect = ReflectionConcrete(FakeClass)
83
+ base_classes = reflect.getBaseClasses()
84
+ self.assertIn(FakeClass.__base__, base_classes)
85
+
86
+ async def testGetSourceCode(self):
87
+ """
88
+ Tests that the `getSourceCode` method of the `ReflectionConcrete` class
89
+ correctly retrieves the source code of the `FakeClass` class.
90
+
91
+ The test asserts that the returned source code starts with the expected
92
+ class definition line.
93
+ """
94
+ reflect = ReflectionConcrete(FakeClass)
95
+ source_code = reflect.getSourceCode()
96
+ self.assertTrue(source_code.startswith('class FakeClass'))
97
+
98
+ async def testGetFile(self):
99
+ """
100
+ Tests that the `getFile` method of the `ReflectionConcrete` class returns the correct file path
101
+ for the given `FakeClass`. Asserts that the returned file path ends with 'fake_reflect_instance.py'.
102
+ """
103
+ reflect = ReflectionConcrete(FakeClass)
104
+ file_path = reflect.getFile()
105
+ self.assertTrue(file_path.endswith('fake_reflect_instance.py'))
106
+
107
+ async def testGetAnnotations(self):
108
+ """
109
+ Tests that the `getAnnotations` method of the `ReflectionConcrete` class
110
+ correctly retrieves the annotations of the `FakeClass`, ensuring that
111
+ 'public_attr' is present in the returned annotations.
112
+ """
113
+ reflect = ReflectionConcrete(FakeClass)
114
+ annotations = reflect.getAnnotations()
115
+ self.assertIn('public_attr', annotations)
116
+
117
+ async def testHasAttribute(self):
118
+ """
119
+ Test whether the ReflectionConcrete class correctly identifies the presence or absence of attributes on the target class.
120
+
121
+ This test verifies that:
122
+ - `hasAttribute('public_attr')` returns True for an existing attribute.
123
+ - `hasAttribute('non_existent_attr')` returns False for a non-existent attribute.
124
+ """
125
+ reflect = ReflectionConcrete(FakeClass)
126
+ self.assertTrue(reflect.hasAttribute('public_attr'))
127
+ self.assertFalse(reflect.hasAttribute('non_existent_attr'))
128
+
129
+ async def testGetAttribute(self):
130
+ """
131
+ Tests the `getAttribute` method of the `ReflectionConcrete` class.
132
+
133
+ This test verifies that:
134
+ - Retrieving an existing attribute ('public_attr') from `FakeClass` returns the correct value (42).
135
+ - Retrieving a non-existent attribute ('non_existent_attr') returns `None`.
136
+ """
137
+ reflect = ReflectionConcrete(FakeClass)
138
+ self.assertEqual(reflect.getAttribute('public_attr'), 42)
139
+ self.assertIsNone(reflect.getAttribute('non_existent_attr'))
140
+
141
+ async def testSetAttribute(self):
142
+ """
143
+ Test the setAttribute and getAttribute methods of the ReflectionConcrete class.
144
+
145
+ This test verifies that attributes (including public, protected, and private) can be set and retrieved correctly
146
+ using the setAttribute and getAttribute methods. It checks for:
147
+ - Setting and getting a public attribute ('name').
148
+ - Setting and getting a protected attribute ('_version').
149
+ - Setting and getting a private attribute ('__python').
150
+ """
151
+ reflect = ReflectionConcrete(FakeClass)
152
+ self.assertTrue(reflect.setAttribute('name', 'Orionis Framework'))
153
+ self.assertEqual(reflect.getAttribute('name'), 'Orionis Framework')
154
+ self.assertTrue(reflect.setAttribute('_version', '1.x'))
155
+ self.assertEqual(reflect.getAttribute('_version'), '1.x')
156
+ self.assertTrue(reflect.setAttribute('__python', '3.13+'))
157
+ self.assertEqual(reflect.getAttribute('__python'), '3.13+')
158
+
159
+ async def testRemoveAttribute(self):
160
+ """
161
+ Tests the removal of an attribute from a reflected class instance.
162
+
163
+ This test verifies that:
164
+ - An attribute ('new_attr') can be set on the reflected class instance.
165
+ - The attribute can be successfully removed using `removeAttribute`.
166
+ - After removal, the attribute no longer exists on the instance, as confirmed by `hasAttribute`.
167
+ """
168
+ reflect = ReflectionConcrete(FakeClass)
169
+ reflect.setAttribute('new_attr', 100)
170
+ self.assertTrue(reflect.removeAttribute('new_attr'))
171
+ self.assertFalse(reflect.hasAttribute('new_attr'))
172
+
173
+ async def testGetAttributes(self):
174
+ """
175
+ Tests that the ReflectionConcrete.getAttributes() method correctly retrieves all attribute names
176
+ from the FakeClass, including public, protected, and private attributes.
177
+
178
+ Asserts:
179
+ - 'public_attr' is present in the returned attributes.
180
+ - '_protected_attr' is present in the returned attributes.
181
+ - '__private_attr' is present in the returned attributes.
182
+ """
183
+ reflect = ReflectionConcrete(FakeClass)
184
+ attributes = reflect.getAttributes()
185
+ self.assertIn('public_attr', attributes)
186
+ self.assertIn('_protected_attr', attributes)
187
+ self.assertIn('__private_attr', attributes)
188
+
189
+ async def testGetPublicAttributes(self):
190
+ """
191
+ Test that the getPublicAttributes method of ReflectionConcrete correctly retrieves only the public attributes of FakeClass.
192
+
193
+ This test verifies that:
194
+ - 'public_attr' is included in the list of public attributes.
195
+ - '_protected_attr' and '__private_attr' are not included in the list of public attributes.
196
+ """
197
+ reflect = ReflectionConcrete(FakeClass)
198
+ public_attributes = reflect.getPublicAttributes()
199
+ self.assertIn('public_attr', public_attributes)
200
+ self.assertNotIn('_protected_attr', public_attributes)
201
+ self.assertNotIn('__private_attr', public_attributes)
202
+
203
+ async def testGetProtectedAttributes(self):
204
+ """
205
+ Test that the getProtectedAttributes method of ReflectionConcrete correctly identifies protected attributes.
206
+
207
+ This test verifies that:
208
+ - The protected attribute '_protected_attr' is included in the returned list.
209
+ - The public attribute 'public_attr' is not included.
210
+ - The private attribute '__private_attr' is not included.
211
+ """
212
+ reflect = ReflectionConcrete(FakeClass)
213
+ protected_attributes = reflect.getProtectedAttributes()
214
+ self.assertIn('_protected_attr', protected_attributes)
215
+ self.assertNotIn('public_attr', protected_attributes)
216
+ self.assertNotIn('__private_attr', protected_attributes)
217
+
218
+ async def testGetPrivateAttributes(self):
219
+ """
220
+ Test that the getPrivateAttributes method of ReflectionConcrete correctly identifies private attributes
221
+ of the FakeClass. Ensures that '__private_attr' is included in the result, while 'public_attr' and
222
+ '_protected_attr' are not.
223
+ """
224
+ reflect = ReflectionConcrete(FakeClass)
225
+ private_attributes = reflect.getPrivateAttributes()
226
+ self.assertIn('__private_attr', private_attributes)
227
+ self.assertNotIn('public_attr', private_attributes)
228
+ self.assertNotIn('_protected_attr', private_attributes)
229
+
230
+ async def testGetDunderAttributes(self):
231
+ """
232
+ Tests that the getDunderAttributes method of the ReflectionConcrete class
233
+ correctly retrieves dunder (double underscore) attributes from the FakeClass.
234
+ Asserts that the '__dd__' attribute is present in the returned list of dunder attributes.
235
+ """
236
+ reflect = ReflectionConcrete(FakeClass)
237
+ dunder_attributes = reflect.getDunderAttributes()
238
+ self.assertIn('__dd__', dunder_attributes)
239
+
240
+ async def testGetMagicAttributes(self):
241
+ """
242
+ Tests that the `getMagicAttributes` method of the `ReflectionConcrete` class
243
+ correctly retrieves magic (dunder) attributes from the `FakeClass`.
244
+
245
+ Asserts that the magic attribute '__dd__' is present in the returned list of attributes.
246
+ """
247
+ reflect = ReflectionConcrete(FakeClass)
248
+ magic_attributes = reflect.getMagicAttributes()
249
+ self.assertIn('__dd__', magic_attributes)
250
+
251
+ async def testHasMethod(self):
252
+ """
253
+ Tests the 'hasMethod' function of the ReflectionConcrete class.
254
+
255
+ This test verifies that 'hasMethod' correctly identifies whether a given method name exists
256
+ on the FakeClass. It asserts that 'instanceSyncMethod' is present and that a non-existent
257
+ method returns False.
258
+ """
259
+ reflect = ReflectionConcrete(FakeClass)
260
+ self.assertTrue(reflect.hasMethod('instanceSyncMethod'))
261
+ self.assertFalse(reflect.hasMethod('non_existent_method'))
262
+
263
+ async def testCallMethod(self):
264
+ """
265
+ Tests the 'callMethod' function of the ReflectionConcrete class by invoking the 'instanceSyncMethod'
266
+ on a FakeClass instance with arguments 2 and 3, and asserts that the result is 5.
267
+ """
268
+ reflect = ReflectionConcrete(FakeClass)
269
+ reflect.getInstance() # Ensure instance is created
270
+ result = reflect.callMethod('instanceSyncMethod', 2, 3)
271
+ self.assertEqual(result, 5)
272
+
273
+ async def testCallAsyncMethod(self):
274
+ """
275
+ Tests that the ReflectionConcrete class can correctly call an asynchronous instance method.
276
+ Ensures that:
277
+ - An instance of FakeClass is created via ReflectionConcrete.
278
+ - The asynchronous method 'instanceAsyncMethod' is called with arguments 2 and 3.
279
+ - The result of the method call is awaited and checked to be equal to 5.
280
+ """
281
+ reflect = ReflectionConcrete(FakeClass)
282
+ reflect.getInstance() # Ensure instance is created
283
+ result = await reflect.callMethod('instanceAsyncMethod', 2, 3)
284
+ self.assertEqual(result, 5)
285
+
286
+ async def testSetMethod(self):
287
+ """
288
+ Tests the ability of the ReflectionConcrete class to dynamically set and call both synchronous and asynchronous methods on an instance of FakeClass.
289
+ This test:
290
+ - Defines a synchronous and an asynchronous mock method.
291
+ - Sets these methods on a ReflectionConcrete instance.
292
+ - Calls the methods using callMethod, verifying correct results for both sync and async cases.
293
+ Asserts:
294
+ - The synchronous method returns the correct sum.
295
+ - The asynchronous method returns the correct sum after awaiting.
296
+ """
297
+ def mockSyncMethod(cls:FakeClass, num1, num2):
298
+ return num1 + num2
299
+
300
+ async def mockAsyncMethod(cls:FakeClass, num1, num2):
301
+ import asyncio
302
+ await asyncio.sleep(0.1)
303
+ return num1 + num2
304
+
305
+ reflect = ReflectionConcrete(FakeClass)
306
+ reflect.getInstance()
307
+ reflect.setMethod('mockSyncMethodConcrete', mockSyncMethod)
308
+ reflect.setMethod('mockAsyncMethodConcrete', mockAsyncMethod)
309
+ sync_result = reflect.callMethod('mockSyncMethodConcrete', 2, 3)
310
+ async_result = await reflect.callMethod('mockAsyncMethodConcrete', 2, 3)
311
+ self.assertEqual(sync_result, 5)
312
+ self.assertEqual(async_result, 5)
313
+
314
+ async def testRemoveMethod(self):
315
+ """
316
+ Test the removal of a dynamically added private method from a reflected class instance.
317
+ This test:
318
+ - Defines a protected and a private method.
319
+ - Adds the private method to the reflected instance using `setMethod`.
320
+ - Asserts that the method exists after addition.
321
+ - Removes the method using `removeMethod`.
322
+ - Asserts that the method no longer exists after removal.
323
+ """
324
+ def _testProtectedMethod(cls:FakeClass, x, y):
325
+ return x + y
326
+
327
+ def __testPrivateMethod(cls:FakeClass, x, y):
328
+ return x + y
329
+
330
+ reflect = ReflectionConcrete(FakeClass)
331
+ reflect.getInstance()
332
+ reflect.setMethod('__testPrivateMethod', __testPrivateMethod)
333
+ self.assertTrue(reflect.hasMethod('__testPrivateMethod'))
334
+ reflect.removeMethod('__testPrivateMethod')
335
+ self.assertFalse(reflect.hasMethod('__testPrivateMethod'))
336
+
337
+ async def testGetMethodSignature(self):
338
+ """
339
+ Tests that the ReflectionConcrete.getMethodSignature method correctly retrieves
340
+ the signature of the 'instanceSyncMethod' from the FakeClass.
341
+
342
+ Asserts that the returned signature string matches the expected format:
343
+ '(self, x: int, y: int) -> int'.
344
+ """
345
+ reflect = ReflectionConcrete(FakeClass)
346
+ signature = reflect.getMethodSignature('instanceSyncMethod')
347
+ self.assertEqual(str(signature), '(self, x: int, y: int) -> int')
348
+
349
+ async def testGetMethods(self):
350
+ """
351
+ Test that the getMethods function of the ReflectionConcrete class correctly retrieves
352
+ the method names of the FakeClass, including both synchronous and asynchronous instance methods.
353
+ """
354
+ reflect = ReflectionConcrete(FakeClass)
355
+ methods = reflect.getMethods()
356
+ self.assertIn('instanceSyncMethod', methods)
357
+ self.assertIn('instanceAsyncMethod', methods)
358
+
359
+ async def testGetPublicMethods(self):
360
+ """
361
+ Test that the getPublicMethods method of ReflectionConcrete returns only the public methods of the given class.
362
+
363
+ This test verifies that:
364
+ - Public methods (e.g., 'instanceSyncMethod') are included in the returned list.
365
+ - Protected methods (prefixed with a single underscore) are not included.
366
+ - Private methods (prefixed with double underscores) are not included.
367
+ """
368
+ reflect = ReflectionConcrete(FakeClass)
369
+ public_methods = reflect.getPublicMethods()
370
+ self.assertIn('instanceSyncMethod', public_methods)
371
+ self.assertNotIn('_protected_method', public_methods)
372
+ self.assertNotIn('__private_method', public_methods)
373
+
374
+ async def testGetPublicSyncMethods(self):
375
+ """
376
+ Test that ReflectionConcrete.getPublicSyncMethods() returns only public synchronous methods of the given class.
377
+
378
+ This test verifies that:
379
+ - Public synchronous methods (e.g., 'instanceSyncMethod') are included in the returned list.
380
+ - Protected methods (prefixed with a single underscore) are not included.
381
+ - Private methods (prefixed with double underscores) are not included.
382
+ """
383
+ reflect = ReflectionConcrete(FakeClass)
384
+ public_sync_methods = reflect.getPublicSyncMethods()
385
+ self.assertIn('instanceSyncMethod', public_sync_methods)
386
+ self.assertNotIn('_protected_method', public_sync_methods)
387
+ self.assertNotIn('__private_method', public_sync_methods)
388
+
389
+ async def testGetPublicAsyncMethods(self):
390
+ """
391
+ Test that ReflectionConcrete.getPublicAsyncMethods() correctly identifies public asynchronous methods
392
+ of the FakeClass, ensuring that protected and private async methods are excluded from the result.
393
+ """
394
+ reflect = ReflectionConcrete(FakeClass)
395
+ public_async_methods = reflect.getPublicAsyncMethods()
396
+ self.assertIn('instanceAsyncMethod', public_async_methods)
397
+ self.assertNotIn('_protected_async_method', public_async_methods)
398
+ self.assertNotIn('__private_async_method', public_async_methods)
399
+
400
+ async def testGetProtectedMethods(self):
401
+ """
402
+ Test that the getProtectedMethods method of ReflectionConcrete correctly identifies protected methods
403
+ in the FakeClass. Ensures that '_protectedAsyncMethod' is included, while public and private methods
404
+ are excluded from the result.
405
+ """
406
+ reflect = ReflectionConcrete(FakeClass)
407
+ protected_methods = reflect.getProtectedMethods()
408
+ self.assertIn('_protectedAsyncMethod', protected_methods)
409
+ self.assertNotIn('instanceSyncMethod', protected_methods)
410
+ self.assertNotIn('__privateSyncMethod', protected_methods)
411
+
412
+ async def testGetProtectedSyncMethods(self):
413
+ """
414
+ Test that the getProtectedSyncMethods method of ReflectionConcrete correctly identifies
415
+ protected synchronous methods in the FakeClass.
416
+
417
+ This test verifies that:
418
+ - The protected synchronous method '_protectedsyncMethod' is included in the result.
419
+ - The asynchronous method 'instanceAsyncMethod' is not included.
420
+ - The private synchronous method '__privateSyncMethod' is not included.
421
+ """
422
+ reflect = ReflectionConcrete(FakeClass)
423
+ protected_sync_methods = reflect.getProtectedSyncMethods()
424
+ self.assertIn('_protectedsyncMethod', protected_sync_methods)
425
+ self.assertNotIn('instanceAsyncMethod', protected_sync_methods)
426
+ self.assertNotIn('__privateSyncMethod', protected_sync_methods)
427
+
428
+ async def testGetProtectedAsyncMethods(self):
429
+ """
430
+ Tests that the getProtectedAsyncMethods method of ReflectionConcrete returns only protected async methods of FakeClass.
431
+
432
+ This test creates a ReflectionConcrete object initialized with FakeClass,
433
+ calls getProtectedAsyncMethods, and asserts that the returned list contains only protected async methods.
434
+ """
435
+ reflect = ReflectionConcrete(FakeClass)
436
+ protected_async_methods = reflect.getProtectedAsyncMethods()
437
+ self.assertIn('_protectedAsyncMethod', protected_async_methods)
438
+ self.assertNotIn('instanceSyncMethod', protected_async_methods)
439
+ self.assertNotIn('__privateSyncMethod', protected_async_methods)
440
+
441
+ async def testGetPrivateMethods(self):
442
+ """
443
+ Tests that the getPrivateMethods method of ReflectionConcrete returns only private methods of FakeClass.
444
+
445
+ This test creates a ReflectionConcrete object initialized with FakeClass,
446
+ calls getPrivateMethods, and asserts that the returned list contains only private methods.
447
+ """
448
+ reflect = ReflectionConcrete(FakeClass)
449
+ private_methods = reflect.getPrivateMethods()
450
+ self.assertIn('__privateSyncMethod', private_methods)
451
+ self.assertNotIn('instanceSyncMethod', private_methods)
452
+ self.assertNotIn('_protectedAsyncMethod', private_methods)
453
+
454
+ async def testGetPrivateSyncMethods(self):
455
+ """
456
+ Tests that the getPrivateSyncMethods method of ReflectionConcrete returns only private sync methods of FakeClass.
457
+
458
+ This test creates a ReflectionConcrete object initialized with FakeClass,
459
+ calls getPrivateSyncMethods, and asserts that the returned list contains only private sync methods.
460
+ """
461
+ reflect = ReflectionConcrete(FakeClass)
462
+ private_sync_methods = reflect.getPrivateSyncMethods()
463
+ self.assertIn('__privateSyncMethod', private_sync_methods)
464
+ self.assertNotIn('instanceAsyncMethod', private_sync_methods)
465
+ self.assertNotIn('_protectedAsyncMethod', private_sync_methods)
466
+
467
+ async def testGetPrivateAsyncMethods(self):
468
+ """
469
+ Tests that the getPrivateAsyncMethods method of ReflectionConcrete returns only private async methods of FakeClass.
470
+
471
+ This test creates a ReflectionConcrete object initialized with FakeClass,
472
+ calls getPrivateAsyncMethods, and asserts that the returned list contains only private async methods.
473
+ """
474
+ reflect = ReflectionConcrete(FakeClass)
475
+ private_async_methods = reflect.getPrivateAsyncMethods()
476
+ self.assertIn('__privateAsyncMethod', private_async_methods)
477
+ self.assertNotIn('instanceSyncMethod', private_async_methods)
478
+ self.assertNotIn('_protectedAsyncMethod', private_async_methods)
479
+
480
+ async def testGetPublicClassMethods(self):
481
+ """
482
+ Tests that the getPublicClassMethods method of ReflectionConcrete returns only public class methods of FakeClass.
483
+
484
+ This test creates a ReflectionConcrete object initialized with FakeClass,
485
+ calls getPublicClassMethods, and asserts that the returned list contains only public class methods.
486
+ """
487
+ reflect = ReflectionConcrete(FakeClass)
488
+ public_class_methods = reflect.getPublicClassMethods()
489
+ self.assertIn('classSyncMethod', public_class_methods)
490
+ self.assertNotIn('_protected_class_method', public_class_methods)
491
+ self.assertNotIn('__private_class_method', public_class_methods)
492
+
493
+ async def testGetPublicClassSyncMethods(self):
494
+ """
495
+ Tests that the getPublicClassSyncMethods method of ReflectionConcrete returns only public class sync methods of FakeClass.
496
+
497
+ This test creates a ReflectionConcrete object initialized with FakeClass,
498
+ calls getPublicClassSyncMethods, and asserts that the returned list contains only public class sync methods.
499
+ """
500
+ reflect = ReflectionConcrete(FakeClass)
501
+ public_class_sync_methods = reflect.getPublicClassSyncMethods()
502
+ self.assertIn('classSyncMethod', public_class_sync_methods)
503
+ self.assertNotIn('_protected_class_method', public_class_sync_methods)
504
+ self.assertNotIn('__private_class_method', public_class_sync_methods)
505
+
506
+ async def testGetPublicClassAsyncMethods(self):
507
+ """
508
+ Tests that the getPublicClassAsyncMethods method of ReflectionConcrete returns only public class async methods of FakeClass.
509
+
510
+ This test creates a ReflectionConcrete object initialized with FakeClass,
511
+ calls getPublicClassAsyncMethods, and asserts that the returned list contains only public class async methods.
512
+ """
513
+ reflect = ReflectionConcrete(FakeClass)
514
+ public_class_async_methods = reflect.getPublicClassAsyncMethods()
515
+ self.assertIn('classAsyncMethod', public_class_async_methods)
516
+ self.assertNotIn('_protected_class_async_method', public_class_async_methods)
517
+ self.assertNotIn('__private_class_async_method', public_class_async_methods)
518
+
519
+ async def testGetProtectedClassMethods(self):
520
+ """
521
+ Tests that the getProtectedClassMethods method of ReflectionConcrete returns only protected class methods of FakeClass.
522
+
523
+ This test creates a ReflectionConcrete object initialized with FakeClass,
524
+ calls getProtectedClassMethods, and asserts that the returned list contains only protected class methods.
525
+ """
526
+ reflect = ReflectionConcrete(FakeClass)
527
+ protected_class_methods = reflect.getProtectedClassMethods()
528
+ self.assertIn('_classMethodProtected', protected_class_methods)
529
+ self.assertNotIn('classSyncMethod', protected_class_methods)
530
+ self.assertNotIn('__classMethodPrivate', protected_class_methods)
531
+
532
+ async def testGetProtectedClassSyncMethods(self):
533
+ """
534
+ Tests that the getProtectedClassSyncMethods method of ReflectionConcrete returns only protected class sync methods of FakeClass.
535
+
536
+ This test creates a ReflectionConcrete object initialized with FakeClass,
537
+ calls getProtectedClassSyncMethods, and asserts that the returned list contains only protected class sync methods.
538
+ """
539
+ reflect = ReflectionConcrete(FakeClass)
540
+ protected_class_sync_methods = reflect.getProtectedClassSyncMethods()
541
+ self.assertIn('_classMethodProtected', protected_class_sync_methods)
542
+ self.assertNotIn('classSyncMethod', protected_class_sync_methods)
543
+ self.assertNotIn('__classSyncMethodPrivate', protected_class_sync_methods)
544
+
545
+ async def testGetProtectedClassAsyncMethods(self):
546
+ """
547
+ Tests that the getProtectedClassAsyncMethods method of ReflectionConcrete returns only protected class async methods of FakeClass.
548
+
549
+ This test creates a ReflectionConcrete object initialized with FakeClass,
550
+ calls getProtectedClassAsyncMethods, and asserts that the returned list contains only protected class async methods.
551
+ """
552
+ reflect = ReflectionConcrete(FakeClass)
553
+ protected_class_async_methods = reflect.getProtectedClassAsyncMethods()
554
+ self.assertIn('_classAsyncMethodProtected', protected_class_async_methods)
555
+ self.assertNotIn('classAsyncMethod', protected_class_async_methods)
556
+ self.assertNotIn('__classAsyncMethodPrivate', protected_class_async_methods)
557
+
558
+ async def testGetPrivateClassMethods(self):
559
+ """
560
+ Tests that the getPrivateClassMethods method of ReflectionConcrete returns only private class methods of FakeClass.
561
+
562
+ This test creates a ReflectionConcrete object initialized with FakeClass,
563
+ calls getPrivateClassMethods, and asserts that the returned list contains only private class methods.
564
+ """
565
+ reflect = ReflectionConcrete(FakeClass)
566
+ private_class_methods = reflect.getPrivateClassMethods()
567
+ self.assertIn('__classMethodPrivate', private_class_methods)
568
+ self.assertNotIn('classSyncMethod', private_class_methods)
569
+ self.assertNotIn('_classMethodProtected', private_class_methods)
570
+
571
+ async def testGetPrivateClassSyncMethods(self):
572
+ """
573
+ Tests that the getPrivateClassSyncMethods method of ReflectionConcrete returns only private class sync methods of FakeClass.
574
+
575
+ This test creates a ReflectionConcrete object initialized with FakeClass,
576
+ calls getPrivateClassSyncMethods, and asserts that the returned list contains only private class sync methods.
577
+ """
578
+ reflect = ReflectionConcrete(FakeClass)
579
+ private_class_methods = reflect.getPrivateClassSyncMethods()
580
+ self.assertIn('__classMethodPrivate', private_class_methods)
581
+ self.assertNotIn('classSyncMethod', private_class_methods)
582
+ self.assertNotIn('_classMethodProtected', private_class_methods)
583
+
584
+ async def testGetPrivateClassAsyncMethods(self):
585
+ """
586
+ Tests that the getPrivateClassAsyncMethods method of ReflectionConcrete returns only private class async methods of FakeClass.
587
+
588
+ This test creates a ReflectionConcrete object initialized with FakeClass,
589
+ calls getPrivateClassAsyncMethods, and asserts that the returned list contains only private class async methods.
590
+ """
591
+ reflect = ReflectionConcrete(FakeClass)
592
+ private_class_async_methods = reflect.getPrivateClassAsyncMethods()
593
+ self.assertIn('__classAsyncMethodPrivate', private_class_async_methods)
594
+ self.assertNotIn('classAsyncMethod', private_class_async_methods)
595
+ self.assertNotIn('_classAsyncMethodProtected', private_class_async_methods)
596
+
597
+ async def testGetPublicStaticMethods(self):
598
+ """
599
+ Tests that the getPublicStaticMethods method of ReflectionConcrete returns only public static methods of FakeClass.
600
+
601
+ This test creates a ReflectionConcrete object initialized with FakeClass,
602
+ calls getPublicStaticMethods, and asserts that the returned list contains only public static methods.
603
+ """
604
+ reflect = ReflectionConcrete(FakeClass)
605
+ public_static_methods = reflect.getPublicStaticMethods()
606
+ self.assertIn('staticMethod', public_static_methods)
607
+ self.assertIn('staticAsyncMethod', public_static_methods)
608
+ self.assertNotIn('static_async_method', public_static_methods)
609
+
610
+ async def testGetPublicStaticSyncMethods(self):
611
+ """
612
+ Tests that the getPublicStaticSyncMethods method of ReflectionConcrete returns only public static sync methods of FakeClass.
613
+
614
+ This test creates a ReflectionConcrete object initialized with FakeClass,
615
+ calls getPublicStaticSyncMethods, and asserts that the returned list contains only public static sync methods.
616
+ """
617
+ reflect = ReflectionConcrete(FakeClass)
618
+ public_static_sync_methods = reflect.getPublicStaticSyncMethods()
619
+ self.assertIn('staticMethod', public_static_sync_methods)
620
+ self.assertNotIn('staticAsyncMethod', public_static_sync_methods)
621
+ self.assertNotIn('static_async_method', public_static_sync_methods)
622
+
623
+ async def testGetPublicStaticAsyncMethods(self):
624
+ """
625
+ Tests that the getPublicStaticAsyncMethods method of ReflectionConcrete returns only public static async methods of FakeClass.
626
+
627
+ This test creates a ReflectionConcrete object initialized with FakeClass,
628
+ calls getPublicStaticAsyncMethods, and asserts that the returned list contains only public static async methods.
629
+ """
630
+ reflect = ReflectionConcrete(FakeClass)
631
+ public_static_async_methods = reflect.getPublicStaticAsyncMethods()
632
+ self.assertIn('staticAsyncMethod', public_static_async_methods)
633
+ self.assertNotIn('staticMethod', public_static_async_methods)
634
+ self.assertNotIn('static_async_method', public_static_async_methods)
635
+
636
+ async def testGetProtectedStaticMethods(self):
637
+ """
638
+ Tests that the getProtectedStaticMethods method of ReflectionConcrete returns only protected static methods of FakeClass.
639
+
640
+ This test creates a ReflectionConcrete object initialized with FakeClass,
641
+ calls getProtectedStaticMethods, and asserts that the returned list contains only protected static methods.
642
+ """
643
+ reflect = ReflectionConcrete(FakeClass)
644
+ protected_static_methods = reflect.getProtectedStaticMethods()
645
+ self.assertIn('_staticMethodProtected', protected_static_methods)
646
+ self.assertNotIn('staticMethod', protected_static_methods)
647
+ self.assertNotIn('__staticMethodPrivate', protected_static_methods)
648
+
649
+ async def testGetProtectedStaticSyncMethods(self):
650
+ """
651
+ Tests that the getProtectedStaticSyncMethods method of ReflectionConcrete returns only protected static sync methods of FakeClass.
652
+
653
+ This test creates a ReflectionConcrete object initialized with FakeClass,
654
+ calls getProtectedStaticSyncMethods, and asserts that the returned list contains only protected static sync methods.
655
+ """
656
+ reflect = ReflectionConcrete(FakeClass)
657
+ protected_static_sync_methods = reflect.getProtectedStaticSyncMethods()
658
+ self.assertIn('_staticMethodProtected', protected_static_sync_methods)
659
+ self.assertNotIn('staticAsyncMethod', protected_static_sync_methods)
660
+ self.assertNotIn('__staticMethodPrivate', protected_static_sync_methods)
661
+
662
+ async def testGetProtectedStaticAsyncMethods(self):
663
+ """
664
+ Tests that the getProtectedStaticAsyncMethods method of ReflectionConcrete returns only protected static async methods of FakeClass.
665
+
666
+ This test creates a ReflectionConcrete object initialized with FakeClass,
667
+ calls getProtectedStaticAsyncMethods, and asserts that the returned list contains only protected static async methods.
668
+ """
669
+ reflect = ReflectionConcrete(FakeClass)
670
+ protected_static_async_methods = reflect.getProtectedStaticAsyncMethods()
671
+ self.assertIn('_staticAsyncMethodProtected', protected_static_async_methods)
672
+ self.assertNotIn('staticMethod', protected_static_async_methods)
673
+ self.assertNotIn('__staticMethodPrivate', protected_static_async_methods)
674
+
675
+ async def testGetPrivateStaticMethods(self):
676
+ """
677
+ Tests that the getPrivateStaticMethods method of ReflectionConcrete returns only private static methods of FakeClass.
678
+
679
+ This test creates a ReflectionConcrete object initialized with FakeClass,
680
+ calls getPrivateStaticMethods, and asserts that the returned list contains only private static methods.
681
+ """
682
+ reflect = ReflectionConcrete(FakeClass)
683
+ private_static_methods = reflect.getPrivateStaticMethods()
684
+ self.assertIn('__staticMethodPrivate', private_static_methods)
685
+ self.assertNotIn('staticMethod', private_static_methods)
686
+ self.assertNotIn('_staticMethodProtected', private_static_methods)
687
+
688
+ async def testGetPrivateStaticSyncMethods(self):
689
+ """
690
+ Tests that the getPrivateStaticSyncMethods method of ReflectionConcrete returns only private static sync methods of FakeClass.
691
+
692
+ This test creates a ReflectionConcrete object initialized with FakeClass,
693
+ calls getPrivateStaticSyncMethods, and asserts that the returned list contains only private static sync methods.
694
+ """
695
+ reflect = ReflectionConcrete(FakeClass)
696
+ private_static_sync_methods = reflect.getPrivateStaticSyncMethods()
697
+ self.assertIn('__staticMethodPrivate', private_static_sync_methods)
698
+ self.assertNotIn('staticMethod', private_static_sync_methods)
699
+ self.assertNotIn('_staticMethodProtected', private_static_sync_methods)
700
+
701
+ async def testGetPrivateStaticAsyncMethods(self):
702
+ """
703
+ Tests that the getPrivateStaticAsyncMethods method of ReflectionConcrete returns only private static async methods of FakeClass.
704
+
705
+ This test creates a ReflectionConcrete object initialized with FakeClass,
706
+ calls getPrivateStaticAsyncMethods, and asserts that the returned list contains only private static async methods.
707
+ """
708
+ reflect = ReflectionConcrete(FakeClass)
709
+ private_static_async_methods = reflect.getPrivateStaticAsyncMethods()
710
+ self.assertIn('__staticAsyncMethodPrivate', private_static_async_methods)
711
+ self.assertNotIn('staticAsyncMethod', private_static_async_methods)
712
+ self.assertNotIn('_staticAsyncMethodProtected', private_static_async_methods)
713
+
714
+ async def testGetDunderMethods(self):
715
+ """
716
+ Test that the getDunderMethods method correctly retrieves dunder (double underscore) methods
717
+ from ReflectionConcrete for the FakeClass.
718
+ Assertions ensure that '__init__' is present in the results.
719
+ """
720
+ reflect = ReflectionConcrete(FakeClass)
721
+ dunder_methods = reflect.getDunderMethods()
722
+ self.assertIn('__init__', dunder_methods)
723
+
724
+ async def testGetMagicMethods(self):
725
+ """
726
+ Test the retrieval of magic methods from ReflectionConcrete.
727
+ This test verifies that the `getMagicMethods` method correctly identifies and returns
728
+ magic methods (such as `__init__`) for ReflectionConcrete with FakeClass.
729
+ """
730
+ reflect = ReflectionConcrete(FakeClass)
731
+ magic_methods = reflect.getMagicMethods()
732
+ self.assertIn('__init__', magic_methods)
733
+
734
+ async def testGetProperties(self):
735
+ """
736
+ Tests that the getProperties method of ReflectionConcrete returns properties of FakeClass.
737
+ This test creates a ReflectionConcrete object initialized with FakeClass,
738
+ calls getProperties, and asserts that the returned list contains properties.
739
+ """
740
+ reflect = ReflectionConcrete(FakeClass)
741
+ properties = reflect.getProperties()
742
+ self.assertIn('computed_public_property', properties)
743
+ self.assertIn('_computed_property_protected', properties)
744
+ self.assertIn('__computed_property_private', properties)
745
+
746
+ async def testGetPublicProperties(self):
747
+ """
748
+ Tests that the getPublicProperties method of ReflectionConcrete returns only public properties of FakeClass.
749
+
750
+ This test creates a ReflectionConcrete object initialized with FakeClass,
751
+ calls getPublicProperties, and asserts that the returned list contains only public properties.
752
+ """
753
+ reflect = ReflectionConcrete(FakeClass)
754
+ public_properties = reflect.getPublicProperties()
755
+ self.assertIn('computed_public_property', public_properties)
756
+ self.assertNotIn('_computed_property_protected', public_properties)
757
+ self.assertNotIn('__computed_property_private', public_properties)
758
+
759
+ async def testGetProtectedProperties(self):
760
+ """
761
+ Tests that the getProtectedProperties method of ReflectionConcrete returns only protected properties of FakeClass.
762
+
763
+ This test creates a ReflectionConcrete object initialized with FakeClass,
764
+ calls getProtectedProperties, and asserts that the returned list contains only protected properties.
765
+ """
766
+ reflect = ReflectionConcrete(FakeClass)
767
+ protected_properties = reflect.getProtectedProperties()
768
+ self.assertIn('_computed_property_protected', protected_properties)
769
+ self.assertNotIn('computed_public_property', protected_properties)
770
+ self.assertNotIn('__computed_property_private', protected_properties)
771
+
772
+ async def testGetPrivateProperties(self):
773
+ """
774
+ Tests that the getPrivateProperties method of ReflectionConcrete returns only private properties of FakeClass.
775
+
776
+ This test creates a ReflectionConcrete object initialized with FakeClass,
777
+ calls getPrivateProperties, and asserts that the returned list contains only private properties.
778
+ """
779
+ reflect = ReflectionConcrete(FakeClass)
780
+ private_properties = reflect.getPrivateProperties()
781
+ self.assertIn('__computed_property_private', private_properties)
782
+ self.assertNotIn('computed_public_property', private_properties)
783
+ self.assertNotIn('_computed_property_protected', private_properties)
784
+
785
+ async def testGetProperty(self):
786
+ """
787
+ Tests that the getProperty method of ReflectionConcrete returns the correct value for a given property name.
788
+
789
+ This test creates a ReflectionConcrete object initialized with FakeClass,
790
+ calls getProperty for 'computed_public_property', and asserts that the returned value matches the expected value.
791
+ """
792
+ reflect = ReflectionConcrete(FakeClass)
793
+ value = reflect.getProperty('computed_public_property')
794
+ self.assertEqual(value, FakeClass().computed_public_property)
795
+
796
+ async def testGetPropertySignature(self):
797
+ """
798
+ Tests that the getPropertySignature method of ReflectionConcrete returns the correct signature for a given property name.
799
+ """
800
+ reflect = ReflectionConcrete(FakeClass)
801
+ signature = reflect.getPropertySignature('computed_public_property')
802
+ self.assertEqual(str(signature), '(self) -> str')
803
+
804
+ async def testGetPropertyDocstring(self):
805
+ """
806
+ Tests that the getPropertyDocstring method of ReflectionConcrete returns the correct docstring for a given property name.
807
+ This test creates a ReflectionConcrete object initialized with FakeClass,
808
+ calls getPropertyDocstring for 'computed_public_property', and asserts that the returned docstring matches the expected value.
809
+ """
810
+ reflect = ReflectionConcrete(FakeClass)
811
+ docstring = reflect.getPropertyDocstring('computed_public_property')
812
+ self.assertIn('Returns the string "public" as', docstring)
813
+
814
+ async def testGetConstructorDependencies(self):
815
+ """
816
+ Tests that the getConstructorDependencies method of ReflectionConcrete returns the correct constructor dependencies for FakeClass.
817
+ This test creates a ReflectionConcrete object initialized with FakeClass,
818
+ calls getConstructorDependencies, and asserts that the returned dependencies are returned as a ClassDependency object.
819
+ """
820
+ reflect = ReflectionConcrete(FakeClass)
821
+ dependencies = reflect.getConstructorDependencies()
822
+ self.assertIsInstance(dependencies, ClassDependency)
823
+
824
+ async def testGetMethodDependencies(self):
825
+ """
826
+ Tests that the getMethodDependencies method of ReflectionConcrete returns the correct method dependencies for 'instanceSyncMethod'.
827
+ This test creates a ReflectionConcrete object,
828
+ calls getMethodDependencies for 'instanceSyncMethod', and asserts that the returned dependencies are as expected.
829
+ """
830
+ reflect = ReflectionConcrete(FakeClass)
831
+ method_deps = reflect.getMethodDependencies('instanceSyncMethod')
832
+ self.assertIn('x', method_deps.resolved)
833
+ self.assertIn('y', method_deps.resolved)
834
+ self.assertEqual(method_deps.resolved['x'].class_name, 'int')
835
+ self.assertEqual(method_deps.resolved['y'].class_name, 'int')
836
+ self.assertEqual(method_deps.resolved['x'].module_name, 'builtins')
837
+ self.assertEqual(method_deps.resolved['y'].module_name, 'builtins')
838
+ self.assertEqual(method_deps.resolved['x'].type, int)
839
+ self.assertEqual(method_deps.resolved['y'].type, int)
840
+ self.assertEqual(method_deps.resolved['x'].full_class_path, 'builtins.int')
841
+ self.assertEqual(method_deps.resolved['y'].full_class_path, 'builtins.int')
842
+ self.assertEqual(method_deps.unresolved, [])