orionis 0.210.0__py3-none-any.whl → 0.213.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/framework.py +1 -1
- orionis/luminate/support/inspection/functions.py +47 -19
- orionis/luminate/support/inspection/reflection.py +16 -444
- orionis/luminate/support/inspection/reflexion_concrete.py +255 -3
- orionis/luminate/support/inspection/reflexion_concrete_with_abstract.py +162 -8
- {orionis-0.210.0.dist-info → orionis-0.213.0.dist-info}/METADATA +1 -1
- {orionis-0.210.0.dist-info → orionis-0.213.0.dist-info}/RECORD +17 -13
- tests/support/inspection/fakes/fake_reflection_concrete.py +44 -0
- tests/support/inspection/fakes/fake_reflection_concrete_with_abstract.py +78 -0
- tests/support/inspection/test_reflection_concrete.py +139 -0
- tests/support/inspection/test_reflection_concrete_with_abstract.py +87 -0
- tests/support/inspection/test_reflection_instance.py +1 -1
- tests/support/inspection/test_reflection_instance_with_abstract.py +1 -1
- {orionis-0.210.0.dist-info → orionis-0.213.0.dist-info}/LICENCE +0 -0
- {orionis-0.210.0.dist-info → orionis-0.213.0.dist-info}/WHEEL +0 -0
- {orionis-0.210.0.dist-info → orionis-0.213.0.dist-info}/entry_points.txt +0 -0
- {orionis-0.210.0.dist-info → orionis-0.213.0.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,139 @@
|
|
1
|
+
from orionis.luminate.support.inspection.reflection import Reflection
|
2
|
+
from orionis.luminate.support.inspection.reflexion_concrete import ReflexionConcrete
|
3
|
+
from orionis.luminate.test.test_case import TestCase
|
4
|
+
from tests.support.inspection.fakes.fake_reflection_concrete import BaseExample, FakeExample
|
5
|
+
|
6
|
+
class TestReflectionConcrete(TestCase):
|
7
|
+
"""
|
8
|
+
Unit tests for the Reflection class.
|
9
|
+
"""
|
10
|
+
|
11
|
+
def testReflectionConcreteExceptionValueError(self):
|
12
|
+
"""Ensure Reflection.instance raises ValueError for invalid types."""
|
13
|
+
with self.assertRaises(ValueError):
|
14
|
+
Reflection.concrete(str)
|
15
|
+
|
16
|
+
def testReflectionConcrete(self):
|
17
|
+
"""Verify Reflection.instance returns an instance of ReflexionInstance."""
|
18
|
+
self.assertIsInstance(Reflection.concrete(FakeExample), ReflexionConcrete)
|
19
|
+
|
20
|
+
def testReflectionConcreteGetClassName(self):
|
21
|
+
"""Test getClassName method."""
|
22
|
+
reflection = Reflection.concrete(FakeExample)
|
23
|
+
self.assertEqual(reflection.getClassName(), "FakeExample")
|
24
|
+
|
25
|
+
def testReflectionConcreteGetClass(self):
|
26
|
+
"""Test getClass method."""
|
27
|
+
reflection = Reflection.concrete(FakeExample)
|
28
|
+
self.assertEqual(reflection.getClass(), FakeExample)
|
29
|
+
|
30
|
+
def testReflectionConcreteGetModuleName(self):
|
31
|
+
"""Test getModuleName method."""
|
32
|
+
reflection = Reflection.concrete(FakeExample)
|
33
|
+
self.assertEqual(reflection.getModuleName(), "tests.support.inspection.fakes.fake_reflection_concrete")
|
34
|
+
|
35
|
+
def testReflectionConcreteGetAttributes(self):
|
36
|
+
"""Test getAttributes method."""
|
37
|
+
reflection = Reflection.concrete(FakeExample)
|
38
|
+
self.assertEqual(reflection.getAttributes(), {'class_attr': 42, 'another_attr': 'hello'})
|
39
|
+
|
40
|
+
def testReflectionConcreteGetMethods(self):
|
41
|
+
"""Test getMethods method."""
|
42
|
+
reflection = Reflection.concrete(FakeExample)
|
43
|
+
expected_methods = [
|
44
|
+
'baseMethod',
|
45
|
+
'method_one',
|
46
|
+
'method_two',
|
47
|
+
'static_method',
|
48
|
+
]
|
49
|
+
self.assertEqual(reflection.getMethods(), expected_methods)
|
50
|
+
|
51
|
+
def testReflectionConcreteGetStaticMethods(self):
|
52
|
+
"""Test getStaticMethods method."""
|
53
|
+
reflection = Reflection.concrete(FakeExample)
|
54
|
+
expected_static_methods = [
|
55
|
+
'static_method'
|
56
|
+
]
|
57
|
+
self.assertEqual(reflection.getStaticMethods(), expected_static_methods)
|
58
|
+
|
59
|
+
def testReflectionConcreteGetPropertyNames(self):
|
60
|
+
"""Test getPropertyNames method."""
|
61
|
+
reflection = Reflection.concrete(FakeExample)
|
62
|
+
expected_properties = [
|
63
|
+
'prop',
|
64
|
+
'prop_with_getter',
|
65
|
+
]
|
66
|
+
self.assertEqual(reflection.getPropertyNames(), expected_properties)
|
67
|
+
|
68
|
+
def testReflectionConcreteGetMethodSignature(self):
|
69
|
+
"""Test getMethodSignature method."""
|
70
|
+
reflection = Reflection.concrete(FakeExample)
|
71
|
+
self.assertEqual(str(reflection.getMethodSignature('method_one')), '(self, x: int) -> int')
|
72
|
+
self.assertEqual(str(reflection.getMethodSignature('method_two')), '(self, a: str, b: str = \'default\') -> str')
|
73
|
+
self.assertEqual(str(reflection.getMethodSignature('__init__')), '(self, value: int = 10) -> None')
|
74
|
+
|
75
|
+
def testReflectionConcreteGetPropertySignature(self):
|
76
|
+
"""Test getPropertySignature method."""
|
77
|
+
reflection = Reflection.concrete(FakeExample)
|
78
|
+
self.assertEqual(str(reflection.getPropertySignature('prop')), '(self) -> int')
|
79
|
+
self.assertEqual(str(reflection.getPropertySignature('prop_with_getter')), '(self) -> str')
|
80
|
+
|
81
|
+
def testReflectionConcreteGetDocstring(self):
|
82
|
+
"""Test getDocstring method."""
|
83
|
+
reflection = Reflection.concrete(FakeExample)
|
84
|
+
self.assertIn('This is a fake example class for testing reflection', reflection.getDocstring())
|
85
|
+
|
86
|
+
def testReflectionConcreteGetBaseClasses(self):
|
87
|
+
"""Test getBaseClasses method."""
|
88
|
+
reflection = Reflection.concrete(FakeExample)
|
89
|
+
self.assertEqual(reflection.getBaseClasses(), (BaseExample,))
|
90
|
+
|
91
|
+
def testReflectionConcreteIsSubclassOf(self):
|
92
|
+
"""Test isSubclassOf method."""
|
93
|
+
reflection = Reflection.concrete(FakeExample)
|
94
|
+
self.assertTrue(reflection.isSubclassOf(BaseExample))
|
95
|
+
self.assertFalse(reflection.isSubclassOf(str))
|
96
|
+
|
97
|
+
def testReflectionConcreteGetSourceCode(self):
|
98
|
+
"""Test getSourceCode method."""
|
99
|
+
reflection = Reflection.concrete(FakeExample)
|
100
|
+
source_code = reflection.getSourceCode()
|
101
|
+
self.assertIn('class FakeExample(BaseExample):', source_code)
|
102
|
+
self.assertIn('def method_one(self, x: int) -> int:', source_code)
|
103
|
+
|
104
|
+
def testReflectionConcreteGetFileLocation(self):
|
105
|
+
"""Test getFileLocation method."""
|
106
|
+
reflection = Reflection.concrete(FakeExample)
|
107
|
+
file_location = reflection.getFileLocation()
|
108
|
+
self.assertIn('fake_reflection_concrete.py', file_location)
|
109
|
+
self.assertIn('tests\\support\\inspection\\fakes', file_location)
|
110
|
+
|
111
|
+
def testReflectionConcreteGetAnnotations(self):
|
112
|
+
"""Test getAnnotations method."""
|
113
|
+
reflection = Reflection.concrete(FakeExample)
|
114
|
+
self.assertEqual(reflection.getAnnotations(), {'class_attr': int})
|
115
|
+
|
116
|
+
def testReflectionConcreteHasAttribute(self):
|
117
|
+
"""Test hasAttribute method."""
|
118
|
+
reflection = Reflection.concrete(FakeExample)
|
119
|
+
self.assertTrue(reflection.hasAttribute('class_attr'))
|
120
|
+
self.assertFalse(reflection.hasAttribute('non_existent_attr'))
|
121
|
+
|
122
|
+
def testReflectionConcreteGetAttribute(self):
|
123
|
+
"""Test getAttribute method."""
|
124
|
+
reflection = Reflection.concrete(FakeExample)
|
125
|
+
self.assertEqual(reflection.getAttribute('class_attr'), 42)
|
126
|
+
with self.assertRaises(AttributeError):
|
127
|
+
reflection.getAttribute('non_existent_attr')
|
128
|
+
|
129
|
+
def testReflectionConcreteGetCallableMembers(self):
|
130
|
+
"""Test getCallableMembers method."""
|
131
|
+
reflection = Reflection.concrete(FakeExample)
|
132
|
+
callable_members = reflection.getCallableMembers()
|
133
|
+
self.assertIn('_private_method', callable_members)
|
134
|
+
self.assertIn('_private_static', callable_members)
|
135
|
+
self.assertIn('baseMethod', callable_members)
|
136
|
+
self.assertIn('class_method', callable_members)
|
137
|
+
self.assertIn('method_one', callable_members)
|
138
|
+
self.assertIn('method_two', callable_members)
|
139
|
+
self.assertIn('static_method', callable_members)
|
@@ -0,0 +1,87 @@
|
|
1
|
+
from orionis.luminate.support.inspection.reflexion_concrete_with_abstract import ReflexionConcreteWithAbstract
|
2
|
+
from orionis.luminate.test.test_case import TestCase
|
3
|
+
from tests.support.inspection.fakes.fake_reflection_concrete_with_abstract import AbstractService, PartiallyImplementedService
|
4
|
+
|
5
|
+
class TestReflexionConcreteWithAbstract(TestCase):
|
6
|
+
|
7
|
+
def testReflexionInstanceWithAbstractGetImplementationAnalysis(self):
|
8
|
+
"""Test reflexion con AbstractService y PartiallyImplementedService."""
|
9
|
+
inspector = ReflexionConcreteWithAbstract(PartiallyImplementedService, AbstractService)
|
10
|
+
|
11
|
+
# Get Implementation analysis
|
12
|
+
analysis = inspector.getImplementationAnalysis()
|
13
|
+
|
14
|
+
# Verifying implemented methods
|
15
|
+
self.assertFalse(analysis['configure']['implemented'])
|
16
|
+
self.assertIsNone(analysis['configure']['abstract_signature'])
|
17
|
+
self.assertIsNone(analysis['configure']['concrete_signature'])
|
18
|
+
self.assertFalse(analysis['configure']['signature_match'])
|
19
|
+
self.assertEqual(analysis['configure']['type'], 'method')
|
20
|
+
|
21
|
+
self.assertTrue(analysis['get_logs']['implemented'])
|
22
|
+
self.assertEqual(str(analysis['get_logs']['abstract_signature']), "(self, limit: int = 10) -> List[str]")
|
23
|
+
self.assertEqual(str(analysis['get_logs']['concrete_signature']), "(self, limit: int = 10) -> List[str]")
|
24
|
+
self.assertTrue(analysis['get_logs']['signature_match'])
|
25
|
+
self.assertEqual(analysis['get_logs']['type'], 'method')
|
26
|
+
|
27
|
+
self.assertFalse(analysis['reset']['implemented'])
|
28
|
+
self.assertIsNone(analysis['reset']['abstract_signature'])
|
29
|
+
self.assertIsNone(analysis['reset']['concrete_signature'])
|
30
|
+
self.assertFalse(analysis['reset']['signature_match'])
|
31
|
+
self.assertEqual(analysis['reset']['type'], 'method')
|
32
|
+
|
33
|
+
self.assertTrue(analysis['process']['implemented'])
|
34
|
+
self.assertEqual(str(analysis['process']['abstract_signature']), "(self, data: str) -> bool")
|
35
|
+
self.assertEqual(str(analysis['process']['concrete_signature']), "(self, data: str) -> bool")
|
36
|
+
self.assertTrue(analysis['process']['signature_match'])
|
37
|
+
self.assertEqual(analysis['process']['type'], 'method')
|
38
|
+
|
39
|
+
self.assertFalse(analysis['status']['implemented'])
|
40
|
+
self.assertIsNone(analysis['status']['abstract_signature'])
|
41
|
+
self.assertIsNone(analysis['status']['concrete_signature'])
|
42
|
+
self.assertFalse(analysis['status']['signature_match'])
|
43
|
+
self.assertEqual(analysis['status']['type'], 'property')
|
44
|
+
|
45
|
+
def testReflexionConcreteWithAbstractGetNonInheritedImplementation(self):
|
46
|
+
"""Test reflexion con AbstractService y PartiallyImplementedService."""
|
47
|
+
inspector = ReflexionConcreteWithAbstract(PartiallyImplementedService, AbstractService)
|
48
|
+
|
49
|
+
# Get Non-Inherited implementation analysis
|
50
|
+
analysis = inspector.getNonInheritedImplementation()
|
51
|
+
|
52
|
+
self.assertIn('extra', analysis['methods'])
|
53
|
+
self.assertListEqual(analysis['properties'], [])
|
54
|
+
self.assertIn('__annotations__', analysis['attributes'])
|
55
|
+
|
56
|
+
def testReflexionConcreteWithAbstractValidateImplementation(self):
|
57
|
+
"""Test reflexion con AbstractService y PartiallyImplementedService."""
|
58
|
+
inspector = ReflexionConcreteWithAbstract(PartiallyImplementedService, AbstractService)
|
59
|
+
|
60
|
+
# Get Implementation analysis
|
61
|
+
is_valid, issues = inspector.validateImplementation()
|
62
|
+
|
63
|
+
# Verifying implemented methods
|
64
|
+
self.assertFalse(is_valid)
|
65
|
+
self.assertIn('reset', issues['missing'])
|
66
|
+
|
67
|
+
def testReflexionConcreteWithAbstractGetHierarchyAnalysis(self):
|
68
|
+
"""Test reflexion con AbstractService y PartiallyImplementedService."""
|
69
|
+
inspector = ReflexionConcreteWithAbstract(PartiallyImplementedService, AbstractService)
|
70
|
+
|
71
|
+
# Get Hierarchy analysis
|
72
|
+
analysis = inspector.getHierarchyAnalysis()
|
73
|
+
|
74
|
+
# Verifying implemented methods
|
75
|
+
self.assertEqual(analysis['common_ancestors'], [])
|
76
|
+
self.assertIn('AbstractService', analysis['abstract_hierarchy'])
|
77
|
+
self.assertIn('PartiallyImplementedService', analysis['concrete_hierarchy'])
|
78
|
+
|
79
|
+
def testReflexionConcreteWithAbstractGetImplementationCoverage(self):
|
80
|
+
"""Test reflexion con AbstractService y PartiallyImplementedService."""
|
81
|
+
inspector = ReflexionConcreteWithAbstract(PartiallyImplementedService, AbstractService)
|
82
|
+
|
83
|
+
# Get Implementation coverage
|
84
|
+
coverage = inspector.getImplementationCoverage()
|
85
|
+
|
86
|
+
# Verifying implemented methods
|
87
|
+
self.assertTrue(coverage >= 0.4)
|
@@ -3,7 +3,7 @@ from orionis.luminate.support.inspection.reflexion_instance import ReflexionInst
|
|
3
3
|
from orionis.luminate.test.test_case import TestCase
|
4
4
|
from tests.support.inspection.fakes.fake_reflection_instance import BaseFakeClass, FakeClass
|
5
5
|
|
6
|
-
class
|
6
|
+
class TestReflectionInstance(TestCase):
|
7
7
|
"""
|
8
8
|
Unit tests for the Reflection class.
|
9
9
|
"""
|
@@ -2,7 +2,7 @@ from orionis.luminate.support.inspection.reflexion_instance_with_abstract import
|
|
2
2
|
from orionis.luminate.test.test_case import TestCase
|
3
3
|
from tests.support.inspection.fakes.fake_reflection_instance_with_abstract import FakeDataProcessor, IDataProcessor
|
4
4
|
|
5
|
-
class
|
5
|
+
class TestReflexionInstanceWithAbstract(TestCase):
|
6
6
|
|
7
7
|
def testReflexionInstanceWithAbstractGetImplementationAnalysis(self):
|
8
8
|
"""Test reflexion con IDataProcessor y FakeDataProcessor."""
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|