2015-03-10 17:12:42 +03:00
|
|
|
"""Objects injections unittests."""
|
|
|
|
|
|
|
|
import unittest2 as unittest
|
2015-03-12 01:10:51 +03:00
|
|
|
|
2015-03-10 17:12:42 +03:00
|
|
|
from objects.injections import Injection
|
2015-03-23 02:04:18 +03:00
|
|
|
from objects.injections import KwArg
|
2015-03-12 01:10:51 +03:00
|
|
|
from objects.injections import Attribute
|
|
|
|
from objects.injections import Method
|
|
|
|
|
|
|
|
from objects.providers import NewInstance
|
2015-03-10 17:12:42 +03:00
|
|
|
|
|
|
|
|
2015-03-15 16:31:05 +03:00
|
|
|
class InjectionTests(unittest.TestCase):
|
2015-03-10 17:12:42 +03:00
|
|
|
|
|
|
|
"""Injection test cases."""
|
|
|
|
|
|
|
|
def test_init(self):
|
|
|
|
"""Test Injection creation and initialization."""
|
|
|
|
injection = Injection('some_arg_name', 'some_value')
|
|
|
|
self.assertEqual(injection.name, 'some_arg_name')
|
|
|
|
self.assertEqual(injection.injectable, 'some_value')
|
2015-03-11 01:23:26 +03:00
|
|
|
|
|
|
|
def test_value_with_scalar_injectable(self):
|
2015-03-12 01:10:51 +03:00
|
|
|
"""Test Injection value property with scalar value."""
|
2015-03-11 01:23:26 +03:00
|
|
|
injection = Injection('some_arg_name', 'some_value')
|
|
|
|
self.assertEqual(injection.value, 'some_value')
|
2015-03-12 01:10:51 +03:00
|
|
|
|
|
|
|
def test_value_with_provider_injectable(self):
|
|
|
|
"""Test Injection value property with provider."""
|
|
|
|
injection = Injection('some_arg_name', NewInstance(object))
|
|
|
|
self.assertIsInstance(injection.value, object)
|
|
|
|
|
|
|
|
|
2015-03-15 16:31:05 +03:00
|
|
|
class InitArgTests(unittest.TestCase):
|
2015-03-12 01:10:51 +03:00
|
|
|
|
|
|
|
"""Init arg injection test cases."""
|
|
|
|
|
|
|
|
def test_init(self):
|
2015-03-23 02:04:18 +03:00
|
|
|
"""Test KwArg creation and initialization."""
|
|
|
|
injection = KwArg('some_arg_name', 'some_value')
|
2015-03-12 01:10:51 +03:00
|
|
|
self.assertEqual(injection.name, 'some_arg_name')
|
|
|
|
self.assertEqual(injection.injectable, 'some_value')
|
|
|
|
|
|
|
|
|
2015-03-15 16:31:05 +03:00
|
|
|
class AttributeTests(unittest.TestCase):
|
2015-03-12 01:10:51 +03:00
|
|
|
|
|
|
|
"""Attribute injection test cases."""
|
|
|
|
|
|
|
|
def test_init(self):
|
|
|
|
"""Test Attribute creation and initialization."""
|
|
|
|
injection = Attribute('some_arg_name', 'some_value')
|
|
|
|
self.assertEqual(injection.name, 'some_arg_name')
|
|
|
|
self.assertEqual(injection.injectable, 'some_value')
|
|
|
|
|
|
|
|
|
2015-03-15 16:31:05 +03:00
|
|
|
class MethodTests(unittest.TestCase):
|
2015-03-12 01:10:51 +03:00
|
|
|
|
|
|
|
"""Method injection test cases."""
|
|
|
|
|
|
|
|
def test_init(self):
|
|
|
|
"""Test Method creation and initialization."""
|
|
|
|
injection = Method('some_arg_name', 'some_value')
|
|
|
|
self.assertEqual(injection.name, 'some_arg_name')
|
|
|
|
self.assertEqual(injection.injectable, 'some_value')
|