def __init__(self, host, port): self.headers = {} self.host = host self.port = port self.paras = {} self.data = {} self.log = BaseLineLogger.get_log()
def __init__(self, methodname='test_normal', api_data=None, http=None): super(BaseLineNormalCase, self).__init__(methodname) self.api_data = api_data self.http = http self.case_name = '' self.case_id = '' self.check_point = {} self.cache_dict = {} self.log = BaseLineLogger.get_log() self.__doc__ = 'api_data'
def __init__(self, methodname='test_normal', api_data=None, web_driver=None): super(BaseLineNormalCase, self).__init__(methodname) self.api_data = api_data self.web_driver = web_driver self.case_name = '' self.case_id = '' self.log = BaseLineLogger.get_log()
class BaseLineCachesNormal: log = BaseLineLogger.get_log() def __init__(self): pass @staticmethod def check_caches(dict_cache, dict_ret, http): if not isinstance(dict_ret, dict) or not isinstance(dict_cache, dict)\ or not isinstance(http, BaseLineHttp): raise TypeError # {"result":{"submitToken":"Submit_token", "userToken":"OPERATOR_TOKEN"}} # iterator the expected cache-key-value with recursive function def get_key_val(ret_dict, cache_dict, out_dict): for key in cache_dict: if key not in ret_dict.keys(): break if isinstance(cache_dict[key], dict) and isinstance( ret_dict[key], dict): get_key_val(ret_dict[key], cache_dict[key], out_dict) else: out_dict[cache_dict[key]] = ret_dict[key] # {"header":{"result":{"submitToken":"Submit_token", "userToken":"OPERATOR_TOKEN"}}} # iterator the expected cache categories: header, paras, data for key_cache in dict_cache: dict_out = {} get_key_val(dict_ret, dict_cache[key_cache], dict_out) if key_cache == 'header': http.set_header(dict_out) # elif key_cache == 'paras': # http.set_paras(dict_out) elif key_cache == 'data': http.set_data(dict_out) else: pass pass
class BaseLineCpNormal: log = BaseLineLogger.get_log() def __init__(self): pass @staticmethod def check_points(dict_cp, dict_ret, case_name, case_id): if not isinstance(dict_ret, dict) or not isinstance(dict_cp, dict): raise TypeError def compare_val(src, dest): for key in src: if key not in dest.keys(): msg = 'not found expected %s key from response' % (key, ) return False, msg if isinstance(src[key], dict) and isinstance(dest[key], dict): return compare_val(src[key], dest[key]) else: print(src[key]) rtn = True if src[key] == "*": if dest[key] == "": rtn = False elif src[key] != dest[key]: rtn = False msg = 'expected[%s]=%s, response[%s]=%s' % (key, src[key], key, dest[key]) BaseLineCpNormal.log.info( "[%s(%s)]: check_point: %s=%s, response: %s=%s", *(case_name, case_id, key, src[key], key, dest[key])) return rtn, msg return compare_val(dict_cp, dict_ret)
def __init__(self, base_url, port=None): self.base_url = "https://" + base_url self.port = port self.driver = webdriver.Firefox() self.driver.implicitly_wait(30) # 隐性等待时间为30秒 self.log = BaseLineLogger.get_log()