orionis 0.546.0__py3-none-any.whl → 0.547.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- orionis/console/base/scheduler_event_listener.py +0 -17
- orionis/console/contracts/schedule_event_listener.py +0 -18
- orionis/foundation/config/app/entities/app.py +3 -2
- orionis/foundation/config/app/enums/ciphers.py +5 -19
- orionis/foundation/config/session/entities/session.py +2 -2
- orionis/metadata/framework.py +1 -1
- orionis/services/encrypter/encrypter.py +115 -0
- orionis/services/environment/dynamic/caster.py +35 -27
- orionis/services/environment/key/key_generator.py +32 -11
- {orionis-0.546.0.dist-info → orionis-0.547.0.dist-info}/METADATA +1 -1
- {orionis-0.546.0.dist-info → orionis-0.547.0.dist-info}/RECORD +15 -159
- {orionis-0.546.0.dist-info → orionis-0.547.0.dist-info}/top_level.txt +0 -1
- tests/container/__init__.py +0 -0
- tests/container/context/__init__.py +0 -0
- tests/container/context/test_manager.py +0 -38
- tests/container/context/test_scope.py +0 -32
- tests/container/core/__init__.py +0 -0
- tests/container/core/test_advanced_async.py +0 -234
- tests/container/core/test_async_optimizations.py +0 -268
- tests/container/core/test_container.py +0 -453
- tests/container/core/test_singleton.py +0 -122
- tests/container/core/test_thread_safety.py +0 -90
- tests/container/entities/__init__.py +0 -0
- tests/container/entities/test_binding.py +0 -242
- tests/container/enums/__init__.py +0 -0
- tests/container/enums/test_lifetimes.py +0 -97
- tests/container/facades/__init__.py +0 -0
- tests/container/facades/test_facade.py +0 -78
- tests/container/mocks/__init__.py +0 -0
- tests/container/mocks/mock_advanced_async.py +0 -332
- tests/container/mocks/mock_async_optimizations.py +0 -407
- tests/container/mocks/mock_auto_resolution.py +0 -192
- tests/container/mocks/mock_complex_classes.py +0 -792
- tests/container/mocks/mock_simple_classes.py +0 -98
- tests/container/providers/__init__.py +0 -0
- tests/container/providers/test_providers.py +0 -55
- tests/container/validators/__init__.py +0 -0
- tests/container/validators/test_implements.py +0 -186
- tests/container/validators/test_is_abstract_class.py +0 -147
- tests/container/validators/test_is_callable.py +0 -102
- tests/container/validators/test_is_concrete_class.py +0 -160
- tests/container/validators/test_is_instance.py +0 -150
- tests/container/validators/test_is_not_subclass.py +0 -49
- tests/container/validators/test_is_subclass.py +0 -178
- tests/container/validators/test_is_valid_alias.py +0 -147
- tests/container/validators/test_lifetime.py +0 -106
- tests/example/__init__.py +0 -0
- tests/example/test_example.py +0 -725
- tests/foundation/__init__.py +0 -0
- tests/foundation/config/__init__.py +0 -0
- tests/foundation/config/app/__init__.py +0 -0
- tests/foundation/config/app/test_foundation_config_app.py +0 -262
- tests/foundation/config/auth/__init__.py +0 -0
- tests/foundation/config/auth/test_foundation_config_auth.py +0 -29
- tests/foundation/config/cache/__init__.py +0 -0
- tests/foundation/config/cache/test_foundation_config_cache.py +0 -143
- tests/foundation/config/cache/test_foundation_config_cache_file.py +0 -126
- tests/foundation/config/cache/test_foundation_config_cache_stores.py +0 -156
- tests/foundation/config/cors/__init__.py +0 -0
- tests/foundation/config/cors/test_foundation_config_cors.py +0 -190
- tests/foundation/config/database/__init__.py +0 -0
- tests/foundation/config/database/test_foundation_config_database.py +0 -158
- tests/foundation/config/database/test_foundation_config_database_connections.py +0 -203
- tests/foundation/config/database/test_foundation_config_database_mysql.py +0 -354
- tests/foundation/config/database/test_foundation_config_database_oracle.py +0 -288
- tests/foundation/config/database/test_foundation_config_database_pgsql.py +0 -257
- tests/foundation/config/database/test_foundation_config_database_sqlite.py +0 -207
- tests/foundation/config/filesystems/__init__.py +0 -0
- tests/foundation/config/filesystems/test_foundation_config_filesystems.py +0 -160
- tests/foundation/config/filesystems/test_foundation_config_filesystems_aws.py +0 -189
- tests/foundation/config/filesystems/test_foundation_config_filesystems_disks.py +0 -184
- tests/foundation/config/filesystems/test_foundation_config_filesystems_local.py +0 -143
- tests/foundation/config/filesystems/test_foundation_config_filesystems_public.py +0 -184
- tests/foundation/config/logging/__init__.py +0 -0
- tests/foundation/config/logging/test_foundation_config_logging.py +0 -112
- tests/foundation/config/logging/test_foundation_config_logging_channels.py +0 -246
- tests/foundation/config/logging/test_foundation_config_logging_chunked.py +0 -217
- tests/foundation/config/logging/test_foundation_config_logging_daily.py +0 -220
- tests/foundation/config/logging/test_foundation_config_logging_hourly.py +0 -196
- tests/foundation/config/logging/test_foundation_config_logging_monthly.py +0 -214
- tests/foundation/config/logging/test_foundation_config_logging_stack.py +0 -178
- tests/foundation/config/logging/test_foundation_config_logging_weekly.py +0 -224
- tests/foundation/config/mail/__init__.py +0 -0
- tests/foundation/config/mail/test_foundation_config_mail.py +0 -145
- tests/foundation/config/mail/test_foundation_config_mail_file.py +0 -97
- tests/foundation/config/mail/test_foundation_config_mail_mailers.py +0 -106
- tests/foundation/config/mail/test_foundation_config_mail_smtp.py +0 -146
- tests/foundation/config/queue/__init__.py +0 -0
- tests/foundation/config/queue/test_foundation_config_queue.py +0 -88
- tests/foundation/config/queue/test_foundation_config_queue_brokers.py +0 -72
- tests/foundation/config/queue/test_foundation_config_queue_database.py +0 -134
- tests/foundation/config/root/__init__.py +0 -0
- tests/foundation/config/root/test_foundation_config_root_paths.py +0 -112
- tests/foundation/config/session/__init__.py +0 -0
- tests/foundation/config/session/test_foundation_config_session.py +0 -213
- tests/foundation/config/startup/__init__.py +0 -0
- tests/foundation/config/startup/test_foundation_config_startup.py +0 -202
- tests/foundation/config/testing/__init__.py +0 -0
- tests/foundation/config/testing/test_foundation_config_testing.py +0 -235
- tests/metadata/__init__.py +0 -0
- tests/metadata/test_metadata_framework.py +0 -140
- tests/metadata/test_metadata_package.py +0 -139
- tests/services/__init__.py +0 -0
- tests/services/asynchrony/__init__.py +0 -0
- tests/services/asynchrony/test_services_asynchrony_coroutine.py +0 -85
- tests/services/environment/__init__.py +0 -0
- tests/services/environment/test_services_environment.py +0 -226
- tests/services/introspection/__init__.py +0 -0
- tests/services/introspection/dependencies/__init__.py +0 -0
- tests/services/introspection/dependencies/mocks/__init__.py +0 -0
- tests/services/introspection/dependencies/mocks/mock_user.py +0 -30
- tests/services/introspection/dependencies/mocks/mock_user_controller.py +0 -27
- tests/services/introspection/dependencies/mocks/mock_users_permissions.py +0 -41
- tests/services/introspection/dependencies/test_reflect_dependencies.py +0 -261
- tests/services/introspection/reflection/__init__.py +0 -0
- tests/services/introspection/reflection/mock/__init__.py +0 -0
- tests/services/introspection/reflection/mock/fake_reflect_instance.py +0 -1115
- tests/services/introspection/reflection/test_reflection_abstract.py +0 -1011
- tests/services/introspection/reflection/test_reflection_callable.py +0 -206
- tests/services/introspection/reflection/test_reflection_concrete.py +0 -952
- tests/services/introspection/reflection/test_reflection_instance.py +0 -1233
- tests/services/introspection/reflection/test_reflection_module.py +0 -567
- tests/services/introspection/test_reflection.py +0 -462
- tests/services/log/__init__.py +0 -0
- tests/services/log/test_log.py +0 -97
- tests/services/system/__init__.py +0 -0
- tests/services/system/test_services_system_imports.py +0 -204
- tests/services/system/test_services_system_workers.py +0 -131
- tests/support/__init__.py +0 -0
- tests/support/entities/__init__.py +0 -0
- tests/support/entities/mock_dataclass.py +0 -40
- tests/support/entities/test_base.py +0 -64
- tests/support/patterns/__init__.py +0 -0
- tests/support/patterns/singleton/__init__.py +0 -0
- tests/support/patterns/singleton/test_patterns_singleton.py +0 -39
- tests/support/standard/__init__.py +0 -0
- tests/support/standard/test_services_std.py +0 -226
- tests/support/wrapper/__init__.py +0 -0
- tests/support/wrapper/test_services_wrapper_docdict.py +0 -202
- tests/testing/__init__.py +0 -0
- tests/testing/cases/__init__.py +0 -0
- tests/testing/cases/test_testing_asynchronous.py +0 -63
- tests/testing/cases/test_testing_synchronous.py +0 -57
- tests/testing/entities/__init__.py +0 -0
- tests/testing/entities/test_testing_result.py +0 -146
- tests/testing/enums/__init__.py +0 -0
- tests/testing/enums/test_testing_status.py +0 -63
- tests/testing/output/__init__.py +0 -0
- tests/testing/output/test_testing_dumper.py +0 -29
- tests/testing/output/test_testing_printer.py +0 -42
- tests/testing/records/__init__.py +0 -0
- tests/testing/records/test_testing_records.py +0 -171
- tests/testing/test_testing_unit.py +0 -164
- tests/testing/validators/__init__.py +0 -0
- tests/testing/validators/test_testing_validators.py +0 -392
- tests/testing/view/__init__.py +0 -0
- tests/testing/view/test_render.py +0 -30
- {orionis-0.546.0.dist-info → orionis-0.547.0.dist-info}/WHEEL +0 -0
- {orionis-0.546.0.dist-info → orionis-0.547.0.dist-info}/licenses/LICENCE +0 -0
- {orionis-0.546.0.dist-info → orionis-0.547.0.dist-info}/zip-safe +0 -0
|
@@ -1,952 +0,0 @@
|
|
|
1
|
-
from orionis.services.introspection.concretes.reflection import ReflectionConcrete
|
|
2
|
-
from orionis.services.introspection.dependencies.entities.resolve_argument import ResolveArguments
|
|
3
|
-
from tests.services.introspection.reflection.mock.fake_reflect_instance import FakeClass
|
|
4
|
-
from orionis.test.cases.asynchronous import AsyncTestCase
|
|
5
|
-
|
|
6
|
-
class TestServiceReflectionConcrete(AsyncTestCase):
|
|
7
|
-
|
|
8
|
-
async def testGetInstance(self):
|
|
9
|
-
"""
|
|
10
|
-
Test that ReflectionConcrete creates an instance of FakeClass using getInstance.
|
|
11
|
-
|
|
12
|
-
Returns
|
|
13
|
-
-------
|
|
14
|
-
None
|
|
15
|
-
This method asserts that the returned instance is of type FakeClass.
|
|
16
|
-
"""
|
|
17
|
-
reflect = ReflectionConcrete(FakeClass)
|
|
18
|
-
instance = reflect.getInstance()
|
|
19
|
-
self.assertIsInstance(instance, FakeClass)
|
|
20
|
-
|
|
21
|
-
async def testGetClass(self):
|
|
22
|
-
"""
|
|
23
|
-
Test that ReflectionConcrete.getClass returns the correct class object.
|
|
24
|
-
|
|
25
|
-
Returns
|
|
26
|
-
-------
|
|
27
|
-
None
|
|
28
|
-
Asserts that the returned class is FakeClass.
|
|
29
|
-
"""
|
|
30
|
-
reflect = ReflectionConcrete(FakeClass)
|
|
31
|
-
cls = reflect.getClass()
|
|
32
|
-
self.assertEqual(cls, FakeClass)
|
|
33
|
-
|
|
34
|
-
async def testGetClassName(self):
|
|
35
|
-
"""
|
|
36
|
-
Test that ReflectionConcrete retrieves the correct class name.
|
|
37
|
-
|
|
38
|
-
Returns
|
|
39
|
-
-------
|
|
40
|
-
None
|
|
41
|
-
Asserts that the returned class name matches 'FakeClass'.
|
|
42
|
-
"""
|
|
43
|
-
reflect = ReflectionConcrete(FakeClass)
|
|
44
|
-
class_name = reflect.getClassName()
|
|
45
|
-
self.assertEqual(class_name, 'FakeClass')
|
|
46
|
-
|
|
47
|
-
async def testGetModuleName(self):
|
|
48
|
-
"""
|
|
49
|
-
Test that ReflectionConcrete.getModuleName returns the correct module name for FakeClass.
|
|
50
|
-
|
|
51
|
-
Returns
|
|
52
|
-
-------
|
|
53
|
-
None
|
|
54
|
-
Asserts that the returned module name matches the expected string.
|
|
55
|
-
"""
|
|
56
|
-
reflect = ReflectionConcrete(FakeClass)
|
|
57
|
-
module_name = reflect.getModuleName()
|
|
58
|
-
self.assertEqual(module_name, 'tests.services.introspection.reflection.mock.fake_reflect_instance')
|
|
59
|
-
|
|
60
|
-
async def testGetModuleWithClassName(self):
|
|
61
|
-
"""
|
|
62
|
-
Test that ReflectionConcrete.getModuleWithClassName returns the fully qualified module and class name.
|
|
63
|
-
|
|
64
|
-
Returns
|
|
65
|
-
-------
|
|
66
|
-
None
|
|
67
|
-
Asserts that the returned string matches the expected module path and class name.
|
|
68
|
-
"""
|
|
69
|
-
reflect = ReflectionConcrete(FakeClass)
|
|
70
|
-
module_with_class_name = reflect.getModuleWithClassName()
|
|
71
|
-
self.assertEqual(module_with_class_name, 'tests.services.introspection.reflection.mock.fake_reflect_instance.FakeClass')
|
|
72
|
-
|
|
73
|
-
async def testGetDocstring(self):
|
|
74
|
-
"""
|
|
75
|
-
Test that ReflectionConcrete.getDocstring returns the correct docstring for FakeClass.
|
|
76
|
-
|
|
77
|
-
Returns
|
|
78
|
-
-------
|
|
79
|
-
None
|
|
80
|
-
Asserts that the returned docstring matches FakeClass.__doc__.
|
|
81
|
-
"""
|
|
82
|
-
reflect = ReflectionConcrete(FakeClass)
|
|
83
|
-
docstring = reflect.getDocstring()
|
|
84
|
-
self.assertEqual(docstring, FakeClass.__doc__)
|
|
85
|
-
|
|
86
|
-
async def testGetBaseClasses(self):
|
|
87
|
-
"""
|
|
88
|
-
Test that ReflectionConcrete.getBaseClasses returns the base classes of FakeClass.
|
|
89
|
-
|
|
90
|
-
Returns
|
|
91
|
-
-------
|
|
92
|
-
None
|
|
93
|
-
Asserts that the direct base class of FakeClass is included in the returned list.
|
|
94
|
-
"""
|
|
95
|
-
reflect = ReflectionConcrete(FakeClass)
|
|
96
|
-
base_classes = reflect.getBaseClasses()
|
|
97
|
-
self.assertIn(FakeClass.__base__, base_classes)
|
|
98
|
-
|
|
99
|
-
async def testGetSourceCode(self):
|
|
100
|
-
"""
|
|
101
|
-
Test that ReflectionConcrete.getSourceCode retrieves the source code of FakeClass.
|
|
102
|
-
|
|
103
|
-
Returns
|
|
104
|
-
-------
|
|
105
|
-
None
|
|
106
|
-
Asserts that the returned source code starts with the expected class definition line.
|
|
107
|
-
"""
|
|
108
|
-
reflect = ReflectionConcrete(FakeClass)
|
|
109
|
-
source_code = reflect.getSourceCode()
|
|
110
|
-
self.assertTrue(source_code.startswith('class FakeClass'))
|
|
111
|
-
|
|
112
|
-
async def testGetFile(self):
|
|
113
|
-
"""
|
|
114
|
-
Test that ReflectionConcrete.getFile returns the correct file path for FakeClass.
|
|
115
|
-
|
|
116
|
-
Returns
|
|
117
|
-
-------
|
|
118
|
-
None
|
|
119
|
-
Asserts that the returned file path ends with 'fake_reflect_instance.py'.
|
|
120
|
-
"""
|
|
121
|
-
reflect = ReflectionConcrete(FakeClass)
|
|
122
|
-
file_path = reflect.getFile()
|
|
123
|
-
self.assertTrue(file_path.endswith('fake_reflect_instance.py'))
|
|
124
|
-
|
|
125
|
-
async def testGetAnnotations(self):
|
|
126
|
-
"""
|
|
127
|
-
Test that ReflectionConcrete.getAnnotations retrieves the annotations of FakeClass.
|
|
128
|
-
|
|
129
|
-
Returns
|
|
130
|
-
-------
|
|
131
|
-
None
|
|
132
|
-
Asserts that 'public_attr' is present in the returned annotations.
|
|
133
|
-
"""
|
|
134
|
-
reflect = ReflectionConcrete(FakeClass)
|
|
135
|
-
annotations = reflect.getAnnotations()
|
|
136
|
-
self.assertIn('public_attr', annotations)
|
|
137
|
-
|
|
138
|
-
async def testHasAttribute(self):
|
|
139
|
-
"""
|
|
140
|
-
Test whether ReflectionConcrete correctly identifies the presence or absence of attributes.
|
|
141
|
-
|
|
142
|
-
Returns
|
|
143
|
-
-------
|
|
144
|
-
None
|
|
145
|
-
Asserts that hasAttribute returns True for an existing attribute and False for a non-existent attribute.
|
|
146
|
-
"""
|
|
147
|
-
reflect = ReflectionConcrete(FakeClass)
|
|
148
|
-
self.assertTrue(reflect.hasAttribute('public_attr'))
|
|
149
|
-
self.assertFalse(reflect.hasAttribute('non_existent_attr'))
|
|
150
|
-
|
|
151
|
-
async def testGetAttribute(self):
|
|
152
|
-
"""
|
|
153
|
-
Test ReflectionConcrete.getAttribute for retrieving attribute values.
|
|
154
|
-
|
|
155
|
-
Returns
|
|
156
|
-
-------
|
|
157
|
-
None
|
|
158
|
-
Asserts correct value for an existing attribute and None for a non-existent attribute.
|
|
159
|
-
"""
|
|
160
|
-
reflect = ReflectionConcrete(FakeClass)
|
|
161
|
-
self.assertEqual(reflect.getAttribute('public_attr'), 42)
|
|
162
|
-
self.assertIsNone(reflect.getAttribute('non_existent_attr'))
|
|
163
|
-
|
|
164
|
-
async def testSetAttribute(self):
|
|
165
|
-
"""
|
|
166
|
-
Test ReflectionConcrete.setAttribute and getAttribute for setting and retrieving attributes.
|
|
167
|
-
|
|
168
|
-
Returns
|
|
169
|
-
-------
|
|
170
|
-
None
|
|
171
|
-
Asserts that public, protected, and private attributes can be set and retrieved correctly.
|
|
172
|
-
"""
|
|
173
|
-
reflect = ReflectionConcrete(FakeClass)
|
|
174
|
-
self.assertTrue(reflect.setAttribute('name', 'Orionis Framework'))
|
|
175
|
-
self.assertEqual(reflect.getAttribute('name'), 'Orionis Framework')
|
|
176
|
-
self.assertTrue(reflect.setAttribute('_version', '1.x'))
|
|
177
|
-
self.assertEqual(reflect.getAttribute('_version'), '1.x')
|
|
178
|
-
self.assertTrue(reflect.setAttribute('__python', '3.13+'))
|
|
179
|
-
self.assertEqual(reflect.getAttribute('__python'), '3.13+')
|
|
180
|
-
|
|
181
|
-
async def testRemoveAttribute(self):
|
|
182
|
-
"""
|
|
183
|
-
Test the removal of an attribute from a reflected class instance.
|
|
184
|
-
|
|
185
|
-
Returns
|
|
186
|
-
-------
|
|
187
|
-
None
|
|
188
|
-
Asserts that an attribute can be set, removed, and is no longer present after removal.
|
|
189
|
-
"""
|
|
190
|
-
reflect = ReflectionConcrete(FakeClass)
|
|
191
|
-
reflect.setAttribute('new_attr', 100)
|
|
192
|
-
self.assertTrue(reflect.removeAttribute('new_attr'))
|
|
193
|
-
self.assertFalse(reflect.hasAttribute('new_attr'))
|
|
194
|
-
|
|
195
|
-
async def testGetAttributes(self):
|
|
196
|
-
"""
|
|
197
|
-
Test that ReflectionConcrete.getAttributes retrieves all attribute names from FakeClass.
|
|
198
|
-
|
|
199
|
-
Returns
|
|
200
|
-
-------
|
|
201
|
-
None
|
|
202
|
-
Asserts that public, protected, and private attributes are present in the returned list.
|
|
203
|
-
"""
|
|
204
|
-
reflect = ReflectionConcrete(FakeClass)
|
|
205
|
-
attributes = reflect.getAttributes()
|
|
206
|
-
self.assertIn('public_attr', attributes)
|
|
207
|
-
self.assertIn('_protected_attr', attributes)
|
|
208
|
-
self.assertIn('__private_attr', attributes)
|
|
209
|
-
|
|
210
|
-
async def testGetPublicAttributes(self):
|
|
211
|
-
"""
|
|
212
|
-
Test that ReflectionConcrete.getPublicAttributes retrieves only public attributes.
|
|
213
|
-
|
|
214
|
-
Returns
|
|
215
|
-
-------
|
|
216
|
-
None
|
|
217
|
-
Asserts that only public attributes are included in the result.
|
|
218
|
-
"""
|
|
219
|
-
reflect = ReflectionConcrete(FakeClass)
|
|
220
|
-
public_attributes = reflect.getPublicAttributes()
|
|
221
|
-
self.assertIn('public_attr', public_attributes)
|
|
222
|
-
self.assertNotIn('_protected_attr', public_attributes)
|
|
223
|
-
self.assertNotIn('__private_attr', public_attributes)
|
|
224
|
-
|
|
225
|
-
async def testGetProtectedAttributes(self):
|
|
226
|
-
"""
|
|
227
|
-
Test that ReflectionConcrete.getProtectedAttributes identifies protected attributes.
|
|
228
|
-
|
|
229
|
-
Returns
|
|
230
|
-
-------
|
|
231
|
-
None
|
|
232
|
-
Asserts that only protected attributes are included in the result.
|
|
233
|
-
"""
|
|
234
|
-
reflect = ReflectionConcrete(FakeClass)
|
|
235
|
-
protected_attributes = reflect.getProtectedAttributes()
|
|
236
|
-
self.assertIn('_protected_attr', protected_attributes)
|
|
237
|
-
self.assertNotIn('public_attr', protected_attributes)
|
|
238
|
-
self.assertNotIn('__private_attr', protected_attributes)
|
|
239
|
-
|
|
240
|
-
async def testGetPrivateAttributes(self):
|
|
241
|
-
"""
|
|
242
|
-
Test that ReflectionConcrete.getPrivateAttributes identifies private attributes.
|
|
243
|
-
|
|
244
|
-
Returns
|
|
245
|
-
-------
|
|
246
|
-
None
|
|
247
|
-
Asserts that only private attributes are included in the result.
|
|
248
|
-
"""
|
|
249
|
-
reflect = ReflectionConcrete(FakeClass)
|
|
250
|
-
private_attributes = reflect.getPrivateAttributes()
|
|
251
|
-
self.assertIn('__private_attr', private_attributes)
|
|
252
|
-
self.assertNotIn('public_attr', private_attributes)
|
|
253
|
-
self.assertNotIn('_protected_attr', private_attributes)
|
|
254
|
-
|
|
255
|
-
async def testGetDunderAttributes(self):
|
|
256
|
-
"""
|
|
257
|
-
Test that ReflectionConcrete.getDunderAttributes retrieves dunder attributes.
|
|
258
|
-
|
|
259
|
-
Returns
|
|
260
|
-
-------
|
|
261
|
-
None
|
|
262
|
-
Asserts that '__dd__' is present in the returned list of dunder attributes.
|
|
263
|
-
"""
|
|
264
|
-
reflect = ReflectionConcrete(FakeClass)
|
|
265
|
-
dunder_attributes = reflect.getDunderAttributes()
|
|
266
|
-
self.assertIn('__dd__', dunder_attributes)
|
|
267
|
-
|
|
268
|
-
async def testGetMagicAttributes(self):
|
|
269
|
-
"""
|
|
270
|
-
Test that ReflectionConcrete.getMagicAttributes retrieves magic (dunder) attributes.
|
|
271
|
-
|
|
272
|
-
Returns
|
|
273
|
-
-------
|
|
274
|
-
None
|
|
275
|
-
Asserts that '__dd__' is present in the returned list of magic attributes.
|
|
276
|
-
"""
|
|
277
|
-
reflect = ReflectionConcrete(FakeClass)
|
|
278
|
-
magic_attributes = reflect.getMagicAttributes()
|
|
279
|
-
self.assertIn('__dd__', magic_attributes)
|
|
280
|
-
|
|
281
|
-
async def testHasMethod(self):
|
|
282
|
-
"""
|
|
283
|
-
Test that ReflectionConcrete.hasMethod identifies the presence of methods.
|
|
284
|
-
|
|
285
|
-
Returns
|
|
286
|
-
-------
|
|
287
|
-
None
|
|
288
|
-
Asserts that an existing method is found and a non-existent method is not found.
|
|
289
|
-
"""
|
|
290
|
-
reflect = ReflectionConcrete(FakeClass)
|
|
291
|
-
self.assertTrue(reflect.hasMethod('instanceSyncMethod'))
|
|
292
|
-
self.assertFalse(reflect.hasMethod('non_existent_method'))
|
|
293
|
-
|
|
294
|
-
async def testCallMethod(self):
|
|
295
|
-
"""
|
|
296
|
-
Test that ReflectionConcrete.callMethod invokes a synchronous method with arguments.
|
|
297
|
-
|
|
298
|
-
Returns
|
|
299
|
-
-------
|
|
300
|
-
None
|
|
301
|
-
Asserts that the result of calling 'instanceSyncMethod' with arguments 2 and 3 is 5.
|
|
302
|
-
"""
|
|
303
|
-
reflect = ReflectionConcrete(FakeClass)
|
|
304
|
-
reflect.getInstance() # Ensure instance is created
|
|
305
|
-
result = reflect.callMethod('instanceSyncMethod', 2, 3)
|
|
306
|
-
self.assertEqual(result, 5)
|
|
307
|
-
|
|
308
|
-
async def testCallAsyncMethod(self):
|
|
309
|
-
"""
|
|
310
|
-
Test that ReflectionConcrete can call an asynchronous instance method.
|
|
311
|
-
|
|
312
|
-
Returns
|
|
313
|
-
-------
|
|
314
|
-
None
|
|
315
|
-
Asserts that the result of calling 'instanceAsyncMethod' with arguments 2 and 3 is 5.
|
|
316
|
-
"""
|
|
317
|
-
reflect = ReflectionConcrete(FakeClass)
|
|
318
|
-
reflect.getInstance() # Ensure instance is created
|
|
319
|
-
result = await reflect.callMethod('instanceAsyncMethod', 2, 3)
|
|
320
|
-
self.assertEqual(result, 5)
|
|
321
|
-
|
|
322
|
-
async def testSetMethod(self):
|
|
323
|
-
"""
|
|
324
|
-
Test that ReflectionConcrete can dynamically set and call synchronous and asynchronous methods.
|
|
325
|
-
|
|
326
|
-
Returns
|
|
327
|
-
-------
|
|
328
|
-
None
|
|
329
|
-
Asserts correct results for both sync and async dynamically set methods.
|
|
330
|
-
"""
|
|
331
|
-
def mockSyncMethod(cls:FakeClass, num1, num2):
|
|
332
|
-
return num1 + num2
|
|
333
|
-
|
|
334
|
-
async def mockAsyncMethod(cls:FakeClass, num1, num2):
|
|
335
|
-
import asyncio
|
|
336
|
-
await asyncio.sleep(0.1)
|
|
337
|
-
return num1 + num2
|
|
338
|
-
|
|
339
|
-
reflect = ReflectionConcrete(FakeClass)
|
|
340
|
-
reflect.getInstance()
|
|
341
|
-
reflect.setMethod('mockSyncMethodConcrete', mockSyncMethod)
|
|
342
|
-
reflect.setMethod('mockAsyncMethodConcrete', mockAsyncMethod)
|
|
343
|
-
sync_result = reflect.callMethod('mockSyncMethodConcrete', 2, 3)
|
|
344
|
-
async_result = await reflect.callMethod('mockAsyncMethodConcrete', 2, 3)
|
|
345
|
-
self.assertEqual(sync_result, 5)
|
|
346
|
-
self.assertEqual(async_result, 5)
|
|
347
|
-
|
|
348
|
-
async def testRemoveMethod(self):
|
|
349
|
-
"""
|
|
350
|
-
Test the removal of a dynamically added private method from a reflected class instance.
|
|
351
|
-
|
|
352
|
-
Returns
|
|
353
|
-
-------
|
|
354
|
-
None
|
|
355
|
-
Asserts that the method exists after addition and is removed successfully.
|
|
356
|
-
"""
|
|
357
|
-
def _testProtectedMethod(cls:FakeClass, x, y):
|
|
358
|
-
return x + y
|
|
359
|
-
|
|
360
|
-
def __testPrivateMethod(cls:FakeClass, x, y):
|
|
361
|
-
return x + y
|
|
362
|
-
|
|
363
|
-
reflect = ReflectionConcrete(FakeClass)
|
|
364
|
-
reflect.getInstance()
|
|
365
|
-
reflect.setMethod('__testPrivateMethod', __testPrivateMethod)
|
|
366
|
-
self.assertTrue(reflect.hasMethod('__testPrivateMethod'))
|
|
367
|
-
reflect.removeMethod('__testPrivateMethod')
|
|
368
|
-
self.assertFalse(reflect.hasMethod('__testPrivateMethod'))
|
|
369
|
-
|
|
370
|
-
async def testGetMethodSignature(self):
|
|
371
|
-
"""
|
|
372
|
-
Test that ReflectionConcrete.getMethodSignature retrieves the signature of a method.
|
|
373
|
-
|
|
374
|
-
Returns
|
|
375
|
-
-------
|
|
376
|
-
None
|
|
377
|
-
Asserts that the returned signature string matches the expected format.
|
|
378
|
-
"""
|
|
379
|
-
reflect = ReflectionConcrete(FakeClass)
|
|
380
|
-
signature = reflect.getMethodSignature('instanceSyncMethod')
|
|
381
|
-
self.assertEqual(str(signature), '(self, x: int, y: int) -> int')
|
|
382
|
-
|
|
383
|
-
async def testGetMethods(self):
|
|
384
|
-
"""
|
|
385
|
-
Test that ReflectionConcrete.getMethods retrieves method names of FakeClass.
|
|
386
|
-
|
|
387
|
-
Returns
|
|
388
|
-
-------
|
|
389
|
-
None
|
|
390
|
-
Asserts that both synchronous and asynchronous instance methods are present.
|
|
391
|
-
"""
|
|
392
|
-
reflect = ReflectionConcrete(FakeClass)
|
|
393
|
-
methods = reflect.getMethods()
|
|
394
|
-
self.assertIn('instanceSyncMethod', methods)
|
|
395
|
-
self.assertIn('instanceAsyncMethod', methods)
|
|
396
|
-
|
|
397
|
-
async def testGetPublicMethods(self):
|
|
398
|
-
"""
|
|
399
|
-
Test that ReflectionConcrete.getPublicMethods returns only public methods.
|
|
400
|
-
|
|
401
|
-
Returns
|
|
402
|
-
-------
|
|
403
|
-
None
|
|
404
|
-
Asserts that public methods are included and protected/private methods are excluded.
|
|
405
|
-
"""
|
|
406
|
-
reflect = ReflectionConcrete(FakeClass)
|
|
407
|
-
public_methods = reflect.getPublicMethods()
|
|
408
|
-
self.assertIn('instanceSyncMethod', public_methods)
|
|
409
|
-
self.assertNotIn('_protected_method', public_methods)
|
|
410
|
-
self.assertNotIn('__private_method', public_methods)
|
|
411
|
-
|
|
412
|
-
async def testGetPublicSyncMethods(self):
|
|
413
|
-
"""
|
|
414
|
-
Test that ReflectionConcrete.getPublicSyncMethods returns only public synchronous methods.
|
|
415
|
-
|
|
416
|
-
Returns
|
|
417
|
-
-------
|
|
418
|
-
None
|
|
419
|
-
Asserts that only public synchronous methods are included in the result.
|
|
420
|
-
"""
|
|
421
|
-
reflect = ReflectionConcrete(FakeClass)
|
|
422
|
-
public_sync_methods = reflect.getPublicSyncMethods()
|
|
423
|
-
self.assertIn('instanceSyncMethod', public_sync_methods)
|
|
424
|
-
self.assertNotIn('_protected_method', public_sync_methods)
|
|
425
|
-
self.assertNotIn('__private_method', public_sync_methods)
|
|
426
|
-
|
|
427
|
-
async def testGetPublicAsyncMethods(self):
|
|
428
|
-
"""
|
|
429
|
-
Test that ReflectionConcrete.getPublicAsyncMethods identifies public asynchronous methods.
|
|
430
|
-
|
|
431
|
-
Returns
|
|
432
|
-
-------
|
|
433
|
-
None
|
|
434
|
-
Asserts that only public async methods are included in the result.
|
|
435
|
-
"""
|
|
436
|
-
reflect = ReflectionConcrete(FakeClass)
|
|
437
|
-
public_async_methods = reflect.getPublicAsyncMethods()
|
|
438
|
-
self.assertIn('instanceAsyncMethod', public_async_methods)
|
|
439
|
-
self.assertNotIn('_protected_async_method', public_async_methods)
|
|
440
|
-
self.assertNotIn('__private_async_method', public_async_methods)
|
|
441
|
-
|
|
442
|
-
async def testGetProtectedMethods(self):
|
|
443
|
-
"""
|
|
444
|
-
Test that ReflectionConcrete.getProtectedMethods identifies protected methods.
|
|
445
|
-
|
|
446
|
-
Returns
|
|
447
|
-
-------
|
|
448
|
-
None
|
|
449
|
-
Asserts that only protected methods are included in the result.
|
|
450
|
-
"""
|
|
451
|
-
reflect = ReflectionConcrete(FakeClass)
|
|
452
|
-
protected_methods = reflect.getProtectedMethods()
|
|
453
|
-
self.assertIn('_protectedAsyncMethod', protected_methods)
|
|
454
|
-
self.assertNotIn('instanceSyncMethod', protected_methods)
|
|
455
|
-
self.assertNotIn('__privateSyncMethod', protected_methods)
|
|
456
|
-
|
|
457
|
-
async def testGetProtectedSyncMethods(self):
|
|
458
|
-
"""
|
|
459
|
-
Test that ReflectionConcrete.getProtectedSyncMethods identifies protected synchronous methods.
|
|
460
|
-
|
|
461
|
-
Returns
|
|
462
|
-
-------
|
|
463
|
-
None
|
|
464
|
-
Asserts that only protected synchronous methods are included in the result.
|
|
465
|
-
"""
|
|
466
|
-
reflect = ReflectionConcrete(FakeClass)
|
|
467
|
-
protected_sync_methods = reflect.getProtectedSyncMethods()
|
|
468
|
-
self.assertIn('_protectedsyncMethod', protected_sync_methods)
|
|
469
|
-
self.assertNotIn('instanceAsyncMethod', protected_sync_methods)
|
|
470
|
-
self.assertNotIn('__privateSyncMethod', protected_sync_methods)
|
|
471
|
-
|
|
472
|
-
async def testGetProtectedAsyncMethods(self):
|
|
473
|
-
"""
|
|
474
|
-
Test that ReflectionConcrete.getProtectedAsyncMethods returns only protected async methods.
|
|
475
|
-
|
|
476
|
-
Returns
|
|
477
|
-
-------
|
|
478
|
-
None
|
|
479
|
-
Asserts that only protected async methods are included in the result.
|
|
480
|
-
"""
|
|
481
|
-
reflect = ReflectionConcrete(FakeClass)
|
|
482
|
-
protected_async_methods = reflect.getProtectedAsyncMethods()
|
|
483
|
-
self.assertIn('_protectedAsyncMethod', protected_async_methods)
|
|
484
|
-
self.assertNotIn('instanceSyncMethod', protected_async_methods)
|
|
485
|
-
self.assertNotIn('__privateSyncMethod', protected_async_methods)
|
|
486
|
-
|
|
487
|
-
async def testGetPrivateMethods(self):
|
|
488
|
-
"""
|
|
489
|
-
Test that ReflectionConcrete.getPrivateMethods returns only private methods.
|
|
490
|
-
|
|
491
|
-
Returns
|
|
492
|
-
-------
|
|
493
|
-
None
|
|
494
|
-
Asserts that only private methods are included in the result.
|
|
495
|
-
"""
|
|
496
|
-
reflect = ReflectionConcrete(FakeClass)
|
|
497
|
-
private_methods = reflect.getPrivateMethods()
|
|
498
|
-
self.assertIn('__privateSyncMethod', private_methods)
|
|
499
|
-
self.assertNotIn('instanceSyncMethod', private_methods)
|
|
500
|
-
self.assertNotIn('_protectedAsyncMethod', private_methods)
|
|
501
|
-
|
|
502
|
-
async def testGetPrivateSyncMethods(self):
|
|
503
|
-
"""
|
|
504
|
-
Test that ReflectionConcrete.getPrivateSyncMethods returns only private sync methods.
|
|
505
|
-
|
|
506
|
-
Returns
|
|
507
|
-
-------
|
|
508
|
-
None
|
|
509
|
-
Asserts that only private sync methods are included in the result.
|
|
510
|
-
"""
|
|
511
|
-
reflect = ReflectionConcrete(FakeClass)
|
|
512
|
-
private_sync_methods = reflect.getPrivateSyncMethods()
|
|
513
|
-
self.assertIn('__privateSyncMethod', private_sync_methods)
|
|
514
|
-
self.assertNotIn('instanceAsyncMethod', private_sync_methods)
|
|
515
|
-
self.assertNotIn('_protectedAsyncMethod', private_sync_methods)
|
|
516
|
-
|
|
517
|
-
async def testGetPrivateAsyncMethods(self):
|
|
518
|
-
"""
|
|
519
|
-
Test that ReflectionConcrete.getPrivateAsyncMethods returns only private async methods.
|
|
520
|
-
|
|
521
|
-
Returns
|
|
522
|
-
-------
|
|
523
|
-
None
|
|
524
|
-
Asserts that only private async methods are included in the result.
|
|
525
|
-
"""
|
|
526
|
-
reflect = ReflectionConcrete(FakeClass)
|
|
527
|
-
private_async_methods = reflect.getPrivateAsyncMethods()
|
|
528
|
-
self.assertIn('__privateAsyncMethod', private_async_methods)
|
|
529
|
-
self.assertNotIn('instanceSyncMethod', private_async_methods)
|
|
530
|
-
self.assertNotIn('_protectedAsyncMethod', private_async_methods)
|
|
531
|
-
|
|
532
|
-
async def testGetPublicClassMethods(self):
|
|
533
|
-
"""
|
|
534
|
-
Test that ReflectionConcrete.getPublicClassMethods returns only public class methods.
|
|
535
|
-
|
|
536
|
-
Returns
|
|
537
|
-
-------
|
|
538
|
-
None
|
|
539
|
-
Asserts that only public class methods are included in the result.
|
|
540
|
-
"""
|
|
541
|
-
reflect = ReflectionConcrete(FakeClass)
|
|
542
|
-
public_class_methods = reflect.getPublicClassMethods()
|
|
543
|
-
self.assertIn('classSyncMethod', public_class_methods)
|
|
544
|
-
self.assertNotIn('_protected_class_method', public_class_methods)
|
|
545
|
-
self.assertNotIn('__private_class_method', public_class_methods)
|
|
546
|
-
|
|
547
|
-
async def testGetPublicClassSyncMethods(self):
|
|
548
|
-
"""
|
|
549
|
-
Test that ReflectionConcrete.getPublicClassSyncMethods returns only public class sync methods.
|
|
550
|
-
|
|
551
|
-
Returns
|
|
552
|
-
-------
|
|
553
|
-
None
|
|
554
|
-
Asserts that only public class sync methods are included in the result.
|
|
555
|
-
"""
|
|
556
|
-
reflect = ReflectionConcrete(FakeClass)
|
|
557
|
-
public_class_sync_methods = reflect.getPublicClassSyncMethods()
|
|
558
|
-
self.assertIn('classSyncMethod', public_class_sync_methods)
|
|
559
|
-
self.assertNotIn('_protected_class_method', public_class_sync_methods)
|
|
560
|
-
self.assertNotIn('__private_class_method', public_class_sync_methods)
|
|
561
|
-
|
|
562
|
-
async def testGetPublicClassAsyncMethods(self):
|
|
563
|
-
"""
|
|
564
|
-
Test that ReflectionConcrete.getPublicClassAsyncMethods returns only public class async methods.
|
|
565
|
-
|
|
566
|
-
Returns
|
|
567
|
-
-------
|
|
568
|
-
None
|
|
569
|
-
Asserts that only public class async methods are included in the result.
|
|
570
|
-
"""
|
|
571
|
-
reflect = ReflectionConcrete(FakeClass)
|
|
572
|
-
public_class_async_methods = reflect.getPublicClassAsyncMethods()
|
|
573
|
-
self.assertIn('classAsyncMethod', public_class_async_methods)
|
|
574
|
-
self.assertNotIn('_protected_class_async_method', public_class_async_methods)
|
|
575
|
-
self.assertNotIn('__private_class_async_method', public_class_async_methods)
|
|
576
|
-
|
|
577
|
-
async def testGetProtectedClassMethods(self):
|
|
578
|
-
"""
|
|
579
|
-
Test that ReflectionConcrete.getProtectedClassMethods returns only protected class methods.
|
|
580
|
-
|
|
581
|
-
Returns
|
|
582
|
-
-------
|
|
583
|
-
None
|
|
584
|
-
Asserts that only protected class methods are included in the result.
|
|
585
|
-
"""
|
|
586
|
-
reflect = ReflectionConcrete(FakeClass)
|
|
587
|
-
protected_class_methods = reflect.getProtectedClassMethods()
|
|
588
|
-
self.assertIn('_classMethodProtected', protected_class_methods)
|
|
589
|
-
self.assertNotIn('classSyncMethod', protected_class_methods)
|
|
590
|
-
self.assertNotIn('__classMethodPrivate', protected_class_methods)
|
|
591
|
-
|
|
592
|
-
async def testGetProtectedClassSyncMethods(self):
|
|
593
|
-
"""
|
|
594
|
-
Test that ReflectionConcrete.getProtectedClassSyncMethods returns only protected class sync methods.
|
|
595
|
-
|
|
596
|
-
Returns
|
|
597
|
-
-------
|
|
598
|
-
None
|
|
599
|
-
Asserts that only protected class sync methods are included in the result.
|
|
600
|
-
"""
|
|
601
|
-
reflect = ReflectionConcrete(FakeClass)
|
|
602
|
-
protected_class_sync_methods = reflect.getProtectedClassSyncMethods()
|
|
603
|
-
self.assertIn('_classMethodProtected', protected_class_sync_methods)
|
|
604
|
-
self.assertNotIn('classSyncMethod', protected_class_sync_methods)
|
|
605
|
-
self.assertNotIn('__classSyncMethodPrivate', protected_class_sync_methods)
|
|
606
|
-
|
|
607
|
-
async def testGetProtectedClassAsyncMethods(self):
|
|
608
|
-
"""
|
|
609
|
-
Test that ReflectionConcrete.getProtectedClassAsyncMethods returns only protected class async methods.
|
|
610
|
-
|
|
611
|
-
Returns
|
|
612
|
-
-------
|
|
613
|
-
None
|
|
614
|
-
Asserts that only protected class async methods are included in the result.
|
|
615
|
-
"""
|
|
616
|
-
reflect = ReflectionConcrete(FakeClass)
|
|
617
|
-
protected_class_async_methods = reflect.getProtectedClassAsyncMethods()
|
|
618
|
-
self.assertIn('_classAsyncMethodProtected', protected_class_async_methods)
|
|
619
|
-
self.assertNotIn('classAsyncMethod', protected_class_async_methods)
|
|
620
|
-
self.assertNotIn('__classAsyncMethodPrivate', protected_class_async_methods)
|
|
621
|
-
|
|
622
|
-
async def testGetPrivateClassMethods(self):
|
|
623
|
-
"""
|
|
624
|
-
Test that ReflectionConcrete.getPrivateClassMethods returns only private class methods.
|
|
625
|
-
|
|
626
|
-
Returns
|
|
627
|
-
-------
|
|
628
|
-
None
|
|
629
|
-
Asserts that only private class methods are included in the result.
|
|
630
|
-
"""
|
|
631
|
-
reflect = ReflectionConcrete(FakeClass)
|
|
632
|
-
private_class_methods = reflect.getPrivateClassMethods()
|
|
633
|
-
self.assertIn('__classMethodPrivate', private_class_methods)
|
|
634
|
-
self.assertNotIn('classSyncMethod', private_class_methods)
|
|
635
|
-
self.assertNotIn('_classMethodProtected', private_class_methods)
|
|
636
|
-
|
|
637
|
-
async def testGetPrivateClassSyncMethods(self):
|
|
638
|
-
"""
|
|
639
|
-
Test that ReflectionConcrete.getPrivateClassSyncMethods returns only private class sync methods.
|
|
640
|
-
|
|
641
|
-
Returns
|
|
642
|
-
-------
|
|
643
|
-
None
|
|
644
|
-
Asserts that only private class sync methods are included in the result.
|
|
645
|
-
"""
|
|
646
|
-
reflect = ReflectionConcrete(FakeClass)
|
|
647
|
-
private_class_methods = reflect.getPrivateClassSyncMethods()
|
|
648
|
-
self.assertIn('__classMethodPrivate', private_class_methods)
|
|
649
|
-
self.assertNotIn('classSyncMethod', private_class_methods)
|
|
650
|
-
self.assertNotIn('_classMethodProtected', private_class_methods)
|
|
651
|
-
|
|
652
|
-
async def testGetPrivateClassAsyncMethods(self):
|
|
653
|
-
"""
|
|
654
|
-
Test that ReflectionConcrete.getPrivateClassAsyncMethods returns only private class async methods.
|
|
655
|
-
|
|
656
|
-
Returns
|
|
657
|
-
-------
|
|
658
|
-
None
|
|
659
|
-
Asserts that only private class async methods are included in the result.
|
|
660
|
-
"""
|
|
661
|
-
reflect = ReflectionConcrete(FakeClass)
|
|
662
|
-
private_class_async_methods = reflect.getPrivateClassAsyncMethods()
|
|
663
|
-
self.assertIn('__classAsyncMethodPrivate', private_class_async_methods)
|
|
664
|
-
self.assertNotIn('classAsyncMethod', private_class_async_methods)
|
|
665
|
-
self.assertNotIn('_classAsyncMethodProtected', private_class_async_methods)
|
|
666
|
-
|
|
667
|
-
async def testGetPublicStaticMethods(self):
|
|
668
|
-
"""
|
|
669
|
-
Test that ReflectionConcrete.getPublicStaticMethods returns only public static methods.
|
|
670
|
-
|
|
671
|
-
Returns
|
|
672
|
-
-------
|
|
673
|
-
None
|
|
674
|
-
Asserts that only public static methods are included in the result.
|
|
675
|
-
"""
|
|
676
|
-
reflect = ReflectionConcrete(FakeClass)
|
|
677
|
-
public_static_methods = reflect.getPublicStaticMethods()
|
|
678
|
-
self.assertIn('staticMethod', public_static_methods)
|
|
679
|
-
self.assertIn('staticAsyncMethod', public_static_methods)
|
|
680
|
-
self.assertNotIn('static_async_method', public_static_methods)
|
|
681
|
-
|
|
682
|
-
async def testGetPublicStaticSyncMethods(self):
|
|
683
|
-
"""
|
|
684
|
-
Test that ReflectionConcrete.getPublicStaticSyncMethods returns only public static sync methods.
|
|
685
|
-
|
|
686
|
-
Returns
|
|
687
|
-
-------
|
|
688
|
-
None
|
|
689
|
-
Asserts that only public static sync methods are included in the result.
|
|
690
|
-
"""
|
|
691
|
-
reflect = ReflectionConcrete(FakeClass)
|
|
692
|
-
public_static_sync_methods = reflect.getPublicStaticSyncMethods()
|
|
693
|
-
self.assertIn('staticMethod', public_static_sync_methods)
|
|
694
|
-
self.assertNotIn('staticAsyncMethod', public_static_sync_methods)
|
|
695
|
-
self.assertNotIn('static_async_method', public_static_sync_methods)
|
|
696
|
-
|
|
697
|
-
async def testGetPublicStaticAsyncMethods(self):
|
|
698
|
-
"""
|
|
699
|
-
Test that ReflectionConcrete.getPublicStaticAsyncMethods returns only public static async methods.
|
|
700
|
-
|
|
701
|
-
Returns
|
|
702
|
-
-------
|
|
703
|
-
None
|
|
704
|
-
Asserts that only public static async methods are included in the result.
|
|
705
|
-
"""
|
|
706
|
-
reflect = ReflectionConcrete(FakeClass)
|
|
707
|
-
public_static_async_methods = reflect.getPublicStaticAsyncMethods()
|
|
708
|
-
self.assertIn('staticAsyncMethod', public_static_async_methods)
|
|
709
|
-
self.assertNotIn('staticMethod', public_static_async_methods)
|
|
710
|
-
self.assertNotIn('static_async_method', public_static_async_methods)
|
|
711
|
-
|
|
712
|
-
async def testGetProtectedStaticMethods(self):
|
|
713
|
-
"""
|
|
714
|
-
Test that ReflectionConcrete.getProtectedStaticMethods returns only protected static methods.
|
|
715
|
-
|
|
716
|
-
Returns
|
|
717
|
-
-------
|
|
718
|
-
None
|
|
719
|
-
Asserts that only protected static methods are included in the result.
|
|
720
|
-
"""
|
|
721
|
-
reflect = ReflectionConcrete(FakeClass)
|
|
722
|
-
protected_static_methods = reflect.getProtectedStaticMethods()
|
|
723
|
-
self.assertIn('_staticMethodProtected', protected_static_methods)
|
|
724
|
-
self.assertNotIn('staticMethod', protected_static_methods)
|
|
725
|
-
self.assertNotIn('__staticMethodPrivate', protected_static_methods)
|
|
726
|
-
|
|
727
|
-
async def testGetProtectedStaticSyncMethods(self):
|
|
728
|
-
"""
|
|
729
|
-
Test that ReflectionConcrete.getProtectedStaticSyncMethods returns only protected static sync methods.
|
|
730
|
-
|
|
731
|
-
Returns
|
|
732
|
-
-------
|
|
733
|
-
None
|
|
734
|
-
Asserts that only protected static sync methods are included in the result.
|
|
735
|
-
"""
|
|
736
|
-
reflect = ReflectionConcrete(FakeClass)
|
|
737
|
-
protected_static_sync_methods = reflect.getProtectedStaticSyncMethods()
|
|
738
|
-
self.assertIn('_staticMethodProtected', protected_static_sync_methods)
|
|
739
|
-
self.assertNotIn('staticAsyncMethod', protected_static_sync_methods)
|
|
740
|
-
self.assertNotIn('__staticMethodPrivate', protected_static_sync_methods)
|
|
741
|
-
|
|
742
|
-
async def testGetProtectedStaticAsyncMethods(self):
|
|
743
|
-
"""
|
|
744
|
-
Test that ReflectionConcrete.getProtectedStaticAsyncMethods returns only protected static async methods.
|
|
745
|
-
|
|
746
|
-
Returns
|
|
747
|
-
-------
|
|
748
|
-
None
|
|
749
|
-
Asserts that only protected static async methods are included in the result.
|
|
750
|
-
"""
|
|
751
|
-
reflect = ReflectionConcrete(FakeClass)
|
|
752
|
-
protected_static_async_methods = reflect.getProtectedStaticAsyncMethods()
|
|
753
|
-
self.assertIn('_staticAsyncMethodProtected', protected_static_async_methods)
|
|
754
|
-
self.assertNotIn('staticMethod', protected_static_async_methods)
|
|
755
|
-
self.assertNotIn('__staticMethodPrivate', protected_static_async_methods)
|
|
756
|
-
|
|
757
|
-
async def testGetPrivateStaticMethods(self):
|
|
758
|
-
"""
|
|
759
|
-
Test that ReflectionConcrete.getPrivateStaticMethods returns only private static methods.
|
|
760
|
-
|
|
761
|
-
Returns
|
|
762
|
-
-------
|
|
763
|
-
None
|
|
764
|
-
Asserts that only private static methods are included in the result.
|
|
765
|
-
"""
|
|
766
|
-
reflect = ReflectionConcrete(FakeClass)
|
|
767
|
-
private_static_methods = reflect.getPrivateStaticMethods()
|
|
768
|
-
self.assertIn('__staticMethodPrivate', private_static_methods)
|
|
769
|
-
self.assertNotIn('staticMethod', private_static_methods)
|
|
770
|
-
self.assertNotIn('_staticMethodProtected', private_static_methods)
|
|
771
|
-
|
|
772
|
-
async def testGetPrivateStaticSyncMethods(self):
|
|
773
|
-
"""
|
|
774
|
-
Test that ReflectionConcrete.getPrivateStaticSyncMethods returns only private static sync methods.
|
|
775
|
-
|
|
776
|
-
Returns
|
|
777
|
-
-------
|
|
778
|
-
None
|
|
779
|
-
Asserts that only private static sync methods are included in the result.
|
|
780
|
-
"""
|
|
781
|
-
reflect = ReflectionConcrete(FakeClass)
|
|
782
|
-
private_static_sync_methods = reflect.getPrivateStaticSyncMethods()
|
|
783
|
-
self.assertIn('__staticMethodPrivate', private_static_sync_methods)
|
|
784
|
-
self.assertNotIn('staticMethod', private_static_sync_methods)
|
|
785
|
-
self.assertNotIn('_staticMethodProtected', private_static_sync_methods)
|
|
786
|
-
|
|
787
|
-
async def testGetPrivateStaticAsyncMethods(self):
|
|
788
|
-
"""
|
|
789
|
-
Test that ReflectionConcrete.getPrivateStaticAsyncMethods returns only private static async methods.
|
|
790
|
-
|
|
791
|
-
Returns
|
|
792
|
-
-------
|
|
793
|
-
None
|
|
794
|
-
Asserts that only private static async methods are included in the result.
|
|
795
|
-
"""
|
|
796
|
-
reflect = ReflectionConcrete(FakeClass)
|
|
797
|
-
private_static_async_methods = reflect.getPrivateStaticAsyncMethods()
|
|
798
|
-
self.assertIn('__staticAsyncMethodPrivate', private_static_async_methods)
|
|
799
|
-
self.assertNotIn('staticAsyncMethod', private_static_async_methods)
|
|
800
|
-
self.assertNotIn('_staticAsyncMethodProtected', private_static_async_methods)
|
|
801
|
-
|
|
802
|
-
async def testGetDunderMethods(self):
|
|
803
|
-
"""
|
|
804
|
-
Test that ReflectionConcrete.getDunderMethods retrieves dunder (double underscore) methods.
|
|
805
|
-
|
|
806
|
-
Returns
|
|
807
|
-
-------
|
|
808
|
-
None
|
|
809
|
-
Asserts that '__init__' is present in the results.
|
|
810
|
-
"""
|
|
811
|
-
reflect = ReflectionConcrete(FakeClass)
|
|
812
|
-
dunder_methods = reflect.getDunderMethods()
|
|
813
|
-
self.assertIn('__init__', dunder_methods)
|
|
814
|
-
|
|
815
|
-
async def testGetMagicMethods(self):
|
|
816
|
-
"""
|
|
817
|
-
Test that ReflectionConcrete.getMagicMethods retrieves magic methods.
|
|
818
|
-
|
|
819
|
-
Returns
|
|
820
|
-
-------
|
|
821
|
-
None
|
|
822
|
-
Asserts that '__init__' is present in the results.
|
|
823
|
-
"""
|
|
824
|
-
reflect = ReflectionConcrete(FakeClass)
|
|
825
|
-
magic_methods = reflect.getMagicMethods()
|
|
826
|
-
self.assertIn('__init__', magic_methods)
|
|
827
|
-
|
|
828
|
-
async def testGetProperties(self):
|
|
829
|
-
"""
|
|
830
|
-
Test that ReflectionConcrete.getProperties returns properties of FakeClass.
|
|
831
|
-
|
|
832
|
-
Returns
|
|
833
|
-
-------
|
|
834
|
-
None
|
|
835
|
-
Asserts that public, protected, and private properties are present in the result.
|
|
836
|
-
"""
|
|
837
|
-
reflect = ReflectionConcrete(FakeClass)
|
|
838
|
-
properties = reflect.getProperties()
|
|
839
|
-
self.assertIn('computed_public_property', properties)
|
|
840
|
-
self.assertIn('_computed_property_protected', properties)
|
|
841
|
-
self.assertIn('__computed_property_private', properties)
|
|
842
|
-
|
|
843
|
-
async def testGetPublicProperties(self):
|
|
844
|
-
"""
|
|
845
|
-
Test that ReflectionConcrete.getPublicProperties returns only public properties.
|
|
846
|
-
|
|
847
|
-
Returns
|
|
848
|
-
-------
|
|
849
|
-
None
|
|
850
|
-
Asserts that only public properties are included in the result.
|
|
851
|
-
"""
|
|
852
|
-
reflect = ReflectionConcrete(FakeClass)
|
|
853
|
-
public_properties = reflect.getPublicProperties()
|
|
854
|
-
self.assertIn('computed_public_property', public_properties)
|
|
855
|
-
self.assertNotIn('_computed_property_protected', public_properties)
|
|
856
|
-
self.assertNotIn('__computed_property_private', public_properties)
|
|
857
|
-
|
|
858
|
-
async def testGetProtectedProperties(self):
|
|
859
|
-
"""
|
|
860
|
-
Test that ReflectionConcrete.getProtectedProperties returns only protected properties.
|
|
861
|
-
|
|
862
|
-
Returns
|
|
863
|
-
-------
|
|
864
|
-
None
|
|
865
|
-
Asserts that only protected properties are included in the result.
|
|
866
|
-
"""
|
|
867
|
-
reflect = ReflectionConcrete(FakeClass)
|
|
868
|
-
protected_properties = reflect.getProtectedProperties()
|
|
869
|
-
self.assertIn('_computed_property_protected', protected_properties)
|
|
870
|
-
self.assertNotIn('computed_public_property', protected_properties)
|
|
871
|
-
self.assertNotIn('__computed_property_private', protected_properties)
|
|
872
|
-
|
|
873
|
-
async def testGetPrivateProperties(self):
|
|
874
|
-
"""
|
|
875
|
-
Test that ReflectionConcrete.getPrivateProperties returns only private properties.
|
|
876
|
-
|
|
877
|
-
Returns
|
|
878
|
-
-------
|
|
879
|
-
None
|
|
880
|
-
Asserts that only private properties are included in the result.
|
|
881
|
-
"""
|
|
882
|
-
reflect = ReflectionConcrete(FakeClass)
|
|
883
|
-
private_properties = reflect.getPrivateProperties()
|
|
884
|
-
self.assertIn('__computed_property_private', private_properties)
|
|
885
|
-
self.assertNotIn('computed_public_property', private_properties)
|
|
886
|
-
self.assertNotIn('_computed_property_protected', private_properties)
|
|
887
|
-
|
|
888
|
-
async def testGetProperty(self):
|
|
889
|
-
"""
|
|
890
|
-
Test that ReflectionConcrete.getProperty returns the correct value for a property.
|
|
891
|
-
|
|
892
|
-
Returns
|
|
893
|
-
-------
|
|
894
|
-
None
|
|
895
|
-
Asserts that the returned value matches the expected value for the property.
|
|
896
|
-
"""
|
|
897
|
-
reflect = ReflectionConcrete(FakeClass)
|
|
898
|
-
value = reflect.getProperty('computed_public_property')
|
|
899
|
-
self.assertEqual(value, FakeClass().computed_public_property)
|
|
900
|
-
|
|
901
|
-
async def testGetPropertySignature(self):
|
|
902
|
-
"""
|
|
903
|
-
Test that ReflectionConcrete.getPropertySignature returns the correct signature for a property.
|
|
904
|
-
|
|
905
|
-
Returns
|
|
906
|
-
-------
|
|
907
|
-
None
|
|
908
|
-
Asserts that the returned signature matches the expected format.
|
|
909
|
-
"""
|
|
910
|
-
reflect = ReflectionConcrete(FakeClass)
|
|
911
|
-
signature = reflect.getPropertySignature('computed_public_property')
|
|
912
|
-
self.assertEqual(str(signature), '(self) -> str')
|
|
913
|
-
|
|
914
|
-
async def testGetPropertyDocstring(self):
|
|
915
|
-
"""
|
|
916
|
-
Test that ReflectionConcrete.getPropertyDocstring returns the correct docstring for a property.
|
|
917
|
-
|
|
918
|
-
Returns
|
|
919
|
-
-------
|
|
920
|
-
None
|
|
921
|
-
Asserts that the returned docstring matches the expected value.
|
|
922
|
-
"""
|
|
923
|
-
reflect = ReflectionConcrete(FakeClass)
|
|
924
|
-
docstring = reflect.getPropertyDocstring('computed_public_property')
|
|
925
|
-
self.assertIn('Returns a string indicating this is a public', docstring)
|
|
926
|
-
|
|
927
|
-
async def testGetConstructorDependencies(self):
|
|
928
|
-
"""
|
|
929
|
-
Test that ReflectionConcrete.getConstructorDependencies returns the correct constructor dependencies.
|
|
930
|
-
|
|
931
|
-
Returns
|
|
932
|
-
-------
|
|
933
|
-
None
|
|
934
|
-
Asserts that the returned dependencies are a ResolveArguments object.
|
|
935
|
-
"""
|
|
936
|
-
reflect = ReflectionConcrete(FakeClass)
|
|
937
|
-
dependencies = reflect.getConstructorDependencies()
|
|
938
|
-
self.assertIsInstance(dependencies, ResolveArguments)
|
|
939
|
-
|
|
940
|
-
async def testGetMethodDependencies(self):
|
|
941
|
-
"""
|
|
942
|
-
Test that ReflectionConcrete.getMethodDependencies returns correct method dependencies.
|
|
943
|
-
|
|
944
|
-
Returns
|
|
945
|
-
-------
|
|
946
|
-
None
|
|
947
|
-
Asserts that the returned dependencies for 'instanceSyncMethod' are as expected.
|
|
948
|
-
"""
|
|
949
|
-
reflect = ReflectionConcrete(FakeClass)
|
|
950
|
-
method_deps: ResolveArguments = reflect.getMethodDependencies('instanceSyncMethod')
|
|
951
|
-
self.assertIn('x', method_deps.unresolved)
|
|
952
|
-
self.assertIn('y', method_deps.unresolved)
|