def test_1002_incorrect_uid(self): uids_to_be_tested = [1.5, 'abc'] for uid in uids_to_be_tested: GET_COMPONENT_IN['uid'] = uid with self.assertRaises(IndexError): get_component(GET_COMPONENT_IN)
def test_1101_correct_input(self): self.assertTrue(get_component(GET_COMPONENT_IN)['success']) result = delete_component(DELETE_COMPONENT_IN) self.assertEqual(result, DELETE_COMPONENT_OUT) with self.assertRaises(IndexError): get_component(GET_COMPONENT_IN)
def test_1001_correct_inputs(self): result = get_component(GET_COMPONENT_IN) del result['component']['creation_timestamp'] del result['component']['last_timestamp'] self.assertEqual(result, GET_COMPONENT_OUT)
def test_1205_unknown_metric(self): UPDATE_COMPONENT_IN['uid'] = self.uid wrong_input_dict = copy.deepcopy(UPDATE_COMPONENT_IN) wrong_input_dict['metrics']['test_metric'] = 2 self.assertEqual(update_component(wrong_input_dict), UPDATE_COMPONENT_OUT) GET_COMPONENT_IN['uid'] = self.uid result = get_component(GET_COMPONENT_IN) self.assertTrue('test_metric' not in result['component']['metrics'])
def test_1301_correct_inputs(self): result = add_component(ADD_COMPONENT_IN) self.assertEqual(result, ADD_COMPONENT_OUT) component_list_post = get_component_list()['components'] for post_uid in component_list_post: if post_uid in self.component_list_pre: continue GET_COMPONENT_IN['uid'] = post_uid['uid'] self.assertTrue(get_component(GET_COMPONENT_IN)['success'])
def get_component(input_dict: dict) -> str: """ Receives a dict in the form defined under JSON_objects_definitions.py for getting/viewing a component. It returns another JSON object, structured as described in docu/JSON_objects_definitions.py which is retrieved from the component_handler. :param input_dict: dict containing the component uid :type input_dict: dict :return: Returns a JSON object, structured as described in docu/JSON_objects_definitions.py representing a component """ component_dict = component_handler.get_component(input_dict) output_json = processing.dict_to_json(component_dict) return output_json
def test_1201_correct_inputs(self): result = update_component(UPDATE_COMPONENT_IN) self.assertEqual(result, UPDATE_COMPONENT_OUT) self.assertTrue(get_component(GET_COMPONENT_IN)['success'])
def test_1004_incorrect_dict_structure(self): with self.assertRaises(KeyError): get_component({"test": 1, "test2": 2}) with self.assertRaises(TypeError): get_component('abc')