Exemple #1
0
    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'])
Exemple #2
0
def create_edit_component(input_dict: dict) -> str:
    """
    Receives a dict in the form defined under JSON_objects_definitions.py for either
    editing a component or creating a new component
    The answer is a JSON object, only containing the success state, which is True or False
    
    :param input_dict: dict containing all component attributes (special information
    to differentiate edit or create is contained in the UID, which is either -1 or the original UID
    :type input_dict: dict
    :return: A JSON object containing the success state, which is True or False
    """

    if input_dict["uid"] == "-1":
        result_dict = component_handler.add_component(input_dict)
        return processing.dict_to_json(result_dict)
    else:
        result_dict = component_handler.update_component(input_dict)
        return processing.dict_to_json(result_dict)
Exemple #3
0
 def test_1204_incorrect_uid(self):
     with self.assertRaises(CypherSyntaxError):
         UPDATE_COMPONENT_IN['uid'] = '123456789'
         update_component(UPDATE_COMPONENT_IN)
Exemple #4
0
 def test_1203_incorrect_metric(self):
     with self.assertRaises(CypherSyntaxError):
         wrong_input_dict = copy.deepcopy(UPDATE_COMPONENT_IN)
         wrong_input_dict['metrics']['number_of_administrators'] = 'zwei'
         update_component(wrong_input_dict)
Exemple #5
0
 def test_1202_incorrect_dict_structure(self):
     with self.assertRaises(KeyError):
         update_component({"test": 1, "test2": 2})
Exemple #6
0
    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'])