Exemplo n.º 1
0
    def setUpClass(cls):
        cls.maxDiff = None
        # get old process_list
        process_list_pre = get_process_list()['processes']
        # add new component
        add_process(PROCESS_WITHOUT_TARGET_METRICS)
        # get new process_list
        process_list_post = get_process_list()['processes']

        cls.uid = None
        cls.componentUid = None

        for post_uid in process_list_post:
            if post_uid not in process_list_pre:
                cls.uid = post_uid['uid']

        UID_DICT["uid"] = cls.uid
        PROCESS_WITHOUT_TARGET_METRICS["process"]["uid"] = cls.uid

        component_list_pre = get_component_list()['components']
        # add new component
        add_component(ADD_COMPONENT_IN)
        component_list_post = get_component_list()['components']

        for post_uid in component_list_post:
            if post_uid not in component_list_pre:
                cls.componentUid = post_uid['uid']

        ADD_PROCESS_REFERENCE["process_uid"] = cls.uid
        ADD_PROCESS_REFERENCE["component_uid"] = cls.componentUid

        add_process_reference(ADD_PROCESS_REFERENCE)
Exemplo n.º 2
0
    def setUpClass(cls):

        component_list_pre = get_component_list()['components']
        # add new component
        add_component(ADD_COMPONENT_IN)
        component_list_post = get_component_list()['components']

        for post_uid in component_list_post:
            if post_uid not in component_list_pre:
                cls.uid = post_uid['uid']
Exemplo n.º 3
0
    def setUp(self):
        add_component(ADD_COMPONENT_IN)
        component_list_post = get_component_list()['components']

        for post_uid in component_list_post:
            if post_uid in self.component_list_pre:
                continue
            self.uid = post_uid['uid']

        DELETE_COMPONENT_IN['uid'] = self.uid
        GET_COMPONENT_IN['uid'] = self.uid
Exemplo n.º 4
0
    def test_1304_incorrect_metrics(self):

        with self.assertRaises(DoesNotExist):
            wrong_input_dict = copy.deepcopy(ADD_COMPONENT_IN)
            wrong_input_dict['metrics']['test_metric'] = 2
            add_component(wrong_input_dict)

        with self.assertRaises((ValueError, DeflateError)):
            wrong_input_dict = copy.deepcopy(ADD_COMPONENT_IN)
            wrong_input_dict['metrics']['number_of_administrators'] = 'zwei'
            add_component(wrong_input_dict)
Exemplo n.º 5
0
    def setUpClass(cls):

        component_list_pre = get_component_list()['components']
        # add new component
        for i in range(0, cls.amount):
            add_component(ADD_COMPONENT_IN)
        component_list_post = get_component_list()['components']

        for post_uid in component_list_post:
            if post_uid not in component_list_pre:
                cls.uid.append(post_uid['uid'])
Exemplo n.º 6
0
    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'])
Exemplo n.º 7
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)
Exemplo n.º 8
0
 def test_1302_incorrect_dict_structure(self):
     with self.assertRaises(KeyError):
         add_component({"test": 1, "test2": 2})