def test_lookup_variables2(self): '''Test variables resolution through multiple entities''' service = BaseEntity('test_service') service.add_var('VAR', 'test') group = BaseEntity('group_service') group.add_var('GVAR', 'group') service.parent = group self.assertEqual(service._lookup_variable('VAR'), 'test') self.assertEqual(service._lookup_variable('GVAR'), 'group')
def test_lookup_variables4(self): '''Test variables resolution with a var referencing a property''' service = BaseEntity('test_service') service.add_var('VAR', 'test') group = BaseEntity('group_service') group.add_var('GVAR', 'group') service.parent = group self.assertEqual(service._lookup_variable('GVAR'), 'group') self.assertEqual(service._lookup_variable('TARGET'), None) self.assertEqual(service._lookup_variable('NAME'), 'test_service')
def test_remove_variable(self): '''Remove a variable, defined or not, is fine.''' svc = BaseEntity('test_var') svc.add_var('var', 'foo') self.assertEqual(svc._lookup_variable('var'), 'foo') # Remove it svc.remove_var('var') self.assertRaises(UndefinedVariableError, svc._lookup_variable, 'var') # Remove it again does not raise an exception. svc.remove_var('var') self.assertRaises(UndefinedVariableError, svc._lookup_variable, 'var')
def test_lookup_variables1(self): '''Test variables resolution through a single entity''' service = BaseEntity('test_service') service.add_var('VAR', 'test') self.assertEqual(service._lookup_variable('VAR'), 'test')
def test_lookup_global_variables(self): '''Test global variables resolution''' service = BaseEntity('test_service') service_manager_self().add_var('MGRVAR', 'test') self.assertEqual(service._lookup_variable('MGRVAR'), 'test')