Add FactoryAsDecoratorTests

This commit is contained in:
Roman Mogilatov 2016-02-28 17:50:47 +02:00
parent 71b820487e
commit c8fda3da8d

View File

@ -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)