Skip to content

Commit bb5fca8

Browse files
committed
bumped up di test-coverage
1 parent 61163d5 commit bb5fca8

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

tests/test_di/test_provider_scopes.py

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import pytest
2+
from injector import inject
23

3-
from ellar.di import EllarInjector, ProviderConfig
4+
from ellar.di import EllarInjector, ProviderConfig, has_binding
5+
from ellar.di.exceptions import DIImproperConfiguration
46
from ellar.di.scopes import RequestScope, SingletonScope, TransientScope
57

68
from .examples import AnyContext, Foo, IContext
@@ -44,3 +46,20 @@ async def test_request_scope_instance():
4446
async with injector.create_asgi_args() as request_provider:
4547
# resolving RequestScope during request will behave like singleton
4648
assert request_provider.get(IContext) == request_provider.get(IContext)
49+
50+
51+
def test_invalid_use_of_provider_config():
52+
with pytest.raises(DIImproperConfiguration):
53+
ProviderConfig(IContext, use_class=AnyContext, use_value=AnyContext())
54+
55+
56+
def test_has_binding_works():
57+
@inject
58+
def inject_function(a: IContext):
59+
pass
60+
61+
assert has_binding(IContext) is False
62+
assert has_binding(AnyContext) is True
63+
64+
assert has_binding(lambda n: print("Hello")) is False
65+
assert has_binding(inject_function) is True

0 commit comments

Comments
 (0)