Exemple #1
0
 def test_set_from_str(self):
     processor = processors.SetterInjection()
     processor.container = IocContainer()
     event = sample_event('tests.watson.di.support.SampleDependencyAware')
     event.params['definition']['setter'] = {'basic_setter': 'arg'}
     event.target = SampleDependencyAware()
     processor(event)
     assert event.target.value == 'arg'
Exemple #2
0
 def test_inject_property(self):
     processor = processors.AttributeInjection()
     processor.container = IocContainer()
     event = sample_event('tests.watson.di.support.SampleDependencyAware')
     event.params['definition']['property'] = {'basic_property': 'test value'}
     event.target = SampleDependencyAware()
     processor(event)
     assert event.target.basic_property == 'test value'
Exemple #3
0
 def test_inject_container(self):
     container = IocContainer()
     processor = processors.ContainerAware()
     processor.container = container
     event = sample_event('tests.watson.di.support.SampleDependencyAware')
     event.target = SampleDependencyAware()
     processor(event)
     assert event.target.container == container
Exemple #4
0
 def test_set_from_dict(self):
     processor = processors.SetterInjection()
     processor.container = IocContainer()
     event = sample_event('tests.watson.di.support.SampleDependencyAware')
     event.params['definition']['setter'] = {'basic_dict_setter': {'kw1': 'one', 'kw2': 'two'}}
     event.target = SampleDependencyAware()
     processor(event)
     assert event.target.kw1 == 'one'
     assert event.target.kw2 == 'two'