File tree Expand file tree Collapse file tree 1 file changed +20
-1
lines changed Expand file tree Collapse file tree 1 file changed +20
-1
lines changed Original file line number Diff line number Diff line change 1
1
import pytest
2
+ from injector import inject
2
3
3
- from ellar .di import EllarInjector , ProviderConfig
4
+ from ellar .di import EllarInjector , ProviderConfig , has_binding
5
+ from ellar .di .exceptions import DIImproperConfiguration
4
6
from ellar .di .scopes import RequestScope , SingletonScope , TransientScope
5
7
6
8
from .examples import AnyContext , Foo , IContext
@@ -44,3 +46,20 @@ async def test_request_scope_instance():
44
46
async with injector .create_asgi_args () as request_provider :
45
47
# resolving RequestScope during request will behave like singleton
46
48
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
You can’t perform that action at this time.
0 commit comments