def test_deep_update_dict(self): origin_dict = {'a': 1, 'b': {'c': 3, 'd': 4}, 'f': 6, 'h': 123} override_dict = {'a': 2, 'b': {'c': 33, 'e': 5}, 'g': 7, 'h': None} updated_dict = utils.deep_update_dict(origin_dict, override_dict) self.assertEqual( updated_dict, {'a': 2, 'b': {'c': 33, 'd': 4, 'e': 5}, 'f': 6, 'g': 7, 'h': 123} )
def test_deep_update_dict(self): origin_dict = {'a': 1, 'b': {'c': 3, 'd': 4}, 'f': 6} override_dict = {'a': 2, 'b': {'c': 33, 'e': 5}, 'g': 7} updated_dict = utils.deep_update_dict(origin_dict, override_dict) self.assertEqual( updated_dict, {'a': 2, 'b': {'c': 33, 'd': 4, 'e': 5}, 'f': 6, 'g': 7} )
def test_run_testcase_with_empty_header(self): testcase_file_path = os.path.join(os.getcwd(), 'tests/data/test_bugfix.yml') testsets = loader.load_testcases(testcase_file_path) testset = testsets[0] config_dict_headers = testset["config"]["request"]["headers"] test_dict_headers = testset["teststeps"][0]["request"]["headers"] headers = deep_update_dict(config_dict_headers, test_dict_headers) self.assertEqual(headers["Content-Type"], "application/json")
def get_parsed_request(self, request_dict, level="testcase"): """ get parsed request with bind variables and functions. @param request_dict: request config mapping @param level: testset or testcase """ if level == "testset": request_dict = self.eval_content(request_dict) self.testset_request_config.update(request_dict) testcase_request_config = utils.deep_update_dict( copy.deepcopy(self.testset_request_config), request_dict) parsed_request = self.eval_content(testcase_request_config) return parsed_request
def get_parsed_request(self, request_dict, level="testcase"): """ get parsed request with bind variables and functions. @param request_dict: request config mapping @param level: testset or testcase """ if level == "testset": #将非常规类型的参数处理为常规类型的参数,以字典形式返回 request_dict = self.testcase_parser.parse_content_with_bindings( request_dict) #将处理后的参数字典更新到testset_request_config{} self.testset_request_config.update(request_dict) #合并字典 testcase_request_config = utils.deep_update_dict( copy.deepcopy(self.testset_request_config), request_dict) parsed_request = self.testcase_parser.parse_content_with_bindings( testcase_request_config) return parsed_request
def get_parsed_request(self, request_dict, level='teststep'): ''' get parsed request with variables and functions. Args: request_dict (dict): request config mapping level (enum): 'testcase' or 'teststep' Returns: dict: parsed request dict ''' if level == 'testcase': # testcase config request dict has been parsed in parse_tests self.TESTCASE_SHARED_REQUSET_MAPPING = copy.deepcopy(request_dict) return self.TESTCASE_SHARED_REQUSET_MAPPING else: # teststep return self.eval_content( utils.deep_update_dict( copy.deepcopy(self.TESTCASE_SHARED_REQUSET_MAPPING), request_dict))
def get_parsed_request(self, request_dict, level="testcase"): """ get parsed request with bind variables and functions. @param request_dict: request config mapping @param level: testset or testcase """ if level == "testset": request_dict = self.eval_content( request_dict ) self.testset_request_config.update(request_dict) testcase_request_config = utils.deep_update_dict( copy.deepcopy(self.testset_request_config), request_dict ) parsed_request = self.eval_content( testcase_request_config ) return parsed_request