From 0414ab54605168df049124e8b55ed3982aa0be8e Mon Sep 17 00:00:00 2001 From: Roman Mogilatov Date: Thu, 12 Mar 2015 00:10:51 +0200 Subject: [PATCH] adding injections module unittests --- tests/test_injections.py | 46 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 45 insertions(+), 1 deletion(-) diff --git a/tests/test_injections.py b/tests/test_injections.py index b084b04e..adea1082 100644 --- a/tests/test_injections.py +++ b/tests/test_injections.py @@ -1,7 +1,13 @@ """Objects injections unittests.""" import unittest2 as unittest + from objects.injections import Injection +from objects.injections import InitArg +from objects.injections import Attribute +from objects.injections import Method + +from objects.providers import NewInstance class InjectionTest(unittest.TestCase): @@ -15,6 +21,44 @@ class InjectionTest(unittest.TestCase): self.assertEqual(injection.injectable, 'some_value') def test_value_with_scalar_injectable(self): - """Test Injection value property.""" + """Test Injection value property with scalar value.""" injection = Injection('some_arg_name', 'some_value') self.assertEqual(injection.value, 'some_value') + + 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) + + +class InitArgTest(unittest.TestCase): + + """Init arg injection test cases.""" + + def test_init(self): + """Test InitArg creation and initialization.""" + injection = InitArg('some_arg_name', 'some_value') + self.assertEqual(injection.name, 'some_arg_name') + self.assertEqual(injection.injectable, 'some_value') + + +class AttributeTest(unittest.TestCase): + + """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') + + +class MethodTest(unittest.TestCase): + + """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')