Commit f4572b2c authored by lopezaguilar's avatar lopezaguilar
Browse files

Management of Exceptions

parent 1932bde9
Loading
Loading
Loading
Loading
+5 −7
Original line number Diff line number Diff line
@@ -53,8 +53,6 @@ class GenerateRobotData:
        _ = [self.get_step_data(test=x.name) for x in self.suite.tests]
        self.test_suite['test_cases'] = self.test_cases

        print()

    def get_params(self, string: str):
        params = list()
        request = str()
@@ -89,7 +87,7 @@ class GenerateRobotData:
                    # Get the list of keys
                    params = aux.split('    ')[1:]
                else:
                    print("Error, unexpected format")
                    raise Exception(f"Error, unexpected format, received: '{string}'")

        return request, params

@@ -159,7 +157,7 @@ class GenerateRobotData:
                    value = self.robot.variables[key]
                except KeyError:
                    # ERROR, the header key is not defined
                    print(f'ERROR, the header key {key} is undefined')
                    raise Exception(f"ERROR, the header key '{key}' is undefined")
        elif count == 2:
            keys = key.split("$")
            key = f'${keys[1]}'
@@ -168,7 +166,7 @@ class GenerateRobotData:
            try:
                second_key = self.ids[key]
            except KeyError:
                print(f"ERROR: Need to manage the {second_key} in GenerateRobotData::self.ids")
                raise Exception(f"ERROR: Need to manage the '{second_key}' in GenerateRobotData::self.ids")
            # Get the value of the Header key
            try:
                value = self.apiutil.variables[key]
@@ -180,7 +178,7 @@ class GenerateRobotData:
                    value = f'{value}{second_key}'
                except KeyError:
                    # ERROR, the header key is not defined
                    print(f'ERROR, the header key {key} is undefined')
                    raise Exception(f"ERROR, the header key '{key}' is undefined")



@@ -321,7 +319,7 @@ class GenerateRobotData:
        return reference, pics

    def get_info_from_template(self, name: str, string: str, version: str):
        # Check that the name of the template is in the string receive
        # TODO: Check that the name of the template is in the string receive
        print(name)

        # Get the Tags line and the tag value
+1 −1
Original line number Diff line number Diff line
@@ -42,7 +42,7 @@ class ParseApiUtilsFile:
                if match.group(1) not in self.variables.keys():
                    self.variables[match.group(1)] = match.group(2)
            else:
                print("Error, the variable is not following the format ${thing} = <value>")
                raise Exception("Error, the variable is not following the format ${thing} = <value>")

    def get_substring(self, initial_string: str, final_string: str, include: bool) -> str:
        index_start = self.file_contents.find(initial_string)
+2 −3
Original line number Diff line number Diff line
@@ -34,7 +34,7 @@ class ParseRobotFile:
            if len(match.groups()) == 2:
                self.variables[match.group(1)] = match.group(2)
            else:
                print("Error, the variable is not following the format ${thing} = <value>")
                raise Exception("Error, the variable is not following the format ${thing} = <value>")

    # def get_expected_status_code(self, keyword: str):
    #     #     Check Response Status Code    ${expected_status_code}    ${response.status_code}
@@ -62,7 +62,7 @@ class ParseRobotFile:
                if len(match.groups()) == 1:
                    self.resource_file = match.group(1)
                else:
                    print("Error, unexpected format")
                    raise Exception("Error, unexpected format")

            self.resource_file = self.resource_file.replace('${EXECDIR}', self.execdir)

@@ -83,7 +83,6 @@ class ParseRobotFile:
    def get_test_cases(self):
        index_start = self.file_contents.find('*** Test Cases ***')
        string = self.file_contents[index_start+len('*** Test Cases ***')+1:]
        print(string)

        pattern = f'{self.test_suite}_\d+\s.*'
        matches = re.findall(pattern=pattern, string=string)
+5 −5
Original line number Diff line number Diff line
@@ -8,8 +8,8 @@ if __name__ == "__main__":
    info = data.get_info()
    pprint(info)

    data = GenerateRobotData(robot_file='../TP/NGSI-LD/ContextInformation/Provision/Entities/CreateEntity/001_01.robot',
                             execdir='/home/fla/Documents/workspace/bdd/ngsi-ld-test-suite')
    data.parse_robot()
    info = data.get_info()
    pprint(info)
    # data = GenerateRobotData(robot_file='../TP/NGSI-LD/ContextInformation/Provision/Entities/CreateEntity/001_01.robot',
    #                          execdir='/home/fla/Documents/workspace/bdd/ngsi-ld-test-suite')
    # data.parse_robot()
    # info = data.get_info()
    # pprint(info)