def transformation_from_entry(entry, my_locals): if type(entry) == str: transform = get_transformation_by_name(entry) result = transform(dict()) else: transform = get_transformation_by_name(entry["name"]) parameters = { k: inject(v, my_locals) for k, v in entry.get("parameters", dict()).items() } result = transform(parameters) return result
def build_tests(): ats = inject(AdventuresTests) test = lambda self: _test_request_returns( self, 'post', '/%s/1/execute' % self._pluralize(self.base_object), {}, 400) test.__name__ = 'test_adventure_execute_no_node_returns_400' setattr(ats, test.__name__, test) test = lambda self: _test_seed_data_request_returns( self, 'post', '/%s/1/execute' % self._pluralize(self.base_object), {'node': 9999999}, 404, {self.base_object: 1}) test.__name__ = 'test_adventure_execute_non_existant_node_returns_404' setattr(ats, test.__name__, test) test = lambda self: _test_seed_data_request_returns( self, 'post', '/%s/999999/execute' % self._pluralize(self.base_object), {'node': 1}, 404, {'node': 1}) test.__name__ = 'test_adventure_execute_non_existant_adventure_returns_404' setattr(ats, test.__name__, test) return ats
n1 = self._model_get_by_id('nodes', self.n1['id']) self.assertEquals(n1['facts']['test_fact'], 'test_value2') def test_list_all_facts(self): self._model_create('facts', node_id=self.n1['id'], key='test_fact', value='test_value') result = self._model_get_all('facts') # 2 facts are parent_ids from setup self.assertEquals(len(result), 3) def test_request_bad_fact(self): resp = self.client.get('/admin/facts/9999') self.assertEquals(resp.status_code, 404) def update_bad_fact(self): resp = self.client.put('/admin/facts/9999', content_type='application/json', data=json.dumps({'value': 'test'})) self.assertEquals(resp.status_code, 404) def test_request_fact(self): fact = self._model_create('facts', node_id=self.n1['id'], key='test_fact', value='test_value') self.app.logger.debug('fact: %s' % fact) self._model_get_by_id('facts', fact['id']) FactsTests = inject(FactsTests)
self._model_create('tasks', state='running', node_id=self.node['id'], action='something', payload={}, completed=prunable_time) all_tasks = self._model_get_all('tasks') self.assertTrue(len(all_tasks) == 1) class TaskGenericTests(OpenCenterTestCase): base_object = 'task' TaskGenericTests = inject(TaskGenericTests) class TaskCreateTests(unittest2.TestCase): @classmethod def setUpClass(self): self.foo = webapp.WebServer('opencenter', configfile='tests/test.conf', debug=True) self.app = self.foo.test_client() self.content_type = 'application/json' @classmethod def tearDownClass(self): pass