Loading doc/analysis/generaterobotdata.py +20 −12 Original line number Diff line number Diff line Loading @@ -53,6 +53,19 @@ class GenerateRobotData: _ = [self.get_step_data(test=x.name) for x in self.suite.tests] self.test_suite['test_cases'] = self.test_cases # Generate the permutation key to provide the keys in test_cases list that are different self.test_suite['permutations'] = self.get_permutation_keys(data=self.test_suite['test_cases']) def get_permutation_keys(self, data): all_keys = set().union(*data) excluded_keys = ['doc', 'permutation_tp_id', 'setup', 'teardown', 'name', 'params', 'tags'] all_keys = [x for x in all_keys if x not in excluded_keys] keys_with_different_values = [ key for key in all_keys if any(d.get(key) != data[0].get(key) for d in data[1:]) ] return keys_with_different_values def get_params(self, string: str): params = list() request = str() Loading Loading @@ -200,8 +213,8 @@ class GenerateRobotData: 'config_id': '', 'parent_release': version, 'pics_selection': pics, 'keywords': self.suite.keywords, 'teardown': self.suite.teardown, 'keywords': list(self.suite.keywords), 'teardown': str(self.suite.teardown), 'initial_condition': self.suite.setup, 'test_cases': list() } Loading @@ -223,19 +236,16 @@ class GenerateRobotData: if len(self.args) != 0: # We are talking about Test Cases with Test Template, so we need to check the keyword content with the # definition of the template params = self.args[test.name] index = [index for index, value in enumerate(self.arguments) if value == '${content_type}'][0] content_type = params[index] body = self.get_body(string=test.name) # params = self.args[test.name] # index = [index for index, value in enumerate(self.arguments) if value == '${content_type}'][0] # content_type = params[index] # # body = self.get_body(string=test.name) # Generate Checks for Test Data then = self.robot.get_checks(test_name=test.template, apiutils=self.apiutil) else: # We are talking about a Test Cases without Test Template content_type = '' body = '' # Generate Checks for Test Data then = self.robot.get_checks(test_name=test.name, apiutils=self.apiutil) Loading @@ -250,8 +260,6 @@ class GenerateRobotData: 'setup': test.setup.name, 'teardown': test.teardown.name, 'template': test.template, 'content-type': content_type, 'body': body, 'then': then, 'when': when } Loading doc/analysis/parserobotfile.py +23 −4 Original line number Diff line number Diff line Loading @@ -109,9 +109,10 @@ class ParseRobotFile: # Get The lines starting by 'Check' checks = list() param = dict() lines_starting_with_check = re.findall(r'^\s*Check.*', test_content, re.MULTILINE) # lines_starting_with_check = re.findall(r'^\s*Check.*', test_content, re.MULTILINE) lines_starting_with_check = self.get_lines_with_checks(content=test_content) for line in lines_starting_with_check: check, param = self.get_data_check(test_case=test_content, checks=data, line=line.strip()) check, param = self.get_data_check(test_case=test_content, checks=data, line=line) result = data.get_checks(checks=check, **param) checks.append(result) Loading @@ -119,6 +120,21 @@ class ParseRobotFile: return result def get_lines_with_checks(self, content): # Obtain the complete list of lines that contains a Check lines_starting_with_check = re.findall(r'^\s*Check.*', content, re.MULTILINE) # From the list of Checks, we need to discard all 'Check Response Status Code' except the last one check_string = 'Check Response Status Code' lines_starting_with_check = [x.strip() for x in lines_starting_with_check] new_list = [value for value in lines_starting_with_check if not value.startswith(check_string)] abb_values = [value for value in lines_starting_with_check if value.startswith(check_string)] if abb_values: new_list.append(abb_values[-1]) return new_list def get_request(self, test_name): print(test_name) data = Requests(variables=self.variables, apiutils_variables=self.apiutils.variables) Loading Loading @@ -158,7 +174,7 @@ class ParseRobotFile: position_params=position_params) return content[0], params elif aux > 1: # We are in one line definiton # We are in one line definition params = self.find_attributes_same_line(params=position_params, content=content) return content[0], params else: Loading Loading @@ -206,6 +222,9 @@ class ParseRobotFile: try: result = self.variables[position] except KeyError: try: result = self.apiutils.variables[position] except KeyError: result = position return result doc/generateDocumentationData.py +5 −2 Original line number Diff line number Diff line from pprint import pprint from doc.analysis.generaterobotdata import GenerateRobotData import json if __name__ == "__main__": data = GenerateRobotData(robot_file='../TP/NGSI-LD/CommonBehaviours/043.robot', data = GenerateRobotData(robot_file='../TP/NGSI-LD/CommonBehaviours/044_01.robot', execdir='/home/fla/Documents/workspace/bdd/ngsi-ld-test-suite') data.parse_robot() info = data.get_info() pprint(info) with open('result.json', 'w') as fp: json.dump(obj=info, indent=4, fp=fp) # data = GenerateRobotData(robot_file='../TP/NGSI-LD/ContextInformation/Provision/Entities/CreateEntity/001_01.robot', # execdir='/home/fla/Documents/workspace/bdd/ngsi-ld-test-suite') Loading Loading
doc/analysis/generaterobotdata.py +20 −12 Original line number Diff line number Diff line Loading @@ -53,6 +53,19 @@ class GenerateRobotData: _ = [self.get_step_data(test=x.name) for x in self.suite.tests] self.test_suite['test_cases'] = self.test_cases # Generate the permutation key to provide the keys in test_cases list that are different self.test_suite['permutations'] = self.get_permutation_keys(data=self.test_suite['test_cases']) def get_permutation_keys(self, data): all_keys = set().union(*data) excluded_keys = ['doc', 'permutation_tp_id', 'setup', 'teardown', 'name', 'params', 'tags'] all_keys = [x for x in all_keys if x not in excluded_keys] keys_with_different_values = [ key for key in all_keys if any(d.get(key) != data[0].get(key) for d in data[1:]) ] return keys_with_different_values def get_params(self, string: str): params = list() request = str() Loading Loading @@ -200,8 +213,8 @@ class GenerateRobotData: 'config_id': '', 'parent_release': version, 'pics_selection': pics, 'keywords': self.suite.keywords, 'teardown': self.suite.teardown, 'keywords': list(self.suite.keywords), 'teardown': str(self.suite.teardown), 'initial_condition': self.suite.setup, 'test_cases': list() } Loading @@ -223,19 +236,16 @@ class GenerateRobotData: if len(self.args) != 0: # We are talking about Test Cases with Test Template, so we need to check the keyword content with the # definition of the template params = self.args[test.name] index = [index for index, value in enumerate(self.arguments) if value == '${content_type}'][0] content_type = params[index] body = self.get_body(string=test.name) # params = self.args[test.name] # index = [index for index, value in enumerate(self.arguments) if value == '${content_type}'][0] # content_type = params[index] # # body = self.get_body(string=test.name) # Generate Checks for Test Data then = self.robot.get_checks(test_name=test.template, apiutils=self.apiutil) else: # We are talking about a Test Cases without Test Template content_type = '' body = '' # Generate Checks for Test Data then = self.robot.get_checks(test_name=test.name, apiutils=self.apiutil) Loading @@ -250,8 +260,6 @@ class GenerateRobotData: 'setup': test.setup.name, 'teardown': test.teardown.name, 'template': test.template, 'content-type': content_type, 'body': body, 'then': then, 'when': when } Loading
doc/analysis/parserobotfile.py +23 −4 Original line number Diff line number Diff line Loading @@ -109,9 +109,10 @@ class ParseRobotFile: # Get The lines starting by 'Check' checks = list() param = dict() lines_starting_with_check = re.findall(r'^\s*Check.*', test_content, re.MULTILINE) # lines_starting_with_check = re.findall(r'^\s*Check.*', test_content, re.MULTILINE) lines_starting_with_check = self.get_lines_with_checks(content=test_content) for line in lines_starting_with_check: check, param = self.get_data_check(test_case=test_content, checks=data, line=line.strip()) check, param = self.get_data_check(test_case=test_content, checks=data, line=line) result = data.get_checks(checks=check, **param) checks.append(result) Loading @@ -119,6 +120,21 @@ class ParseRobotFile: return result def get_lines_with_checks(self, content): # Obtain the complete list of lines that contains a Check lines_starting_with_check = re.findall(r'^\s*Check.*', content, re.MULTILINE) # From the list of Checks, we need to discard all 'Check Response Status Code' except the last one check_string = 'Check Response Status Code' lines_starting_with_check = [x.strip() for x in lines_starting_with_check] new_list = [value for value in lines_starting_with_check if not value.startswith(check_string)] abb_values = [value for value in lines_starting_with_check if value.startswith(check_string)] if abb_values: new_list.append(abb_values[-1]) return new_list def get_request(self, test_name): print(test_name) data = Requests(variables=self.variables, apiutils_variables=self.apiutils.variables) Loading Loading @@ -158,7 +174,7 @@ class ParseRobotFile: position_params=position_params) return content[0], params elif aux > 1: # We are in one line definiton # We are in one line definition params = self.find_attributes_same_line(params=position_params, content=content) return content[0], params else: Loading Loading @@ -206,6 +222,9 @@ class ParseRobotFile: try: result = self.variables[position] except KeyError: try: result = self.apiutils.variables[position] except KeyError: result = position return result
doc/generateDocumentationData.py +5 −2 Original line number Diff line number Diff line from pprint import pprint from doc.analysis.generaterobotdata import GenerateRobotData import json if __name__ == "__main__": data = GenerateRobotData(robot_file='../TP/NGSI-LD/CommonBehaviours/043.robot', data = GenerateRobotData(robot_file='../TP/NGSI-LD/CommonBehaviours/044_01.robot', execdir='/home/fla/Documents/workspace/bdd/ngsi-ld-test-suite') data.parse_robot() info = data.get_info() pprint(info) with open('result.json', 'w') as fp: json.dump(obj=info, indent=4, fp=fp) # data = GenerateRobotData(robot_file='../TP/NGSI-LD/ContextInformation/Provision/Entities/CreateEntity/001_01.robot', # execdir='/home/fla/Documents/workspace/bdd/ngsi-ld-test-suite') Loading