mirror of
https://github.com/ets-labs/python-dependency-injector.git
synced 2024-11-22 01:26:51 +03:00
Add FactoryAsDecoratorTests
This commit is contained in:
parent
71b820487e
commit
c8fda3da8d
|
@ -1089,3 +1089,27 @@ class ConfigTests(unittest.TestCase):
|
|||
'ChildConfig({0}) at {1}>'.format(
|
||||
repr('.'.join(('category', 'setting'))),
|
||||
hex(id(category_setting))))
|
||||
|
||||
|
||||
class FactoryAsDecoratorTests(unittest.TestCase):
|
||||
"""Factory as decorator tests."""
|
||||
|
||||
def test_decoration(self):
|
||||
"""Test decoration of some class with Factory provider."""
|
||||
@providers.Factory
|
||||
class AuthService(object):
|
||||
"""Auth service."""
|
||||
|
||||
@providers.Factory
|
||||
@injections.inject(auth_service=AuthService)
|
||||
class UsersService(object):
|
||||
"""Users service."""
|
||||
|
||||
def __init__(self, auth_service):
|
||||
"""Initializer."""
|
||||
self.auth_service = auth_service
|
||||
|
||||
users_service = UsersService()
|
||||
|
||||
self.assertIsInstance(users_service, UsersService.cls)
|
||||
self.assertIsInstance(users_service.auth_service, AuthService.cls)
|
||||
|
|
Loading…
Reference in New Issue
Block a user