orionis 0.306.0__py3-none-any.whl → 0.308.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- orionis/metadata/framework.py +1 -1
- orionis/services/introspection/abstract/contracts/reflection_abstract.py +1 -1
- orionis/services/introspection/abstract/reflection_abstract.py +1 -1
- orionis/services/introspection/concretes/contracts/reflection_concrete.py +2 -2
- orionis/services/introspection/concretes/reflection_concrete.py +2 -4
- orionis/services/introspection/instances/contracts/reflection_instance.py +2 -2
- orionis/services/introspection/instances/reflection_instance.py +2 -2
- {orionis-0.306.0.dist-info → orionis-0.308.0.dist-info}/METADATA +1 -1
- {orionis-0.306.0.dist-info → orionis-0.308.0.dist-info}/RECORD +18 -14
- tests/services/inspection/reflection/mock/fake_reflect_instance.py +18 -3
- tests/services/inspection/reflection/test_reflection_abstract.py +588 -0
- tests/services/inspection/reflection/test_reflection_concrete.py +842 -0
- tests/services/inspection/reflection/test_reflection_instance.py +888 -0
- tests/services/inspection/reflection/test_reflection_module.py +397 -0
- {orionis-0.306.0.dist-info → orionis-0.308.0.dist-info}/WHEEL +0 -0
- {orionis-0.306.0.dist-info → orionis-0.308.0.dist-info}/licenses/LICENCE +0 -0
- {orionis-0.306.0.dist-info → orionis-0.308.0.dist-info}/top_level.txt +0 -0
- {orionis-0.306.0.dist-info → orionis-0.308.0.dist-info}/zip-safe +0 -0
@@ -0,0 +1,588 @@
|
|
1
|
+
from orionis.services.introspection.abstract.reflection_abstract import ReflectionAbstract
|
2
|
+
from orionis.services.introspection.dependencies.entities.class_dependencies import ClassDependency
|
3
|
+
from tests.services.inspection.reflection.mock.fake_reflect_instance import AbstractFakeClass
|
4
|
+
from orionis.unittesting import TestCase
|
5
|
+
|
6
|
+
class TestServiceReflectionAbstract(TestCase):
|
7
|
+
|
8
|
+
async def testGetClass(self):
|
9
|
+
"""
|
10
|
+
Verifies that getClass returns the correct class.
|
11
|
+
"""
|
12
|
+
reflect = ReflectionAbstract(AbstractFakeClass)
|
13
|
+
cls = reflect.getClass()
|
14
|
+
self.assertEqual(cls, AbstractFakeClass)
|
15
|
+
|
16
|
+
async def testGetClassName(self):
|
17
|
+
"""
|
18
|
+
Verifies that getClassName returns the class name.
|
19
|
+
"""
|
20
|
+
reflect = ReflectionAbstract(AbstractFakeClass)
|
21
|
+
class_name = reflect.getClassName()
|
22
|
+
self.assertEqual(class_name, 'AbstractFakeClass')
|
23
|
+
|
24
|
+
async def testGetModuleName(self):
|
25
|
+
"""
|
26
|
+
Verifies that getModuleName returns the module name.
|
27
|
+
"""
|
28
|
+
reflect = ReflectionAbstract(AbstractFakeClass)
|
29
|
+
module_name = reflect.getModuleName()
|
30
|
+
self.assertEqual(module_name, 'tests.services.inspection.reflection.mock.fake_reflect_instance')
|
31
|
+
|
32
|
+
async def testGetModuleWithClassName(self):
|
33
|
+
"""
|
34
|
+
Verifies that getModuleWithClassName returns the module and class name.
|
35
|
+
"""
|
36
|
+
reflect = ReflectionAbstract(AbstractFakeClass)
|
37
|
+
module_with_class_name = reflect.getModuleWithClassName()
|
38
|
+
self.assertEqual(module_with_class_name, 'tests.services.inspection.reflection.mock.fake_reflect_instance.AbstractFakeClass')
|
39
|
+
|
40
|
+
async def testGetDocstring(self):
|
41
|
+
"""
|
42
|
+
Verifies that getDocstring returns the class docstring.
|
43
|
+
"""
|
44
|
+
reflect = ReflectionAbstract(AbstractFakeClass)
|
45
|
+
docstring = reflect.getDocstring()
|
46
|
+
self.assertEqual(docstring, AbstractFakeClass.__doc__)
|
47
|
+
|
48
|
+
async def testGetBaseClasses(self):
|
49
|
+
"""
|
50
|
+
Verifies that getBaseClasses returns the base classes.
|
51
|
+
"""
|
52
|
+
reflect = ReflectionAbstract(AbstractFakeClass)
|
53
|
+
base_classes = reflect.getBaseClasses()
|
54
|
+
self.assertIn(AbstractFakeClass.__base__, base_classes)
|
55
|
+
|
56
|
+
async def testGetSourceCode(self):
|
57
|
+
"""
|
58
|
+
Verifies that getSourceCode returns the class source code.
|
59
|
+
"""
|
60
|
+
reflect = ReflectionAbstract(AbstractFakeClass)
|
61
|
+
source_code = reflect.getSourceCode()
|
62
|
+
self.assertTrue(source_code.startswith('class AbstractFakeClass'))
|
63
|
+
|
64
|
+
async def testGetFile(self):
|
65
|
+
"""
|
66
|
+
Verifies that getFile returns the class file path.
|
67
|
+
"""
|
68
|
+
reflect = ReflectionAbstract(AbstractFakeClass)
|
69
|
+
file_path = reflect.getFile()
|
70
|
+
self.assertTrue(file_path.endswith('fake_reflect_instance.py'))
|
71
|
+
|
72
|
+
async def testGetAnnotations(self):
|
73
|
+
"""
|
74
|
+
Verifies that getAnnotations returns the class annotations.
|
75
|
+
"""
|
76
|
+
reflect = ReflectionAbstract(AbstractFakeClass)
|
77
|
+
annotations = reflect.getAnnotations()
|
78
|
+
self.assertIn('public_attr', annotations)
|
79
|
+
|
80
|
+
async def testHasAttribute(self):
|
81
|
+
"""
|
82
|
+
Verifies that hasAttribute identifies existing attributes.
|
83
|
+
"""
|
84
|
+
reflect = ReflectionAbstract(AbstractFakeClass)
|
85
|
+
self.assertTrue(reflect.hasAttribute('public_attr'))
|
86
|
+
self.assertFalse(reflect.hasAttribute('non_existent_attr'))
|
87
|
+
|
88
|
+
async def testGetAttribute(self):
|
89
|
+
"""
|
90
|
+
Verifies that getAttribute gets the correct value of an attribute.
|
91
|
+
"""
|
92
|
+
reflect = ReflectionAbstract(AbstractFakeClass)
|
93
|
+
self.assertEqual(reflect.getAttribute('public_attr'), 42)
|
94
|
+
self.assertIsNone(reflect.getAttribute('non_existent_attr'))
|
95
|
+
|
96
|
+
async def testSetAttribute(self):
|
97
|
+
"""
|
98
|
+
Verifies that setAttribute modifies attributes correctly.
|
99
|
+
"""
|
100
|
+
reflect = ReflectionAbstract(AbstractFakeClass)
|
101
|
+
self.assertTrue(reflect.setAttribute('name', 'Orionis Framework'))
|
102
|
+
self.assertEqual(reflect.getAttribute('name'), 'Orionis Framework')
|
103
|
+
self.assertTrue(reflect.setAttribute('_version', '1.x'))
|
104
|
+
self.assertEqual(reflect.getAttribute('_version'), '1.x')
|
105
|
+
self.assertTrue(reflect.setAttribute('__python', '3.13+'))
|
106
|
+
self.assertEqual(reflect.getAttribute('__python'), '3.13+')
|
107
|
+
|
108
|
+
async def testRemoveAttribute(self):
|
109
|
+
"""
|
110
|
+
Verifies that removeAttribute removes attributes correctly.
|
111
|
+
"""
|
112
|
+
reflect = ReflectionAbstract(AbstractFakeClass)
|
113
|
+
reflect.setAttribute('new_attr', 100)
|
114
|
+
self.assertTrue(reflect.removeAttribute('new_attr'))
|
115
|
+
self.assertFalse(reflect.hasAttribute('new_attr'))
|
116
|
+
|
117
|
+
async def testGetAttributes(self):
|
118
|
+
"""
|
119
|
+
Verifies that getAttributes returns all attributes.
|
120
|
+
"""
|
121
|
+
reflect = ReflectionAbstract(AbstractFakeClass)
|
122
|
+
attributes = reflect.getAttributes()
|
123
|
+
self.assertIn('public_attr', attributes)
|
124
|
+
self.assertIn('_protected_attr', attributes)
|
125
|
+
self.assertIn('__private_attr', attributes)
|
126
|
+
|
127
|
+
async def testGetPublicAttributes(self):
|
128
|
+
"""
|
129
|
+
Verifies that getPublicAttributes returns only public attributes.
|
130
|
+
"""
|
131
|
+
reflect = ReflectionAbstract(AbstractFakeClass)
|
132
|
+
public_attributes = reflect.getPublicAttributes()
|
133
|
+
self.assertIn('public_attr', public_attributes)
|
134
|
+
self.assertNotIn('_protected_attr', public_attributes)
|
135
|
+
self.assertNotIn('__private_attr', public_attributes)
|
136
|
+
|
137
|
+
async def testGetProtectedAttributes(self):
|
138
|
+
"""
|
139
|
+
Verifies that getProtectedAttributes returns only protected attributes.
|
140
|
+
"""
|
141
|
+
reflect = ReflectionAbstract(AbstractFakeClass)
|
142
|
+
protected_attributes = reflect.getProtectedAttributes()
|
143
|
+
self.assertIn('_protected_attr', protected_attributes)
|
144
|
+
self.assertNotIn('public_attr', protected_attributes)
|
145
|
+
self.assertNotIn('__private_attr', protected_attributes)
|
146
|
+
|
147
|
+
async def testGetPrivateAttributes(self):
|
148
|
+
"""
|
149
|
+
Verifies that getPrivateAttributes returns only private attributes.
|
150
|
+
"""
|
151
|
+
reflect = ReflectionAbstract(AbstractFakeClass)
|
152
|
+
private_attributes = reflect.getPrivateAttributes()
|
153
|
+
self.assertIn('__private_attr', private_attributes)
|
154
|
+
self.assertNotIn('public_attr', private_attributes)
|
155
|
+
self.assertNotIn('_protected_attr', private_attributes)
|
156
|
+
|
157
|
+
async def testGetDunderAttributes(self):
|
158
|
+
"""
|
159
|
+
Verifies that getDunderAttributes returns dunder attributes.
|
160
|
+
"""
|
161
|
+
reflect = ReflectionAbstract(AbstractFakeClass)
|
162
|
+
dunder_attributes = reflect.getDunderAttributes()
|
163
|
+
self.assertIn('__dd__', dunder_attributes)
|
164
|
+
|
165
|
+
async def testGetMagicAttributes(self):
|
166
|
+
"""
|
167
|
+
Verifies that getMagicAttributes returns magic attributes.
|
168
|
+
"""
|
169
|
+
reflect = ReflectionAbstract(AbstractFakeClass)
|
170
|
+
magic_attributes = reflect.getMagicAttributes()
|
171
|
+
self.assertIn('__dd__', magic_attributes)
|
172
|
+
|
173
|
+
async def testHasMethod(self):
|
174
|
+
"""
|
175
|
+
Verifies that hasMethod identifies existing methods.
|
176
|
+
"""
|
177
|
+
reflect = ReflectionAbstract(AbstractFakeClass)
|
178
|
+
self.assertTrue(reflect.hasMethod('instanceSyncMethod'))
|
179
|
+
self.assertFalse(reflect.hasMethod('non_existent_method'))
|
180
|
+
|
181
|
+
async def testCallMethod(self):
|
182
|
+
"""
|
183
|
+
Verifies that callMethod executes methods correctly.
|
184
|
+
"""
|
185
|
+
# No aplica para ReflectionAbstract, se omite
|
186
|
+
|
187
|
+
async def testCallAsyncMethod(self):
|
188
|
+
"""
|
189
|
+
Verifies that callMethod executes async methods correctly.
|
190
|
+
"""
|
191
|
+
# No aplica para ReflectionAbstract, se omite
|
192
|
+
|
193
|
+
async def testSetMethod(self):
|
194
|
+
"""
|
195
|
+
Verifies that setMethod assigns methods correctly.
|
196
|
+
"""
|
197
|
+
# No aplica para ReflectionAbstract, se omite
|
198
|
+
|
199
|
+
async def testRemoveMethod(self):
|
200
|
+
"""
|
201
|
+
Verifies that removeMethod removes methods correctly.
|
202
|
+
"""
|
203
|
+
# No aplica para ReflectionAbstract, se omite
|
204
|
+
|
205
|
+
async def testGetMethodSignature(self):
|
206
|
+
"""
|
207
|
+
Verifies that getMethodSignature returns the method signature.
|
208
|
+
"""
|
209
|
+
reflect = ReflectionAbstract(AbstractFakeClass)
|
210
|
+
signature = reflect.getMethodSignature('instanceSyncMethod')
|
211
|
+
self.assertEqual(str(signature), '(self, x: int, y: int) -> int')
|
212
|
+
|
213
|
+
async def testGetMethods(self):
|
214
|
+
"""
|
215
|
+
Verifies that getMethods returns the class methods.
|
216
|
+
"""
|
217
|
+
reflect = ReflectionAbstract(AbstractFakeClass)
|
218
|
+
methods = reflect.getMethods()
|
219
|
+
self.assertIn('instanceSyncMethod', methods)
|
220
|
+
self.assertIn('instanceAsyncMethod', methods)
|
221
|
+
|
222
|
+
async def testGetPublicMethods(self):
|
223
|
+
"""
|
224
|
+
Verifies that getPublicMethods returns only public methods.
|
225
|
+
"""
|
226
|
+
reflect = ReflectionAbstract(AbstractFakeClass)
|
227
|
+
public_methods = reflect.getPublicMethods()
|
228
|
+
self.assertIn('instanceSyncMethod', public_methods)
|
229
|
+
self.assertNotIn('_protected_method', public_methods)
|
230
|
+
self.assertNotIn('__private_method', public_methods)
|
231
|
+
|
232
|
+
async def testGetPublicSyncMethods(self):
|
233
|
+
"""
|
234
|
+
Verifies that getPublicSyncMethods returns only public sync methods.
|
235
|
+
"""
|
236
|
+
reflect = ReflectionAbstract(AbstractFakeClass)
|
237
|
+
public_sync_methods = reflect.getPublicSyncMethods()
|
238
|
+
self.assertIn('instanceSyncMethod', public_sync_methods)
|
239
|
+
self.assertNotIn('_protected_method', public_sync_methods)
|
240
|
+
self.assertNotIn('__private_method', public_sync_methods)
|
241
|
+
|
242
|
+
async def testGetPublicAsyncMethods(self):
|
243
|
+
"""
|
244
|
+
Verifies that getPublicAsyncMethods returns only public async methods.
|
245
|
+
"""
|
246
|
+
reflect = ReflectionAbstract(AbstractFakeClass)
|
247
|
+
public_async_methods = reflect.getPublicAsyncMethods()
|
248
|
+
self.assertIn('instanceAsyncMethod', public_async_methods)
|
249
|
+
self.assertNotIn('_protected_async_method', public_async_methods)
|
250
|
+
self.assertNotIn('__private_async_method', public_async_methods)
|
251
|
+
|
252
|
+
async def testGetProtectedMethods(self):
|
253
|
+
"""
|
254
|
+
Verifies that getProtectedMethods returns only protected methods.
|
255
|
+
"""
|
256
|
+
reflect = ReflectionAbstract(AbstractFakeClass)
|
257
|
+
protected_methods = reflect.getProtectedMethods()
|
258
|
+
self.assertIn('_protectedAsyncMethod', protected_methods)
|
259
|
+
self.assertNotIn('instanceSyncMethod', protected_methods)
|
260
|
+
self.assertNotIn('__privateSyncMethod', protected_methods)
|
261
|
+
|
262
|
+
async def testGetProtectedSyncMethods(self):
|
263
|
+
"""
|
264
|
+
Verifies that getProtectedSyncMethods returns only protected sync methods.
|
265
|
+
"""
|
266
|
+
reflect = ReflectionAbstract(AbstractFakeClass)
|
267
|
+
protected_sync_methods = reflect.getProtectedSyncMethods()
|
268
|
+
self.assertIn('_protectedsyncMethod', protected_sync_methods)
|
269
|
+
self.assertNotIn('instanceAsyncMethod', protected_sync_methods)
|
270
|
+
self.assertNotIn('__privateSyncMethod', protected_sync_methods)
|
271
|
+
|
272
|
+
async def testGetProtectedAsyncMethods(self):
|
273
|
+
"""
|
274
|
+
Verifies that getProtectedAsyncMethods returns only protected async methods.
|
275
|
+
"""
|
276
|
+
reflect = ReflectionAbstract(AbstractFakeClass)
|
277
|
+
protected_async_methods = reflect.getProtectedAsyncMethods()
|
278
|
+
self.assertIn('_protectedAsyncMethod', protected_async_methods)
|
279
|
+
self.assertNotIn('instanceSyncMethod', protected_async_methods)
|
280
|
+
self.assertNotIn('__privateSyncMethod', protected_async_methods)
|
281
|
+
|
282
|
+
async def testGetPrivateMethods(self):
|
283
|
+
"""
|
284
|
+
Verifies that getPrivateMethods returns only private methods.
|
285
|
+
"""
|
286
|
+
reflect = ReflectionAbstract(AbstractFakeClass)
|
287
|
+
private_methods = reflect.getPrivateMethods()
|
288
|
+
self.assertIn('__privateSyncMethod', private_methods)
|
289
|
+
self.assertNotIn('instanceSyncMethod', private_methods)
|
290
|
+
self.assertNotIn('_protectedAsyncMethod', private_methods)
|
291
|
+
|
292
|
+
async def testGetPrivateSyncMethods(self):
|
293
|
+
"""
|
294
|
+
Verifies that getPrivateSyncMethods returns only private sync methods.
|
295
|
+
"""
|
296
|
+
reflect = ReflectionAbstract(AbstractFakeClass)
|
297
|
+
private_sync_methods = reflect.getPrivateSyncMethods()
|
298
|
+
self.assertIn('__privateSyncMethod', private_sync_methods)
|
299
|
+
self.assertNotIn('instanceAsyncMethod', private_sync_methods)
|
300
|
+
self.assertNotIn('_protectedAsyncMethod', private_sync_methods)
|
301
|
+
|
302
|
+
async def testGetPrivateAsyncMethods(self):
|
303
|
+
"""
|
304
|
+
Verifies that getPrivateAsyncMethods returns only private async methods.
|
305
|
+
"""
|
306
|
+
reflect = ReflectionAbstract(AbstractFakeClass)
|
307
|
+
private_async_methods = reflect.getPrivateAsyncMethods()
|
308
|
+
self.assertIn('__privateAsyncMethod', private_async_methods)
|
309
|
+
self.assertNotIn('instanceSyncMethod', private_async_methods)
|
310
|
+
self.assertNotIn('_protectedAsyncMethod', private_async_methods)
|
311
|
+
|
312
|
+
async def testGetPublicClassMethods(self):
|
313
|
+
"""
|
314
|
+
Verifies that getPublicClassMethods returns only public class methods.
|
315
|
+
"""
|
316
|
+
reflect = ReflectionAbstract(AbstractFakeClass)
|
317
|
+
public_class_methods = reflect.getPublicClassMethods()
|
318
|
+
self.assertIn('classSyncMethod', public_class_methods)
|
319
|
+
self.assertNotIn('_protected_class_method', public_class_methods)
|
320
|
+
self.assertNotIn('__private_class_method', public_class_methods)
|
321
|
+
|
322
|
+
async def testGetPublicClassSyncMethods(self):
|
323
|
+
"""
|
324
|
+
Verifies that getPublicClassSyncMethods returns only public class sync methods.
|
325
|
+
"""
|
326
|
+
reflect = ReflectionAbstract(AbstractFakeClass)
|
327
|
+
public_class_sync_methods = reflect.getPublicClassSyncMethods()
|
328
|
+
self.assertIn('classSyncMethod', public_class_sync_methods)
|
329
|
+
self.assertNotIn('_protected_class_method', public_class_sync_methods)
|
330
|
+
self.assertNotIn('__private_class_method', public_class_sync_methods)
|
331
|
+
|
332
|
+
async def testGetPublicClassAsyncMethods(self):
|
333
|
+
"""
|
334
|
+
Verifies that getPublicClassAsyncMethods returns only public class async methods.
|
335
|
+
"""
|
336
|
+
reflect = ReflectionAbstract(AbstractFakeClass)
|
337
|
+
public_class_async_methods = reflect.getPublicClassAsyncMethods()
|
338
|
+
self.assertIn('classAsyncMethod', public_class_async_methods)
|
339
|
+
self.assertNotIn('_protected_class_async_method', public_class_async_methods)
|
340
|
+
self.assertNotIn('__private_class_async_method', public_class_async_methods)
|
341
|
+
|
342
|
+
async def testGetProtectedClassMethods(self):
|
343
|
+
"""
|
344
|
+
Verifies that getProtectedClassMethods returns only protected class methods.
|
345
|
+
"""
|
346
|
+
reflect = ReflectionAbstract(AbstractFakeClass)
|
347
|
+
protected_class_methods = reflect.getProtectedClassMethods()
|
348
|
+
self.assertIn('_classMethodProtected', protected_class_methods)
|
349
|
+
self.assertNotIn('classSyncMethod', protected_class_methods)
|
350
|
+
self.assertNotIn('__classMethodPrivate', protected_class_methods)
|
351
|
+
|
352
|
+
async def testGetProtectedClassSyncMethods(self):
|
353
|
+
"""
|
354
|
+
Verifies that getProtectedClassSyncMethods returns only protected class sync methods.
|
355
|
+
"""
|
356
|
+
reflect = ReflectionAbstract(AbstractFakeClass)
|
357
|
+
protected_class_sync_methods = reflect.getProtectedClassSyncMethods()
|
358
|
+
self.assertIn('_classMethodProtected', protected_class_sync_methods)
|
359
|
+
self.assertNotIn('classSyncMethod', protected_class_sync_methods)
|
360
|
+
self.assertNotIn('__classSyncMethodPrivate', protected_class_sync_methods)
|
361
|
+
|
362
|
+
async def testGetProtectedClassAsyncMethods(self):
|
363
|
+
"""
|
364
|
+
Verifies that getProtectedClassAsyncMethods returns only protected class async methods.
|
365
|
+
"""
|
366
|
+
reflect = ReflectionAbstract(AbstractFakeClass)
|
367
|
+
protected_class_async_methods = reflect.getProtectedClassAsyncMethods()
|
368
|
+
self.assertIn('_classAsyncMethodProtected', protected_class_async_methods)
|
369
|
+
self.assertNotIn('classAsyncMethod', protected_class_async_methods)
|
370
|
+
self.assertNotIn('__classAsyncMethodPrivate', protected_class_async_methods)
|
371
|
+
|
372
|
+
async def testGetPrivateClassMethods(self):
|
373
|
+
"""
|
374
|
+
Verifies that getPrivateClassMethods returns only private class methods.
|
375
|
+
"""
|
376
|
+
reflect = ReflectionAbstract(AbstractFakeClass)
|
377
|
+
private_class_methods = reflect.getPrivateClassMethods()
|
378
|
+
self.assertIn('__classMethodPrivate', private_class_methods)
|
379
|
+
self.assertNotIn('classSyncMethod', private_class_methods)
|
380
|
+
self.assertNotIn('_classMethodProtected', private_class_methods)
|
381
|
+
|
382
|
+
async def testGetPrivateClassSyncMethods(self):
|
383
|
+
"""
|
384
|
+
Verifies that getPrivateClassSyncMethods returns only private class sync methods.
|
385
|
+
"""
|
386
|
+
reflect = ReflectionAbstract(AbstractFakeClass)
|
387
|
+
private_class_methods = reflect.getPrivateClassSyncMethods()
|
388
|
+
self.assertIn('__classMethodPrivate', private_class_methods)
|
389
|
+
self.assertNotIn('classSyncMethod', private_class_methods)
|
390
|
+
self.assertNotIn('_classMethodProtected', private_class_methods)
|
391
|
+
|
392
|
+
async def testGetPrivateClassAsyncMethods(self):
|
393
|
+
"""
|
394
|
+
Verifies that getPrivateClassAsyncMethods returns only private class async methods.
|
395
|
+
"""
|
396
|
+
reflect = ReflectionAbstract(AbstractFakeClass)
|
397
|
+
private_class_async_methods = reflect.getPrivateClassAsyncMethods()
|
398
|
+
self.assertIn('__classAsyncMethodPrivate', private_class_async_methods)
|
399
|
+
self.assertNotIn('classAsyncMethod', private_class_async_methods)
|
400
|
+
self.assertNotIn('_classAsyncMethodProtected', private_class_async_methods)
|
401
|
+
|
402
|
+
async def testGetPublicStaticMethods(self):
|
403
|
+
"""
|
404
|
+
Verifies that getPublicStaticMethods returns only public static methods.
|
405
|
+
"""
|
406
|
+
reflect = ReflectionAbstract(AbstractFakeClass)
|
407
|
+
public_static_methods = reflect.getPublicStaticMethods()
|
408
|
+
self.assertIn('staticMethod', public_static_methods)
|
409
|
+
self.assertIn('staticAsyncMethod', public_static_methods)
|
410
|
+
self.assertNotIn('static_async_method', public_static_methods)
|
411
|
+
|
412
|
+
async def testGetPublicStaticSyncMethods(self):
|
413
|
+
"""
|
414
|
+
Verifies that getPublicStaticSyncMethods returns only public static sync methods.
|
415
|
+
"""
|
416
|
+
reflect = ReflectionAbstract(AbstractFakeClass)
|
417
|
+
public_static_sync_methods = reflect.getPublicStaticSyncMethods()
|
418
|
+
self.assertIn('staticMethod', public_static_sync_methods)
|
419
|
+
self.assertNotIn('staticAsyncMethod', public_static_sync_methods)
|
420
|
+
self.assertNotIn('static_async_method', public_static_sync_methods)
|
421
|
+
|
422
|
+
async def testGetPublicStaticAsyncMethods(self):
|
423
|
+
"""
|
424
|
+
Verifies that getPublicStaticAsyncMethods returns only public static async methods.
|
425
|
+
"""
|
426
|
+
reflect = ReflectionAbstract(AbstractFakeClass)
|
427
|
+
public_static_async_methods = reflect.getPublicStaticAsyncMethods()
|
428
|
+
self.assertIn('staticAsyncMethod', public_static_async_methods)
|
429
|
+
self.assertNotIn('staticMethod', public_static_async_methods)
|
430
|
+
self.assertNotIn('static_async_method', public_static_async_methods)
|
431
|
+
|
432
|
+
async def testGetProtectedStaticMethods(self):
|
433
|
+
"""
|
434
|
+
Verifies that getProtectedStaticMethods returns only protected static methods.
|
435
|
+
"""
|
436
|
+
reflect = ReflectionAbstract(AbstractFakeClass)
|
437
|
+
protected_static_methods = reflect.getProtectedStaticMethods()
|
438
|
+
self.assertIn('_staticMethodProtected', protected_static_methods)
|
439
|
+
self.assertNotIn('staticMethod', protected_static_methods)
|
440
|
+
self.assertNotIn('__staticMethodPrivate', protected_static_methods)
|
441
|
+
|
442
|
+
async def testGetProtectedStaticSyncMethods(self):
|
443
|
+
"""
|
444
|
+
Verifies that getProtectedStaticSyncMethods returns only protected static sync methods.
|
445
|
+
"""
|
446
|
+
reflect = ReflectionAbstract(AbstractFakeClass)
|
447
|
+
protected_static_sync_methods = reflect.getProtectedStaticSyncMethods()
|
448
|
+
self.assertIn('_staticMethodProtected', protected_static_sync_methods)
|
449
|
+
self.assertNotIn('staticAsyncMethod', protected_static_sync_methods)
|
450
|
+
self.assertNotIn('__staticMethodPrivate', protected_static_sync_methods)
|
451
|
+
|
452
|
+
async def testGetProtectedStaticAsyncMethods(self):
|
453
|
+
"""
|
454
|
+
Verifies that getProtectedStaticAsyncMethods returns only protected static async methods.
|
455
|
+
"""
|
456
|
+
reflect = ReflectionAbstract(AbstractFakeClass)
|
457
|
+
protected_static_async_methods = reflect.getProtectedStaticAsyncMethods()
|
458
|
+
self.assertIn('_staticAsyncMethodProtected', protected_static_async_methods)
|
459
|
+
self.assertNotIn('staticMethod', protected_static_async_methods)
|
460
|
+
self.assertNotIn('__staticMethodPrivate', protected_static_async_methods)
|
461
|
+
|
462
|
+
async def testGetPrivateStaticMethods(self):
|
463
|
+
"""
|
464
|
+
Verifies that getPrivateStaticMethods returns only private static methods.
|
465
|
+
"""
|
466
|
+
reflect = ReflectionAbstract(AbstractFakeClass)
|
467
|
+
private_static_methods = reflect.getPrivateStaticMethods()
|
468
|
+
self.assertIn('__staticMethodPrivate', private_static_methods)
|
469
|
+
self.assertNotIn('staticMethod', private_static_methods)
|
470
|
+
self.assertNotIn('_staticMethodProtected', private_static_methods)
|
471
|
+
|
472
|
+
async def testGetPrivateStaticSyncMethods(self):
|
473
|
+
"""
|
474
|
+
Verifies that getPrivateStaticSyncMethods returns only private static sync methods.
|
475
|
+
"""
|
476
|
+
reflect = ReflectionAbstract(AbstractFakeClass)
|
477
|
+
private_static_sync_methods = reflect.getPrivateStaticSyncMethods()
|
478
|
+
self.assertIn('__staticMethodPrivate', private_static_sync_methods)
|
479
|
+
self.assertNotIn('staticMethod', private_static_sync_methods)
|
480
|
+
self.assertNotIn('_staticMethodProtected', private_static_sync_methods)
|
481
|
+
|
482
|
+
async def testGetPrivateStaticAsyncMethods(self):
|
483
|
+
"""
|
484
|
+
Verifies that getPrivateStaticAsyncMethods returns only private static async methods.
|
485
|
+
"""
|
486
|
+
reflect = ReflectionAbstract(AbstractFakeClass)
|
487
|
+
private_static_async_methods = reflect.getPrivateStaticAsyncMethods()
|
488
|
+
self.assertIn('__staticAsyncMethodPrivate', private_static_async_methods)
|
489
|
+
self.assertNotIn('staticAsyncMethod', private_static_async_methods)
|
490
|
+
self.assertNotIn('_staticAsyncMethodProtected', private_static_async_methods)
|
491
|
+
|
492
|
+
async def testGetDunderMethods(self):
|
493
|
+
"""
|
494
|
+
Verifies that getDunderMethods returns dunder methods.
|
495
|
+
"""
|
496
|
+
reflect = ReflectionAbstract(AbstractFakeClass)
|
497
|
+
dunder_methods = reflect.getDunderMethods()
|
498
|
+
self.assertIn('__init__', dunder_methods)
|
499
|
+
|
500
|
+
async def testGetMagicMethods(self):
|
501
|
+
"""
|
502
|
+
Verifies that getMagicMethods returns magic methods.
|
503
|
+
"""
|
504
|
+
reflect = ReflectionAbstract(AbstractFakeClass)
|
505
|
+
magic_methods = reflect.getMagicMethods()
|
506
|
+
self.assertIn('__init__', magic_methods)
|
507
|
+
|
508
|
+
async def testGetProperties(self):
|
509
|
+
"""
|
510
|
+
Verifies that getProperties returns the class properties.
|
511
|
+
"""
|
512
|
+
reflect = ReflectionAbstract(AbstractFakeClass)
|
513
|
+
properties = reflect.getProperties()
|
514
|
+
self.assertIn('computed_public_property', properties)
|
515
|
+
self.assertIn('_computed_property_protected', properties)
|
516
|
+
self.assertIn('__computed_property_private', properties)
|
517
|
+
|
518
|
+
async def testGetPublicProperties(self):
|
519
|
+
"""
|
520
|
+
Verifies that getPublicProperties returns only public properties.
|
521
|
+
"""
|
522
|
+
reflect = ReflectionAbstract(AbstractFakeClass)
|
523
|
+
public_properties = reflect.getPublicProperties()
|
524
|
+
self.assertIn('computed_public_property', public_properties)
|
525
|
+
self.assertNotIn('_computed_property_protected', public_properties)
|
526
|
+
self.assertNotIn('__computed_property_private', public_properties)
|
527
|
+
|
528
|
+
async def testGetProtectedProperties(self):
|
529
|
+
"""
|
530
|
+
Verifies that getProtectedProperties returns only protected properties.
|
531
|
+
"""
|
532
|
+
reflect = ReflectionAbstract(AbstractFakeClass)
|
533
|
+
protected_properties = reflect.getProtectedProperties()
|
534
|
+
self.assertIn('_computed_property_protected', protected_properties)
|
535
|
+
self.assertNotIn('computed_public_property', protected_properties)
|
536
|
+
self.assertNotIn('__computed_property_private', protected_properties)
|
537
|
+
|
538
|
+
async def testGetPrivateProperties(self):
|
539
|
+
"""
|
540
|
+
Verifies that getPrivateProperties returns only private properties.
|
541
|
+
"""
|
542
|
+
reflect = ReflectionAbstract(AbstractFakeClass)
|
543
|
+
private_properties = reflect.getPrivateProperties()
|
544
|
+
self.assertIn('__computed_property_private', private_properties)
|
545
|
+
self.assertNotIn('computed_public_property', private_properties)
|
546
|
+
self.assertNotIn('_computed_property_protected', private_properties)
|
547
|
+
|
548
|
+
async def testGetPropertySignature(self):
|
549
|
+
"""
|
550
|
+
Verifies that getPropertySignature returns the property signature.
|
551
|
+
"""
|
552
|
+
reflect = ReflectionAbstract(AbstractFakeClass)
|
553
|
+
signature = reflect.getPropertySignature('computed_public_property')
|
554
|
+
self.assertEqual(str(signature), '(self) -> str')
|
555
|
+
|
556
|
+
async def testGetPropertyDocstring(self):
|
557
|
+
"""
|
558
|
+
Verifies that getPropertyDocstring returns the property docstring.
|
559
|
+
"""
|
560
|
+
reflect = ReflectionAbstract(AbstractFakeClass)
|
561
|
+
docstring = reflect.getPropertyDocstring('computed_public_property')
|
562
|
+
self.assertIn('Computes and returns the valu', docstring)
|
563
|
+
|
564
|
+
async def testGetConstructorDependencies(self):
|
565
|
+
"""
|
566
|
+
Verifies that getConstructorDependencies returns the constructor dependencies.
|
567
|
+
"""
|
568
|
+
reflect = ReflectionAbstract(AbstractFakeClass)
|
569
|
+
dependencies = reflect.getConstructorDependencies()
|
570
|
+
self.assertIsInstance(dependencies, ClassDependency)
|
571
|
+
|
572
|
+
async def testGetMethodDependencies(self):
|
573
|
+
"""
|
574
|
+
Verifies that getMethodDependencies returns the method dependencies.
|
575
|
+
"""
|
576
|
+
reflect = ReflectionAbstract(AbstractFakeClass)
|
577
|
+
method_deps = reflect.getMethodDependencies('instanceSyncMethod')
|
578
|
+
self.assertIn('x', method_deps.resolved)
|
579
|
+
self.assertIn('y', method_deps.resolved)
|
580
|
+
self.assertEqual(method_deps.resolved['x'].class_name, 'int')
|
581
|
+
self.assertEqual(method_deps.resolved['y'].class_name, 'int')
|
582
|
+
self.assertEqual(method_deps.resolved['x'].module_name, 'builtins')
|
583
|
+
self.assertEqual(method_deps.resolved['y'].module_name, 'builtins')
|
584
|
+
self.assertEqual(method_deps.resolved['x'].type, int)
|
585
|
+
self.assertEqual(method_deps.resolved['y'].type, int)
|
586
|
+
self.assertEqual(method_deps.resolved['x'].full_class_path, 'builtins.int')
|
587
|
+
self.assertEqual(method_deps.resolved['y'].full_class_path, 'builtins.int')
|
588
|
+
self.assertEqual(method_deps.unresolved, [])
|