orionis 0.407.0__py3-none-any.whl → 0.408.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/container/container.py +11 -9
- orionis/container/enums/lifetimes.py +2 -0
- orionis/container/validators/__init__.py +21 -0
- orionis/metadata/framework.py +1 -1
- {orionis-0.407.0.dist-info → orionis-0.408.0.dist-info}/METADATA +1 -1
- {orionis-0.407.0.dist-info → orionis-0.408.0.dist-info}/RECORD +29 -29
- tests/container/context/test_manager.py +15 -5
- tests/container/context/test_scope.py +12 -4
- tests/container/entities/test_binding.py +130 -21
- tests/container/enums/test_lifetimes.py +52 -18
- tests/container/facades/test_facade.py +29 -12
- tests/container/providers/test_providers.py +17 -10
- tests/container/resolver/test_resolver.py +14 -7
- tests/container/test_container.py +226 -71
- tests/container/test_singleton.py +43 -24
- tests/container/test_thread_safety.py +28 -156
- tests/container/validators/test_implements.py +59 -13
- tests/container/validators/test_is_abstract_class.py +73 -25
- tests/container/validators/test_is_callable.py +55 -26
- tests/container/validators/test_is_concrete_class.py +80 -17
- tests/container/validators/test_is_instance.py +67 -22
- tests/container/validators/test_is_not_subclass.py +28 -95
- tests/container/validators/test_is_subclass.py +84 -21
- tests/container/validators/test_is_valid_alias.py +46 -12
- tests/container/validators/test_lifetime.py +45 -14
- {orionis-0.407.0.dist-info → orionis-0.408.0.dist-info}/WHEEL +0 -0
- {orionis-0.407.0.dist-info → orionis-0.408.0.dist-info}/licenses/LICENCE +0 -0
- {orionis-0.407.0.dist-info → orionis-0.408.0.dist-info}/top_level.txt +0 -0
- {orionis-0.407.0.dist-info → orionis-0.408.0.dist-info}/zip-safe +0 -0
orionis/container/container.py
CHANGED
|
@@ -6,15 +6,17 @@ from orionis.container.entities.binding import Binding
|
|
|
6
6
|
from orionis.container.enums.lifetimes import Lifetime
|
|
7
7
|
from orionis.container.exceptions import OrionisContainerException
|
|
8
8
|
from orionis.container.resolver.resolver import Resolver
|
|
9
|
-
from orionis.container.validators
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
9
|
+
from orionis.container.validators import (
|
|
10
|
+
ImplementsAbstractMethods,
|
|
11
|
+
IsAbstractClass,
|
|
12
|
+
IsCallable,
|
|
13
|
+
IsConcreteClass,
|
|
14
|
+
IsInstance,
|
|
15
|
+
IsNotSubclass,
|
|
16
|
+
IsSubclass,
|
|
17
|
+
IsValidAlias,
|
|
18
|
+
LifetimeValidator
|
|
19
|
+
)
|
|
18
20
|
from orionis.services.introspection.abstract.reflection import ReflectionAbstract
|
|
19
21
|
from orionis.services.introspection.callables.reflection import ReflectionCallable
|
|
20
22
|
|
|
@@ -23,7 +23,9 @@ class Lifetime(Enum):
|
|
|
23
23
|
|
|
24
24
|
# A new instance is provided every time the dependency is requested.
|
|
25
25
|
TRANSIENT = auto()
|
|
26
|
+
|
|
26
27
|
# A single shared instance is provided for the entire application lifetime.
|
|
27
28
|
SINGLETON = auto()
|
|
29
|
+
|
|
28
30
|
# An instance is provided per scope (e.g., per request or session).
|
|
29
31
|
SCOPED = auto()
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
from .implements import ImplementsAbstractMethods
|
|
2
|
+
from .is_abstract_class import IsAbstractClass
|
|
3
|
+
from .is_concrete_class import IsConcreteClass
|
|
4
|
+
from .is_instance import IsInstance
|
|
5
|
+
from .is_callable import IsCallable
|
|
6
|
+
from .is_subclass import IsSubclass
|
|
7
|
+
from .is_not_subclass import IsNotSubclass
|
|
8
|
+
from .is_valid_alias import IsValidAlias
|
|
9
|
+
from .lifetime import LifetimeValidator
|
|
10
|
+
|
|
11
|
+
__all__ = [
|
|
12
|
+
"ImplementsAbstractMethods",
|
|
13
|
+
"IsAbstractClass",
|
|
14
|
+
"IsConcreteClass",
|
|
15
|
+
"IsInstance",
|
|
16
|
+
"IsCallable",
|
|
17
|
+
"IsSubclass",
|
|
18
|
+
"IsNotSubclass",
|
|
19
|
+
"IsValidAlias",
|
|
20
|
+
"LifetimeValidator",
|
|
21
|
+
]
|
orionis/metadata/framework.py
CHANGED
|
@@ -114,7 +114,7 @@ orionis/console/output/contracts/console.py,sha256=phaQhCLWa81MLzB5ydOSaUfEIdDq7
|
|
|
114
114
|
orionis/console/output/enums/__init__.py,sha256=LAaAxg-DpArCjf_jqZ0_9s3p8899gntDYkSU_ppTdC8,66
|
|
115
115
|
orionis/console/output/enums/styles.py,sha256=6a4oQCOBOKMh2ARdeq5GlIskJ3wjiylYmh66tUKKmpQ,4053
|
|
116
116
|
orionis/container/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
117
|
-
orionis/container/container.py,sha256=
|
|
117
|
+
orionis/container/container.py,sha256=ICKSeaXA_IL15jV6Ofe1wIb1QyX-F-8oaGuk7hj955I,22773
|
|
118
118
|
orionis/container/context/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
119
119
|
orionis/container/context/manager.py,sha256=9yODWkHBoJ2kgJZ5ONLqcEcex50vaWuMcxsvmDgnQo4,2437
|
|
120
120
|
orionis/container/context/scope.py,sha256=jhRGGO6oZcWNa3eCaurGwPngTUsCuMm7asIa24d6q3Q,962
|
|
@@ -125,7 +125,7 @@ orionis/container/contracts/service_provider.py,sha256=qYBWCw55pudk8QnbjX0_FRKsz
|
|
|
125
125
|
orionis/container/entities/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
126
126
|
orionis/container/entities/binding.py,sha256=sY0ioHbRcjp9TSQjfrFHxkO3vRn_VOrbHK62_QEGe1U,3717
|
|
127
127
|
orionis/container/enums/__init__.py,sha256=BRpTC9sY0dWlGsGfE96uZ8TZqU28kXTP0HEH8DdC9c8,65
|
|
128
|
-
orionis/container/enums/lifetimes.py,sha256=
|
|
128
|
+
orionis/container/enums/lifetimes.py,sha256=ntvF_cmmOWA0ujyxwdUmgJK7O6M9kCYlmrfcEmhwarM,1047
|
|
129
129
|
orionis/container/exceptions/__init__.py,sha256=uJU8ncq66d26tWRFZfxBzs6AyYu5eIuDe-N3mcFg4vw,354
|
|
130
130
|
orionis/container/exceptions/attribute.py,sha256=ysYKvXfunH-bywK_e02inY94s8aZ3vUZA6jATbDcQmk,480
|
|
131
131
|
orionis/container/exceptions/exception.py,sha256=goTDEwC70xTMD2qppN8KV-xyR0Nps218OD4D1LZ2-3s,470
|
|
@@ -137,7 +137,7 @@ orionis/container/providers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMp
|
|
|
137
137
|
orionis/container/providers/service_provider.py,sha256=j0-8p7210YKb1HhI9Bug1TZ165rcrpdyEGenw-dfCPY,1946
|
|
138
138
|
orionis/container/resolver/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
139
139
|
orionis/container/resolver/resolver.py,sha256=8mTouPo9hhMwz1CxZcqmzZlg3vHoLCs5HEWtreZ-KWk,23523
|
|
140
|
-
orionis/container/validators/__init__.py,sha256=
|
|
140
|
+
orionis/container/validators/__init__.py,sha256=iJ_cY8U0EkpnZOU4_LANGKHFkvHeV0vH5bjbYr1fdSg,609
|
|
141
141
|
orionis/container/validators/implements.py,sha256=xDXK7yhG5GGGRT9Mj1UbbVrcVTgifmjFZdaAJG4Ke8o,3110
|
|
142
142
|
orionis/container/validators/is_abstract_class.py,sha256=vJqUPn610YZS0sEkV8c_gPZskIgWmFHjg3D3MF2OTs8,1141
|
|
143
143
|
orionis/container/validators/is_callable.py,sha256=ZW-e3ljJGXbD9GUEfPNqVcyBbpVHFlfYaTf9rSmJmBk,824
|
|
@@ -258,7 +258,7 @@ orionis/foundation/providers/progress_bar_provider.py,sha256=WW3grNgH-yV2meSSTeO
|
|
|
258
258
|
orionis/foundation/providers/testing_provider.py,sha256=iJSN2RIChbYIL-1ue6vmPmDMCSrvERDkti4Er9MPiLA,1102
|
|
259
259
|
orionis/foundation/providers/workers_provider.py,sha256=kiQjQRyUEyiBX2zcbF_KmqRgvc7Bvxsvg5oMtIvYniM,1075
|
|
260
260
|
orionis/metadata/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
261
|
-
orionis/metadata/framework.py,sha256=
|
|
261
|
+
orionis/metadata/framework.py,sha256=lyVpWF0MG5Xr2V2hDnMRTAMzJ-rQJ2v7c8oWkA1Dmno,4960
|
|
262
262
|
orionis/metadata/package.py,sha256=tqLfBRo-w1j_GN4xvzUNFyweWYFS-qhSgAEc-AmCH1M,5452
|
|
263
263
|
orionis/services/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
264
264
|
orionis/services/asynchrony/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
@@ -428,38 +428,38 @@ orionis/test/validators/web_report.py,sha256=-h3Fe9jY93_kzUhd2NBIqEfCcBpu-8Ei9x3
|
|
|
428
428
|
orionis/test/validators/workers.py,sha256=LGffDKtK6SKixFKzIYPQpI5aFeQPAGXpv_LUtmEu6g4,1102
|
|
429
429
|
orionis/test/view/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
430
430
|
orionis/test/view/render.py,sha256=3ICz68l-WF3BtnYqH5m-ktN9UD00MELMbmMnyJDV74A,4768
|
|
431
|
-
orionis-0.
|
|
431
|
+
orionis-0.408.0.dist-info/licenses/LICENCE,sha256=-_4cF2EBKuYVS_SQpy1uapq0oJPUU1vl_RUWSy2jJTo,1111
|
|
432
432
|
tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
433
433
|
tests/container/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
434
|
-
tests/container/test_container.py,sha256=
|
|
435
|
-
tests/container/test_singleton.py,sha256=
|
|
436
|
-
tests/container/test_thread_safety.py,sha256=
|
|
434
|
+
tests/container/test_container.py,sha256=asv8TkkupVoex6SWod74NBl4dSs7wb9mLmu_glNdNy8,14815
|
|
435
|
+
tests/container/test_singleton.py,sha256=GkwFaLtRvOQCNMpaCXfQiPu6tJWRm3gkDaJ0vzQn1ko,4689
|
|
436
|
+
tests/container/test_thread_safety.py,sha256=0gn6kawiSMSMP1iTGWZP-4cQcO2RWXo9Ay4skcihKEM,3740
|
|
437
437
|
tests/container/context/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
438
|
-
tests/container/context/test_manager.py,sha256=
|
|
439
|
-
tests/container/context/test_scope.py,sha256=
|
|
438
|
+
tests/container/context/test_manager.py,sha256=QfzhzkK5LFmtI7AEE-dzceBROTo7VNnQfL3EGgYqK64,1354
|
|
439
|
+
tests/container/context/test_scope.py,sha256=2ykGAmey5xu3cXASseIiOHosJ4QwABbQqRU3_WahO8c,1221
|
|
440
440
|
tests/container/entities/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
441
|
-
tests/container/entities/test_binding.py,sha256=
|
|
441
|
+
tests/container/entities/test_binding.py,sha256=AZ5jUF0MMwTXueevZnYbLpF73g7qrAcvx51jlKMfqkg,9708
|
|
442
442
|
tests/container/enums/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
443
|
-
tests/container/enums/test_lifetimes.py,sha256=
|
|
443
|
+
tests/container/enums/test_lifetimes.py,sha256=JFb4q1rgo10C5ibQ6LS-776NevxCMNLSq_cd7D1O8Ps,3511
|
|
444
444
|
tests/container/facades/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
445
|
-
tests/container/facades/test_facade.py,sha256=
|
|
445
|
+
tests/container/facades/test_facade.py,sha256=aCy0S6YaaiswGoodJEAhNkqJrMaEQL-CcWh2AgXMvvQ,2938
|
|
446
446
|
tests/container/mocks/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
447
447
|
tests/container/mocks/mock_complex_classes.py,sha256=DKBD2Wd8n_dDPXRo-HepEOy3L6w7ACfFpeQKVuIFlRA,15026
|
|
448
448
|
tests/container/mocks/mock_simple_classes.py,sha256=rvHFEYAzEnLvL79WWS-YCNwIEPsx14FEo2v3wrdibzE,841
|
|
449
449
|
tests/container/providers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
450
|
-
tests/container/providers/test_providers.py,sha256=
|
|
450
|
+
tests/container/providers/test_providers.py,sha256=qGh2vtrLYp_S7u3U64I22Fzr86NsDZw0tXtJioSDdms,2149
|
|
451
451
|
tests/container/resolver/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
452
|
-
tests/container/resolver/test_resolver.py,sha256=
|
|
452
|
+
tests/container/resolver/test_resolver.py,sha256=6p3XMIme53QLEbPpTBfs3dLzESMK_5fGYbr2TNPolTI,2313
|
|
453
453
|
tests/container/validators/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
454
|
-
tests/container/validators/test_implements.py,sha256=
|
|
455
|
-
tests/container/validators/test_is_abstract_class.py,sha256=
|
|
456
|
-
tests/container/validators/test_is_callable.py,sha256=
|
|
457
|
-
tests/container/validators/test_is_concrete_class.py,sha256=
|
|
458
|
-
tests/container/validators/test_is_instance.py,sha256=
|
|
459
|
-
tests/container/validators/test_is_not_subclass.py,sha256=
|
|
460
|
-
tests/container/validators/test_is_subclass.py,sha256=
|
|
461
|
-
tests/container/validators/test_is_valid_alias.py,sha256=
|
|
462
|
-
tests/container/validators/test_lifetime.py,sha256=
|
|
454
|
+
tests/container/validators/test_implements.py,sha256=XquLuD3WGRPfSj2Jfd5uBTV48h8FPU0E-cJeEjZohEo,6759
|
|
455
|
+
tests/container/validators/test_is_abstract_class.py,sha256=_xW8NrnrmG5tKocaGs83r118S-t-YbaMTal-cWXtM0k,6868
|
|
456
|
+
tests/container/validators/test_is_callable.py,sha256=VbQNKZ4sVQeWnqAIZ7R2E-6uFnT78Gcdaxf7Gq-qWlw,3767
|
|
457
|
+
tests/container/validators/test_is_concrete_class.py,sha256=bD8F_fbeWLf61I-7sCeapugvXl1-oSx8iVawuYF4tY4,6362
|
|
458
|
+
tests/container/validators/test_is_instance.py,sha256=skRLexi-31IxJrW0nSYwTW84iqXvi0IVqxHm0X-YfC0,5255
|
|
459
|
+
tests/container/validators/test_is_not_subclass.py,sha256=1OCPtCRuysm7OKL6XhuXJPZQPumtZZqfoiYtC4HzNFA,1983
|
|
460
|
+
tests/container/validators/test_is_subclass.py,sha256=0Uc8uIR69ZX7G5Nrex0LMQXrueTdncdDxfQoila3h3U,5834
|
|
461
|
+
tests/container/validators/test_is_valid_alias.py,sha256=egVf6IfSXurIdu8hKo03rwsM1P-bxGOFd1_9JjDHJIk,5657
|
|
462
|
+
tests/container/validators/test_lifetime.py,sha256=5PequjXAcIcp0Q4TIki7THSU31XftGpI0u1mVGqHmpU,4692
|
|
463
463
|
tests/example/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
464
464
|
tests/example/test_example.py,sha256=XJEcsro3vCO5m4zvMiWUGphvd0C7oIkBtUfQgTDsdUU,25568
|
|
465
465
|
tests/foundation/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
@@ -559,8 +559,8 @@ tests/support/wrapper/test_services_wrapper_docdict.py,sha256=nTNrvJkMSPx_aopEQ9
|
|
|
559
559
|
tests/testing/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
560
560
|
tests/testing/test_testing_result.py,sha256=aWOOJiHji_U7gcJHbDukgMmfBEEQCLQdyqpXJD5q4BE,4643
|
|
561
561
|
tests/testing/test_testing_unit.py,sha256=Krz0Bw1toI9qvLtKtYe_slNvi7fYmZbHK1i4DRPMfUM,7952
|
|
562
|
-
orionis-0.
|
|
563
|
-
orionis-0.
|
|
564
|
-
orionis-0.
|
|
565
|
-
orionis-0.
|
|
566
|
-
orionis-0.
|
|
562
|
+
orionis-0.408.0.dist-info/METADATA,sha256=n5ql9Cat7kQbHjFV3goNTgyUPgouORkrqTgZuMIwjjE,4772
|
|
563
|
+
orionis-0.408.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
564
|
+
orionis-0.408.0.dist-info/top_level.txt,sha256=2bdoHgyGZhOtLAXS6Om8OCTmL24dUMC_L1quMe_ETbk,14
|
|
565
|
+
orionis-0.408.0.dist-info/zip-safe,sha256=frcCV1k9oG9oKj3dpUqdJg1PxRT2RSN_XKdLCPjaYaY,2
|
|
566
|
+
orionis-0.408.0.dist-info/RECORD,,
|
|
@@ -2,14 +2,23 @@ from orionis.container.context.manager import ScopeManager
|
|
|
2
2
|
from orionis.test.cases.asynchronous import AsyncTestCase
|
|
3
3
|
|
|
4
4
|
class TestScopeManagerMethods(AsyncTestCase):
|
|
5
|
-
"""
|
|
6
|
-
Test suite to ensure all required methods exist in ScopeManager and their signatures are preserved.
|
|
7
|
-
"""
|
|
8
5
|
|
|
9
6
|
def testMethodsExist(self):
|
|
10
7
|
"""
|
|
11
|
-
|
|
8
|
+
Checks that all required methods are present in the ScopeManager class.
|
|
9
|
+
|
|
10
|
+
This test verifies the existence of a predefined list of methods that are
|
|
11
|
+
essential for the correct functioning of ScopeManager. The methods checked
|
|
12
|
+
include initialization, item access, containment, clearing, and context
|
|
13
|
+
management methods.
|
|
14
|
+
|
|
15
|
+
Returns
|
|
16
|
+
-------
|
|
17
|
+
None
|
|
18
|
+
This method does not return any value. It asserts the existence of methods
|
|
19
|
+
and fails the test if any are missing.
|
|
12
20
|
"""
|
|
21
|
+
# List of expected method names in ScopeManager
|
|
13
22
|
expected_methods = [
|
|
14
23
|
"__init__",
|
|
15
24
|
"__getitem__",
|
|
@@ -20,8 +29,9 @@ class TestScopeManagerMethods(AsyncTestCase):
|
|
|
20
29
|
"__exit__"
|
|
21
30
|
]
|
|
22
31
|
|
|
32
|
+
# Check each method for existence in ScopeManager
|
|
23
33
|
for method in expected_methods:
|
|
24
34
|
self.assertTrue(
|
|
25
|
-
hasattr(ScopeManager, method),
|
|
35
|
+
hasattr(ScopeManager, method), # Assert method exists
|
|
26
36
|
f"Method '{method}' does not exist in ScopeManager class."
|
|
27
37
|
)
|
|
@@ -2,20 +2,28 @@ from orionis.container.context.scope import ScopedContext
|
|
|
2
2
|
from orionis.test.cases.asynchronous import AsyncTestCase
|
|
3
3
|
|
|
4
4
|
class TestScopedContextMethods(AsyncTestCase):
|
|
5
|
-
"""
|
|
6
|
-
Test suite to ensure all required methods exist in ScopedContext and their signatures are preserved.
|
|
7
|
-
"""
|
|
8
5
|
|
|
9
6
|
def testMethodsExist(self):
|
|
10
7
|
"""
|
|
11
|
-
|
|
8
|
+
Checks that all required methods are present in the ScopedContext class.
|
|
9
|
+
|
|
10
|
+
This test verifies the existence of specific methods that are essential for the correct
|
|
11
|
+
operation of ScopedContext. It ensures that the class interface is complete and that
|
|
12
|
+
method names have not been changed or removed.
|
|
13
|
+
|
|
14
|
+
Returns
|
|
15
|
+
-------
|
|
16
|
+
None
|
|
17
|
+
This method does not return anything. It asserts the existence of methods and fails the test if any are missing.
|
|
12
18
|
"""
|
|
19
|
+
# List of method names expected to be present in ScopedContext
|
|
13
20
|
expected_methods = [
|
|
14
21
|
"getCurrentScope",
|
|
15
22
|
"setCurrentScope",
|
|
16
23
|
"clear"
|
|
17
24
|
]
|
|
18
25
|
|
|
26
|
+
# Iterate through each expected method and assert its existence
|
|
19
27
|
for method in expected_methods:
|
|
20
28
|
self.assertTrue(
|
|
21
29
|
hasattr(ScopedContext, method),
|
|
@@ -7,37 +7,73 @@ class TestBinding(AsyncTestCase):
|
|
|
7
7
|
|
|
8
8
|
async def testBindingInitialization(self):
|
|
9
9
|
"""
|
|
10
|
-
Test
|
|
10
|
+
Test initialization of a Binding object with default values.
|
|
11
|
+
|
|
12
|
+
This test verifies that when a Binding instance is created without any arguments,
|
|
13
|
+
all attributes are set to their expected default values.
|
|
14
|
+
|
|
15
|
+
Parameters
|
|
16
|
+
----------
|
|
17
|
+
self : TestBinding
|
|
18
|
+
The test case instance.
|
|
19
|
+
|
|
20
|
+
Returns
|
|
21
|
+
-------
|
|
22
|
+
None
|
|
23
|
+
This method does not return anything. Assertions are used to validate behavior.
|
|
11
24
|
|
|
12
25
|
Raises
|
|
13
26
|
------
|
|
14
27
|
AssertionError
|
|
15
|
-
If the
|
|
28
|
+
If any of the default values are incorrect or the Binding initialization fails.
|
|
16
29
|
"""
|
|
30
|
+
|
|
31
|
+
# Create a Binding instance with default parameters
|
|
17
32
|
binding: Binding = Binding()
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
self.assertIsNone(binding.
|
|
21
|
-
self.assertIsNone(binding.
|
|
22
|
-
self.
|
|
23
|
-
self.
|
|
24
|
-
self.
|
|
33
|
+
|
|
34
|
+
# Assert that all attributes are set to their default values
|
|
35
|
+
self.assertIsNone(binding.contract) # Default contract should be None
|
|
36
|
+
self.assertIsNone(binding.concrete) # Default concrete should be None
|
|
37
|
+
self.assertIsNone(binding.instance) # Default instance should be None
|
|
38
|
+
self.assertIsNone(binding.function) # Default function should be None
|
|
39
|
+
self.assertEqual(binding.lifetime, Lifetime.TRANSIENT) # Default lifetime should be TRANSIENT
|
|
40
|
+
self.assertFalse(binding.enforce_decoupling) # Default enforce_decoupling should be False
|
|
41
|
+
self.assertIsNone(binding.alias) # Default alias should be None
|
|
25
42
|
|
|
26
43
|
async def testBindingCustomValues(self):
|
|
27
44
|
"""
|
|
28
|
-
Test
|
|
45
|
+
Test initialization of a Binding object with custom values.
|
|
46
|
+
|
|
47
|
+
This test verifies that when a Binding instance is created with explicit arguments,
|
|
48
|
+
all attributes are set to the provided custom values, and the object reflects the intended configuration.
|
|
49
|
+
|
|
50
|
+
Parameters
|
|
51
|
+
----------
|
|
52
|
+
self : TestBinding
|
|
53
|
+
The test case instance.
|
|
54
|
+
|
|
55
|
+
Returns
|
|
56
|
+
-------
|
|
57
|
+
None
|
|
58
|
+
This method does not return anything. Assertions are used to validate correct attribute assignment.
|
|
29
59
|
|
|
30
60
|
Raises
|
|
31
61
|
------
|
|
32
62
|
AssertionError
|
|
33
63
|
If the Binding initialization fails or custom values are not set correctly.
|
|
34
64
|
"""
|
|
65
|
+
|
|
66
|
+
# Define dummy contract and concrete classes for testing
|
|
35
67
|
class TestContract: pass
|
|
36
68
|
class TestConcrete: pass
|
|
37
69
|
|
|
70
|
+
# Create an instance for the 'instance' attribute
|
|
38
71
|
instance = TestConcrete()
|
|
72
|
+
|
|
73
|
+
# Define a factory function for the 'function' attribute
|
|
39
74
|
factory_func = lambda: TestConcrete()
|
|
40
75
|
|
|
76
|
+
# Initialize Binding with custom values
|
|
41
77
|
binding = Binding(
|
|
42
78
|
contract=TestContract,
|
|
43
79
|
concrete=TestConcrete,
|
|
@@ -48,6 +84,7 @@ class TestBinding(AsyncTestCase):
|
|
|
48
84
|
alias="test_binding"
|
|
49
85
|
)
|
|
50
86
|
|
|
87
|
+
# Assert that all attributes are set to the provided custom values
|
|
51
88
|
self.assertIs(binding.contract, TestContract)
|
|
52
89
|
self.assertIs(binding.concrete, TestConcrete)
|
|
53
90
|
self.assertIs(binding.instance, instance)
|
|
@@ -58,37 +95,72 @@ class TestBinding(AsyncTestCase):
|
|
|
58
95
|
|
|
59
96
|
async def testBindingPostInitValidation(self):
|
|
60
97
|
"""
|
|
61
|
-
|
|
98
|
+
Validates that the `__post_init__` method of the `Binding` class raises appropriate
|
|
99
|
+
exceptions when invalid types are provided for certain attributes.
|
|
100
|
+
|
|
101
|
+
This test ensures that type validation is enforced for the `lifetime`, `enforce_decoupling`,
|
|
102
|
+
and `alias` attributes during initialization. If an invalid type is passed, the
|
|
103
|
+
`OrionisContainerTypeError` should be raised.
|
|
104
|
+
|
|
105
|
+
Parameters
|
|
106
|
+
----------
|
|
107
|
+
self : TestBinding
|
|
108
|
+
The test case instance.
|
|
109
|
+
|
|
110
|
+
Returns
|
|
111
|
+
-------
|
|
112
|
+
None
|
|
113
|
+
This method does not return anything. Assertions are used to validate that
|
|
114
|
+
exceptions are raised for invalid input types.
|
|
62
115
|
|
|
63
116
|
Raises
|
|
64
117
|
------
|
|
65
118
|
AssertionError
|
|
66
|
-
If
|
|
119
|
+
If the expected `OrionisContainerTypeError` is not raised when invalid types
|
|
120
|
+
are provided for the attributes.
|
|
67
121
|
"""
|
|
68
|
-
|
|
122
|
+
|
|
123
|
+
# Attempt to initialize Binding with an invalid lifetime type (should raise exception)
|
|
69
124
|
with self.assertRaises(OrionisContainerTypeError):
|
|
70
125
|
Binding(lifetime="not_a_lifetime")
|
|
71
126
|
|
|
72
|
-
#
|
|
127
|
+
# Attempt to initialize Binding with an invalid enforce_decoupling type (should raise exception)
|
|
73
128
|
with self.assertRaises(OrionisContainerTypeError):
|
|
74
129
|
Binding(enforce_decoupling="not_a_bool")
|
|
75
130
|
|
|
76
|
-
#
|
|
131
|
+
# Attempt to initialize Binding with an invalid alias type (should raise exception)
|
|
77
132
|
with self.assertRaises(OrionisContainerTypeError):
|
|
78
133
|
Binding(alias=123)
|
|
79
134
|
|
|
80
135
|
async def testToDictMethod(self):
|
|
81
136
|
"""
|
|
82
|
-
|
|
137
|
+
Tests the `toDict` method of the `Binding` class to ensure it returns a correct dictionary representation
|
|
138
|
+
of the binding's attributes.
|
|
139
|
+
|
|
140
|
+
This test verifies that the dictionary contains all expected keys and that their values match the attributes
|
|
141
|
+
set during initialization. It also checks that the types and values are correctly preserved.
|
|
142
|
+
|
|
143
|
+
Parameters
|
|
144
|
+
----------
|
|
145
|
+
self : TestBinding
|
|
146
|
+
The test case instance.
|
|
147
|
+
|
|
148
|
+
Returns
|
|
149
|
+
-------
|
|
150
|
+
None
|
|
151
|
+
This method does not return anything. Assertions are used to validate the correctness of the dictionary representation.
|
|
83
152
|
|
|
84
153
|
Raises
|
|
85
154
|
------
|
|
86
155
|
AssertionError
|
|
87
|
-
If the dictionary representation is incorrect.
|
|
156
|
+
If the dictionary representation is incorrect or any attribute does not match the expected value.
|
|
88
157
|
"""
|
|
158
|
+
|
|
159
|
+
# Define dummy contract and concrete classes for testing
|
|
89
160
|
class TestContract: pass
|
|
90
161
|
class TestConcrete: pass
|
|
91
162
|
|
|
163
|
+
# Create a Binding instance with custom values
|
|
92
164
|
binding = Binding(
|
|
93
165
|
contract=TestContract,
|
|
94
166
|
concrete=TestConcrete,
|
|
@@ -97,37 +169,74 @@ class TestBinding(AsyncTestCase):
|
|
|
97
169
|
alias="test_binding"
|
|
98
170
|
)
|
|
99
171
|
|
|
172
|
+
# Get the dictionary representation of the binding
|
|
100
173
|
result = binding.toDict()
|
|
101
174
|
|
|
175
|
+
# Assert that the result is a dictionary
|
|
102
176
|
self.assertIsInstance(result, dict)
|
|
177
|
+
|
|
178
|
+
# Assert that contract and concrete are correctly set
|
|
103
179
|
self.assertIs(result["contract"], TestContract)
|
|
104
180
|
self.assertIs(result["concrete"], TestConcrete)
|
|
181
|
+
|
|
182
|
+
# Assert that instance and function are None by default
|
|
105
183
|
self.assertIsNone(result["instance"])
|
|
106
184
|
self.assertIsNone(result["function"])
|
|
185
|
+
|
|
186
|
+
# Assert that lifetime, enforce_decoupling, and alias are correctly set
|
|
107
187
|
self.assertEqual(result["lifetime"], Lifetime.SINGLETON)
|
|
108
188
|
self.assertTrue(result["enforce_decoupling"])
|
|
109
189
|
self.assertEqual(result["alias"], "test_binding")
|
|
110
190
|
|
|
111
191
|
async def testGetFieldsMethod(self):
|
|
112
192
|
"""
|
|
113
|
-
|
|
193
|
+
Tests the `getFields` method of the `Binding` class to ensure it returns accurate field metadata.
|
|
194
|
+
|
|
195
|
+
This test verifies that the returned list contains the expected number of fields, that all expected
|
|
196
|
+
field names are present, and that specific field metadata (such as default values and descriptions)
|
|
197
|
+
are correctly provided for the `lifetime` field.
|
|
198
|
+
|
|
199
|
+
Parameters
|
|
200
|
+
----------
|
|
201
|
+
self : TestBinding
|
|
202
|
+
The test case instance.
|
|
203
|
+
|
|
204
|
+
Returns
|
|
205
|
+
-------
|
|
206
|
+
None
|
|
207
|
+
This method does not return anything. Assertions are used to validate the correctness of the
|
|
208
|
+
field metadata returned by `getFields`.
|
|
114
209
|
|
|
115
210
|
Raises
|
|
116
211
|
------
|
|
117
212
|
AssertionError
|
|
118
|
-
If the field information is incorrect.
|
|
213
|
+
If the field information is incorrect, such as missing fields, incorrect defaults, or missing metadata.
|
|
119
214
|
"""
|
|
215
|
+
|
|
216
|
+
# Create a Binding instance with default parameters
|
|
120
217
|
binding = Binding()
|
|
218
|
+
|
|
219
|
+
# Retrieve field metadata using getFields
|
|
121
220
|
fields_info = binding.getFields()
|
|
122
221
|
|
|
222
|
+
# Assert that the returned value is a list
|
|
123
223
|
self.assertIsInstance(fields_info, list)
|
|
224
|
+
|
|
225
|
+
# Assert that there are exactly 7 fields
|
|
124
226
|
self.assertEqual(len(fields_info), 7)
|
|
125
227
|
|
|
228
|
+
# Extract field names from the metadata
|
|
126
229
|
field_names = [field["name"] for field in fields_info]
|
|
127
|
-
expected_names = ["contract", "concrete", "instance", "function","lifetime", "enforce_decoupling", "alias"]
|
|
230
|
+
expected_names = ["contract", "concrete", "instance", "function", "lifetime", "enforce_decoupling", "alias"]
|
|
231
|
+
|
|
232
|
+
# Assert that all expected field names are present
|
|
128
233
|
self.assertTrue(all(name in field_names for name in expected_names))
|
|
129
234
|
|
|
130
|
-
#
|
|
235
|
+
# Find the metadata for the 'lifetime' field
|
|
131
236
|
lifetime_field = next(field for field in fields_info if field["name"] == "lifetime")
|
|
237
|
+
|
|
238
|
+
# Assert that the default value for 'lifetime' is correct
|
|
132
239
|
self.assertEqual(lifetime_field["default"], Lifetime.TRANSIENT.value)
|
|
240
|
+
|
|
241
|
+
# Assert that the 'lifetime' field contains a description in its metadata
|
|
133
242
|
self.assertIn("description", lifetime_field["metadata"])
|
|
@@ -2,62 +2,96 @@ from orionis.container.enums.lifetimes import Lifetime
|
|
|
2
2
|
from orionis.test.cases.asynchronous import AsyncTestCase
|
|
3
3
|
|
|
4
4
|
class TestLifetime(AsyncTestCase):
|
|
5
|
-
"""
|
|
6
|
-
Test cases for the Lifetime enum in orionis.container.enums.lifetimes.
|
|
7
|
-
|
|
8
|
-
Notes
|
|
9
|
-
-----
|
|
10
|
-
This test suite validates the enumeration values and behavior of the Lifetime enum
|
|
11
|
-
which defines the lifecycle types for dependency injection.
|
|
12
|
-
"""
|
|
13
5
|
|
|
14
6
|
async def testLifetimeValuesExist(self) -> None:
|
|
15
7
|
"""
|
|
16
|
-
|
|
8
|
+
Checks that the `Lifetime` enum contains the expected lifecycle values.
|
|
9
|
+
|
|
10
|
+
This test verifies the presence of the following enum members:
|
|
11
|
+
- `TRANSIENT`
|
|
12
|
+
- `SINGLETON`
|
|
13
|
+
- `SCOPED`
|
|
17
14
|
|
|
18
|
-
|
|
15
|
+
Returns
|
|
16
|
+
-------
|
|
17
|
+
None
|
|
18
|
+
This method does not return any value. It asserts the existence of enum members.
|
|
19
19
|
"""
|
|
20
|
+
|
|
21
|
+
# Assert that each expected enum member exists in Lifetime
|
|
20
22
|
self.assertIn(Lifetime.TRANSIENT, Lifetime)
|
|
21
23
|
self.assertIn(Lifetime.SINGLETON, Lifetime)
|
|
22
24
|
self.assertIn(Lifetime.SCOPED, Lifetime)
|
|
23
25
|
|
|
24
26
|
async def testLifetimeValuesAreUnique(self) -> None:
|
|
25
27
|
"""
|
|
26
|
-
|
|
28
|
+
Ensures that all `Lifetime` enum values are unique.
|
|
27
29
|
|
|
28
|
-
|
|
30
|
+
This test collects the integer values of all enum members and checks that
|
|
31
|
+
there are no duplicates.
|
|
32
|
+
|
|
33
|
+
Returns
|
|
34
|
+
-------
|
|
35
|
+
None
|
|
36
|
+
This method does not return any value. It asserts uniqueness of enum values.
|
|
29
37
|
"""
|
|
38
|
+
|
|
39
|
+
# Gather all enum values
|
|
30
40
|
values = [member.value for member in Lifetime]
|
|
41
|
+
|
|
42
|
+
# Assert that all values are unique
|
|
31
43
|
self.assertEqual(len(values), len(set(values)))
|
|
32
44
|
|
|
33
45
|
async def testLifetimeCount(self) -> None:
|
|
34
46
|
"""
|
|
35
|
-
|
|
47
|
+
Validates that the `Lifetime` enum defines exactly three lifecycle types.
|
|
36
48
|
|
|
37
|
-
|
|
49
|
+
This test ensures that no additional or missing enum members exist.
|
|
50
|
+
|
|
51
|
+
Returns
|
|
52
|
+
-------
|
|
53
|
+
None
|
|
54
|
+
This method does not return any value. It asserts the count of enum members.
|
|
38
55
|
"""
|
|
56
|
+
|
|
57
|
+
# Assert that there are exactly three members in the Lifetime enum
|
|
39
58
|
self.assertEqual(len(list(Lifetime)), 3)
|
|
40
59
|
|
|
41
60
|
async def testLifetimeStringRepresentation(self) -> None:
|
|
42
61
|
"""
|
|
43
|
-
|
|
62
|
+
Verifies the string representation of `Lifetime` enum members.
|
|
63
|
+
|
|
64
|
+
This test checks that converting each enum member to a string yields the expected format.
|
|
44
65
|
|
|
45
|
-
|
|
66
|
+
Returns
|
|
67
|
+
-------
|
|
68
|
+
None
|
|
69
|
+
This method does not return any value. It asserts string representations.
|
|
46
70
|
"""
|
|
71
|
+
|
|
72
|
+
# Assert that string representations match expected format
|
|
47
73
|
self.assertEqual(str(Lifetime.TRANSIENT), "Lifetime.TRANSIENT")
|
|
48
74
|
self.assertEqual(str(Lifetime.SINGLETON), "Lifetime.SINGLETON")
|
|
49
75
|
self.assertEqual(str(Lifetime.SCOPED), "Lifetime.SCOPED")
|
|
50
76
|
|
|
51
77
|
async def testLifetimeComparison(self) -> None:
|
|
52
78
|
"""
|
|
53
|
-
|
|
79
|
+
Tests comparison operations between `Lifetime` enum members.
|
|
80
|
+
|
|
81
|
+
This test verifies that each enum member is only equal to itself and not to others.
|
|
54
82
|
|
|
55
|
-
|
|
83
|
+
Returns
|
|
84
|
+
-------
|
|
85
|
+
None
|
|
86
|
+
This method does not return any value. It asserts comparison results.
|
|
56
87
|
"""
|
|
88
|
+
|
|
89
|
+
# Assert that different enum members are not equal
|
|
57
90
|
self.assertNotEqual(Lifetime.TRANSIENT, Lifetime.SINGLETON)
|
|
58
91
|
self.assertNotEqual(Lifetime.SINGLETON, Lifetime.SCOPED)
|
|
59
92
|
self.assertNotEqual(Lifetime.TRANSIENT, Lifetime.SCOPED)
|
|
60
93
|
|
|
94
|
+
# Assert that each enum member is equal to itself
|
|
61
95
|
self.assertEqual(Lifetime.TRANSIENT, Lifetime.TRANSIENT)
|
|
62
96
|
self.assertEqual(Lifetime.SINGLETON, Lifetime.SINGLETON)
|
|
63
97
|
self.assertEqual(Lifetime.SCOPED, Lifetime.SCOPED)
|