def setUpClass(cls): Log.info('TestUserLogin START BB端') # cls.lc = LoadConfig() # cls.domain = cls.lc.get_domain() cls.dh = DataHandle() # 布里端 cls.L = Login(node=2)
def setUpClass(cls): Log.info('TestDownloadTaskHK START HK端') cls.node = 1 cls.dh = DataHandle() # 香港端 cls.L = Login(node=cls.node) cls.admin_cookies = cls.L.get_cookie() cls.df = DownloadFile(node=cls.node)
def setUpClass(cls): Log.info('TestGetServerBB START BB端') cls.node = 2 cls.dh = DataHandle() # 布里端 cls.L = Login(node=cls.node) cls.admin_cookies = cls.L.get_cookie() cls.cal_get = CalGet(node=cls.node)
def setUpClass(cls): Log.info('TestQueryInStatusBB START BB端') cls.node = 2 cls.dh = DataHandle() # 香港端 cls.L = Login(node=cls.node) cls.admin_cookies = cls.L.get_cookie() cls.ui = UserInfo(node=cls.node)
def setUpClass(cls): Log.info('TestGetGenResultHK START HK端') cls.node = 1 cls.dh = DataHandle() # 香港端 cls.L = Login(node=cls.node) cls.admin_cookies = cls.L.get_cookie() cls.h_t = HistoryTest(node=cls.node)
def setUpClass(cls): Log.info('TestDownloadPublicTaskBB START BB端') cls.node = 2 cls.dh = DataHandle() # 布里端 cls.L = Login(node=cls.node) cls.admin_cookies = cls.L.get_cookie() cls.df = DownloadFile(node=cls.node)
def setUpClass(cls): Log.info('TestGetListByAcceptHK START HK端') cls.node = 1 cls.dh = DataHandle() # 香港端 cls.L = Login(node=cls.node) cls.admin_cookies = cls.L.get_cookie() cls.cal_get = CalGet(node=cls.node)
def setUpClass(cls): Log.info('TestCancelTaskBB START BB端') cls.node = 2 cls.dh = DataHandle() # 布里端 cls.L = Login(node=cls.node) cls.admin_cookies = cls.L.get_cookie() cls.cancel_task = CancelTask(node=cls.node)
def setUpClass(cls): Log.info('TestQueryUpdateFlagHK START HK端') cls.node = 1 cls.dh = DataHandle() # 香港端 cls.L = Login(node=cls.node) cls.admin_cookies = cls.L.get_cookie() cls.cancel_task = CancelTask(node=cls.node)
def setUpClass(cls): Log.info('TestGetErrorResultBB START BB端') cls.node = 2 cls.dh = DataHandle() # 布里端 cls.L = Login(node=cls.node) cls.admin_cookies = cls.L.get_cookie() cls.h_g = HistoryGWAS(node=cls.node)
def setUpClass(cls): Log.info('TestUpLoadFileHK START HK端') cls.node = 1 cls.dh = DataHandle() # 香港端 cls.L = Login(node=cls.node) cls.admin_cookies = cls.L.get_cookie() cls.fh = FileHandle(node=cls.node)
def setUpClass(cls): Log.info('TestComputeMulBB START BB端') cls.node = 2 cls.dh = DataHandle() # 布里端 cls.L = Login(node=cls.node) cls.admin_cookies = cls.L.get_cookie() cls.comp_vcf = ComputeVcf(node=cls.node)
def setUpClass(cls): Log.info('TestVCFStartHK START HK端') cls.node = 1 cls.dh = DataHandle() # 香港端 cls.L = Login(node=cls.node) cls.admin_cookies = cls.L.get_cookie() cls.cal_vcf = CalVcf(node=cls.node)
def setUpClass(cls): Log.info('TestGetListBB START BB端') cls.node = 2 cls.dh = DataHandle() # 布里端 cls.L = Login(node=cls.node) cls.admin_cookies = cls.L.get_cookie() cls.h_t = HistoryTest(node=cls.node)
def setUpClass(cls): Log.info('TestGwasStartBB START BB端') cls.node = 2 cls.dh = DataHandle() # 布里端 cls.L = Login(node=cls.node) cls.admin_cookies = cls.L.get_cookie() cls.cal_gwas = CalGwas(node=cls.node)
def setUpClass(cls): Log.info('TestComputeGwasBB START BB端') cls.node = 2 # 计算类型 gwas;3 cls.calType = 3 cls.dh = DataHandle() # 布里端 cls.L = Login(node=cls.node) cls.admin_cookies = cls.L.get_cookie() cls.comp_gwas = ComputeGwas(node=cls.node)
def setUpClass(cls): Log.info('TestComputeVcfHK START HK端') cls.node = 1 # 计算类型 vcf;1 cls.calType = 1 cls.dh = DataHandle() # 香港端 cls.L = Login(node=cls.node) cls.admin_cookies = cls.L.get_cookie() cls.comp_vcf = ComputeVcf(node=cls.node)
def setUpClass(cls): Log.info('TestComputeGenHK START HK端') cls.node = 1 # 计算类型 gen;2 cls.calType = 2 cls.dh = DataHandle() # 香港端 cls.L = Login(node=cls.node) cls.admin_cookies = cls.L.get_cookie() cls.comp_gen = ComputeGen(node=cls.node)
def setUpClass(cls): Log.info('TestUpdateUserHK START HK端') cls.node = 1 cls.dh = DataHandle() # 香港端 cls.L = Login(node=cls.node) cls.admin_cookies = cls.L.get_cookie() cls.ui = UserInfo(node=cls.node) # cls.url = cls.lc.get_domain() + cls.dh.get_path(1) # auto登录cookie cls.AUTO_cookies = cls.ui.modify_cookies(data_id=3001, node=cls.node)
def setUpClass(cls): Log.info('TestDownloadLogFileBB START BB端') cls.node = 2 cls.dh = DataHandle() # 布里端 cls.L = Login(node=cls.node) cls.admin_cookies = cls.L.get_cookie() cls.df = DownloadFile(node=cls.node) cls.ui = UserInfo(node=cls.node) # auto登录cookie cls.AUTO_cookies = cls.ui.modify_cookies(data_id=3001, node=cls.node)
def setUpClass(cls): Log.info('TestUserInfoBB START BB端') # cls.lc = LoadConfig() # cls.domain = cls.lc.get_domain() cls.node = 2 cls.dh = DataHandle() # 布里端 cls.L = Login(node=cls.node) cls.admin_cookies = cls.L.get_cookie() cls.ui = UserInfo(node=cls.node) # cls.url = cls.lc.get_domain() + cls.dh.get_path(1) # auto登录cookie cls.modify_cookie = cls.ui.modify_cookies(data_id=3001, node=cls.node)
test_dir = '../cases' discover = unittest.defaultTestLoader.discover(test_dir, pattern='test_*.py') if __name__ == "__main__": Log.info('*' * 100) Log.info('run START') # 运行前账户状态(update,Automation)检查 BeforeCheck(node=1).check() BeforeCheck(node=2).check() # 报告文件 now = time.strftime("%Y%m%d%H%M%S") filename = '../report/' + now + '_result.html' fp = open(filename, 'wb') # result文件,写入标题 dh = DataHandle() title = [['id', 'name', 'actual', 'expect', 'result', str(now)]] dh.write_data(title) runner = HTMLTestRunner(stream=fp, verbosity=2, title='NEMO Test Report', description='Implementation Example with: ') runner.run(discover) fp.close() Log.info('run FINISH') Log.info('*' * 100)
class Base: headers = { 'Content-Type': 'application/json;charset=UTF-8', 'Connection': 'keep-alive', 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) ' 'Chrome/66.0.3359.117 Safari/537.36' } lc = LoadConfig() dh = DataHandle() def __init__(self, node, path_id): """ @:param node 1: hongkong other:bulisiban @:param p_id path id """ self.domain = self.lc.get_domain_h( ) if node == 1 else self.lc.get_domain_b() self.url = self.domain + self.dh.get_path(path_id) pass @staticmethod def check(res): """1 成功 0 失败""" code = '00000' if res["code"] == code: Log.debug('actual res check is 1') return 1 else: Log.debug('actual res check is 0') return 0 @classmethod def get_req_para(cls, para_id, data_id): para_source = cls.dh.get_para(para_id) cls.data_source = cls.dh.get_data(data_id)[0] req_para = DataHandle.combine_data(para_source, cls.data_source) return req_para @staticmethod def make_password(password): return hashlib.md5(password.encode('utf-8')).hexdigest() @staticmethod def gene_username(): return 'test{}'.format(int(time.strftime("%Y%m%d%H%M%S"))) @staticmethod def order_dic_by_keys(data): """字典按key排序""" sorted_data = collections.OrderedDict() for key in sorted(data.keys()): sorted_data[key] = data[key] return sorted_data @staticmethod def sign_modify(data): """ 只能处理PKCS#1 RSA Private Key file 格式: -----BEGIN RSA PRIVATE KEY----- -----END RSA PRIVATE KEY----- -----BEGIN RSA PUBLIC KEY----- -----END RSA PUBLIC KEY----- """ # 加签私钥 keyfile = os.path.join(os.path.abspath('../config'), 'keyen.pem') pri_key = rsa.PrivateKey.load_pkcs1( keyfile=open(keyfile, 'r').read().encode()) # 数据排序 sorted_data = Base.order_dic_by_keys(data) # sorted_data = collections.OrderedDict() # for key in sorted(data.keys()): # sorted_data[key] = data[key] str_data = json.dumps(sorted_data) # 去掉空格 str_data = str_data.split() str_data = ''.join(str_data) # 签名 signature = rsa.sign(str_data.encode(encoding='utf-8'), priv_key=pri_key, hash='SHA-1') sig = base64.b16encode(signature).lower().decode() res = {"msg": str_data, "signature": sig} Log.info('加签数据为:{}'.format(json.dumps(res))) return json.dumps(res) @staticmethod def sign(data): """ 同时处理PKCS#1 PKCS#8 -----BEGIN PRIVATE KEY----- -----END PRIVATE KEY----- 限制:公私钥文件必须分离,且-----END PRIVATE KEY-----之后不能又空格及空行 """ # 数据排序 sorted_data = Base.order_dic_by_keys(data) str_data = json.dumps(sorted_data) # 去掉空格 str_data = str_data.split() str_data = ''.join(str_data) file = os.path.join(os.path.abspath('../config'), 'private.txt') keyfile = open(file, 'r').read() private_key = RSA.importKey(keyfile) cipher = PKCS1_v1_5.new(private_key) h = SHA.new(str_data.encode()) signature = cipher.sign(h) sig = base64.b16encode(signature).lower().decode() res = {"msg": str_data, "signature": sig} res = json.dumps(res) Log.info('加签数据为:{}'.format(res)) return res @staticmethod def str2sec(str_t): str_t = str_t h, m, s = str_t.strip().split(':') return int(h) * 3600 + int(m) * 60 + int(s)
def setUpClass(cls): Log.info('TestUserLogoutBB START BB端') cls.node = 2 cls.dh = DataHandle() # 布里端 cls.LO = Logout(node=cls.node)
def setUpClass(cls): Log.info('TestUserLogoutHK START HK端') cls.node = 1 cls.dh = DataHandle() # 香港端 cls.LO = Logout(node=cls.node)