def test_fill_in_contexts_desc(self): base.BaseActor.all_options = { 'test_opt': (str, REQUIRED, 'Test option') } self.actor = base.BaseActor(desc='Unit Test Action - {NAME}', options={'test_opt': 'Foo bar'}, condition='{NAME}', init_context={'NAME': 'TEST'}) self.assertEqual('Unit Test Action - TEST', self.actor._desc) self.assertEqual('TEST', self.actor._condition) with self.assertRaises(exceptions.InvalidOptions): self.actor = base.BaseActor(desc='Unit Test Action', options={'test_opt': 'Foo {BAZ} bar'}, init_context={}) with self.assertRaises(exceptions.InvalidOptions): self.actor = base.BaseActor(desc='Unit Test Action - {NAME}', options={}, init_context={}) with self.assertRaises(exceptions.InvalidOptions): self.actor = base.BaseActor(desc='Unit Test Action', options={'test_opt': 'Foo bar'}, condition='{NAME}', init_context={}) # Reset the all options so we dont break other tests base.BaseActor.all_options = {}
def setUp(self): super(TestBaseActor, self).setUp() # Create a BaseActor object self.actor = base.BaseActor('Unit Test Action', {}) # Mock out the actors ._execute() method so that we have something to # test self.actor._execute = self.true
def test_fill_in_contexts_options_escape(self): base.BaseActor.all_options = { 'test_opt': (str, REQUIRED, 'Test option') } self.actor = base.BaseActor(desc='Unit Test Action', options={'test_opt': 'Foo bar - \{NAME\}'}, init_context={'NAME': 'TEST'}) self.assertEqual('Foo bar - {NAME}', self.actor.option('test_opt')) # Reset the all options so we dont break other tests base.BaseActor.all_options = {}