def main(): APP_NAME = 'The Coffee Machine' parser = argparse.ArgumentParser(description='The Coffee Machine v0.0.1') parser.add_argument('-H', '--host', type=str, help='HTTP Server Host') parser.add_argument('-P', '--port', type=int, help='HTTP Server Port') parser.add_argument('-m', '--machine-svc-host', type=str, help='Machine Service Host') parser.add_argument('-n', '--machine-svc-port', type=int, help='Machine Service Port') parser.add_argument('-c', '--config', type=str, help='Configuration file path') parser.add_argument('-i', '--cpu-increase-interval', type=int, help='CPU increase interval [m]') parser.add_argument('-d', '--cpu-increase-duration', type=int, help='CPU increase duration [m]') parser.add_argument('-t', '--cpu-increase-threads', type=int, help='Number of threads for CPU increaser') parser.add_argument('-l', '--log-level', type=str, help='Application log level', default='info') args = parser.parse_args() if args.config: config = Config(config_path=args.config) conf_file = config.get_the_coffeemachine_config() conf_args = args_to_conf_dict(args=args) configuration = merge_configuration(from_file=conf_file, from_args=conf_args) else: configuration = args_to_conf_dict(args=args) configure_logging(args.log_level) log.info('********** Starting %s **********', APP_NAME) log.info('Configuration: %s', configuration) coffee_machine = CoffeeMachine( name=APP_NAME, host=configuration['host'], port=configuration['port'], machine_svc_host=configuration['machine_svc_host'], machine_svc_port=configuration['machine_svc_port'], cpu_increase_interval=configuration['cpu_increase_interval'], cpu_increase_duration=configuration['cpu_increase_duration'], cpu_increase_threads=configuration['cpu_increase_threads']) coffee_machine.run()
def main(): APP_NAME = 'The Coffee Lover' parser = argparse.ArgumentParser(description='The Coffee Lover v0.0.1') parser.add_argument('-H', '--host', type=str, help='The Coffee Bar Server Host') parser.add_argument('-P', '--port', type=int, help='The Coffe Bar Server Port') parser.add_argument('-r', '--ratio', type=int, help='Time interval for requests [s]') parser.add_argument('-c', '--config', type=str, help='Configuration file path') parser.add_argument('-l', '--log-level', type=str, help='Application log level', default='info') args = parser.parse_args() if args.config: config = Config(config_path=args.config) conf_file = config.get_the_coffee_lover_config() conf_args = args_to_conf_dict(args=args) configuration = merge_configuration(from_file=conf_file, from_args=conf_args) else: configuration = args_to_conf_dict(args=args) configure_basic_logging(args.log_level) log.info('********** Starting %s **********', APP_NAME) log.info('Configuration: %s', configuration) coffee_lover = CoffeeLover(bar_host=configuration['host'], bar_port=configuration['port'], ratio=configuration['ratio']) coffee_lover.run()
def main(): APP_NAME = 'The Coffee Bar' parser = argparse.ArgumentParser(description='The Coffee Bar v0.0.1') parser.add_argument('-H', '--host', type=str, help='HTTP Server Host') parser.add_argument('-P', '--port', type=int, help='HTTP Server Port') parser.add_argument('-m', '--coffeemachine-host', type=str, help='Coffe Machine Host') parser.add_argument('-n', '--coffeemachine-port', type=int, help='Coffee Machine Port') parser.add_argument('-j', '--cashdesk-host', type=str, help='Cashdesk Host') parser.add_argument('-k', '--cashdesk-port', type=int, help='Cashdeks Port') parser.add_argument('-c', '--config', type=str, help='Configuration file path') parser.add_argument('-l', '--log-level', type=str, help='Application log level', default='info') args = parser.parse_args() if args.config: config = Config(config_path=args.config) conf_file = config.get_the_coffee_bar_config() conf_args = args_to_conf_dict(args=args) configuration = merge_configuration(from_file=conf_file, from_args=conf_args) else: configuration = args_to_conf_dict(args=args) configure_logging(args.log_level) log.info('********** Starting %s **********', APP_NAME) log.info('Configuration: %s', configuration) the_bar = Bar(name=APP_NAME, host=configuration['host'], port=configuration['port'], coffee_machine_host=configuration['coffeemachine_host'], coffee_machine_port=configuration['coffeemachine_port'], cashdesk_host=configuration['cashdesk_host'], cashdesk_port=configuration['cashdesk_port']) the_bar.run()
def execute_test(): code_bytes = bytearray.fromhex(codeStr) config = Config('b80b05b998e017b0b170bc51c52b0f148cb990d3') params = build_params() print("params: ", params.hex()) config.tx = build_tx() # print(config.tx.serialize(True)) engine = ExecutionEngine() engine.push_context(ExecutionContext(engine, params)) num = 0 while (True): if len(engine.contexts) == 0: break engine.execute_code() if engine.op_code == ScriptOp.OP_RET: break if engine.op_code is None: pass elif ScriptOp.OP_PUSHBYTES1.value <= engine.op_code.value <= ScriptOp.OP_PUSHBYTES75.value: pass elif not engine.validate_op(): break else: if engine.op_code is not None: print( num, "> " + str(engine.evaluation_stack.count()) + " " + hex(engine.op_code.value) + " " + engine.op_exec.name + " " + engine.evaluation_stack.info2()) num += 1 if ScriptOp.OP_APPCALL == engine.op_code: print("####APPCALL####") num = 0 engine2 = ExecutionEngine() engine2.push_context(ExecutionContext(engine2, code_bytes)) engine.evaluation_stack.copy_to(engine2.evaluation_stack) engine = engine2 elif ScriptOp.OP_SYSCALL == engine.op_code: bys = engine.context.op_reader.read_var_bytes() print("####SYSCALL#### ", bys.decode()) service = ServiceMap.get_service(bys.decode()) if service is None: print(bys.decode()) return service.exec(config, engine) else: engine.step_info() print("##########end############") print("Stack Count:", engine.evaluation_stack.count()) items = engine.evaluation_stack.peek(0) if type(items) is ByteArrayItem: print( "Result ByteArrayItem:", engine.evaluation_stack.peek(0).get_bytearray().hex() + engine.evaluation_stack.peek(0).get_bytearray().decode()) elif type(items) is IntegerItem: print("Result GetBigInteger:", engine.evaluation_stack.peek(0).get_biginteger()) elif type(items) is BoolItem: print("Result BoolItem:", engine.evaluation_stack.peek(0).get_bool()) return
def __init__(self, conf=None, priv_key='', salt=''): if conf: try: cf = Config(filename=conf) except ConfigFileException as e: logger.exception(e) raise try: self.priv_key = cf.get('encrypt', 'private_key') except (NoOptionError, NoSectionError): self.priv_key = '' try: self.salt = cf.get('encrypt', 'salt') except (NoOptionError, NoSectionError): self.salt = '' try: self.encrypt_way = cf.get('encrypt', 'encrypt') except (NoOptionError, NoSectionError): self.encrypt_way = 'MD5' else: self.priv_key = priv_key self.salt = salt self.encrypt_way = 'MD5'
def __init__(self): cf = Config().get('mongodb') self.host = cf.get('host') self.port = cf.get('port') self.user = cf.get('user') self.password = cf.get('password') try: self.client = pymongo.MongoClient(self.host, port=int(self.port)) except: print('数据库连接失败')
def test_login(self): login_page = LoginPage(self.driver) login_page.url = Config().get('URL') login_page.visit() # time.sleep(10) login_page.wait(10) login_page.set_value(element=login_page.rec_user_input(), text=Config().get('USER')) login_page.set_value(element=login_page.rec_passwd_input(), text=Config().get('PASSWORD')) login_page.click_login_btn() login_page.get_windows_img()
def setUp(self): self.driver = Browser().get_browserdriver() login_page = LoginPage(self.driver) login_page.url = Config().get('URL') login_page.visit() # time.sleep(10) login_page.wait(10) login_page.set_value(element=login_page.rec_user_input(), text=Config().get('USER')) login_page.set_value(element=login_page.rec_passwd_input(), text=Config().get('PASSWORD')) login_page.click_login_btn() self.main_page = login_page.get_main_page()
class XSTZ_Android(unittest.TestCase): '''Android端测试''' USERNAME = Config().get("USERNAME") PWD = Config().get("PWD") desired_caps = Config().get("desired_caps") Remote_URL = Config().get("Remote_URL") driver = webdriver.Remote(Remote_URL, desired_caps) # 打开测试XSTZ程序主页 driver.implicitly_wait(30) @classmethod def setUpClass(cls): print("Android starting test...") def test_Android_1_login(self): '''Android 登录测试''' test_action = get_func_name() Login = LoginPage(self.driver) Login.enter_portal Login.login(self.USERNAME, self.PWD) result = Login.is_login_success data1 = {} data1[test_action] = result["data"] Android_data["suite"].update(data1) self.assertTrue(result["result"], msg=result["Exception"]) def test_Android_2_injection(self): test_action = get_func_name() JPage = InjectionPage(self.driver) JPage.click_injection_button result = JPage.is_injection_success # 验证点 data1 = {} data1[test_action] = result["data"] Android_data["suite"].update(data1) self.assertTrue(result["result"], msg=result["Exception"]) def test_Android_3_payway(self): test_action = get_func_name() DPage = ChannelSelect(self.driver) DPage.select_money DPage.select_payway result = DPage.is_deposit_success data1 = {} data1[test_action] = result["data"] Android_data["suite"].update(data1) self.assertTrue(result["result"], msg=result["Exception"]) @classmethod def tearDownClass(cls): cls.driver.quit()
def main(): APP_NAME = 'The Cashdesk' parser = argparse.ArgumentParser(description='The Cashdesk v0.0.1') parser.add_argument('-H', '--host', type=str, help='HTTP Server Host') parser.add_argument('-P', '--port', type=int, help='HTTP Server Port') parser.add_argument('-C', '--calculator-host', type=str, help='Calculator HTTP Server Host') parser.add_argument('-D', '--calculator-port', type=int, help='Calculator HTTP Server Port') parser.add_argument('-S', '--connection-string', type=str, help='Storage Connection String') parser.add_argument('-c', '--config', type=str, help='Config file path') parser.add_argument('-l', '--log-level', type=str, help='Application log level', default='info') args = parser.parse_args() if args.config: config = Config(config_path=args.config) conf_file = config.get_the_cashdesk_config() conf_args = args_to_conf_dict(args=args) configuration = merge_configuration(from_file=conf_file, from_args=conf_args) else: configuration = args_to_conf_dict(args=args) configure_logging(args.log_level) log.info('********** Starting %s **********', APP_NAME) log.info('Configuration: %s', configuration) cashdesk = CashDesk(name=APP_NAME, host=configuration['host'], port=configuration['port'], calculator_host=configuration['calculator_host'], calculator_port=configuration['calculator_port'], connection_string=configuration['connection_string']) cashdesk.run()
def main(): parser = argparse.ArgumentParser() parser.add_argument('-e', '--experiment', action='store', dest='config', default=EXPERIMENT_CONFIG) group = parser.add_mutually_exclusive_group(required=True) group.add_argument('-t', '--train', action='store_true', dest='train') group.add_argument('--test', action='store_true', dest='test') group.add_argument('--evaluate', action='store_true', dest='evaluate') parser.add_argument('-c', '--clear', action='store_true', dest='clear') parser.add_argument('-v', '--verbose', action='store', dest='log_level', default=logging.INFO) arguments = parser.parse_args(['-t']) clear_logs = arguments.clear if arguments.train else False session = Session(*Config(arguments.config, arguments.log_level).assemble(), clear=clear_logs) if arguments.train: session.train() elif arguments.test: session.test() elif arguments.evaluate: session.evaluate()
def get_config(self): try: config = Config(self.config) except FileNotFoundError: print("configuration file: %s not found" % config, file=sys.stderr) sys.exit(1) return config
class TestMall(unittest.TestCase): """统一订单接口""" API_URL = Config().get('API_URL').get('Pay') excel = DATA_PATH + '\PayTest.xlsx' def setUp(self): self.client = HTTPClient(url=self.API_URL, method='POST') def tearDown(self): logger.info('测试结束') def test_productlist(self): """钻石商城商品信息查询接口""" datas = ExcelReader(self.excel, sheet='ProductList').data for d in range(0, len(datas)): with self.subTest(data=datas[d]['describe']): self.setUp() # logger.debug(datas[d]) expect = datas[d]['expectation'] #请求的参数剔除期望值列、描述列 datas[d].pop('expectation') datas[d].pop('describe') params = datas[d] res = self.client.send(data=params) # logger.debug(res.text) # result = JMESPathExtractor().extract(query='[0].itemName', body=res.text) self.assertEqual(expect, res.text) self.tearDown()
class TestDeviceList(unittest.TestCase): """查询用户常用设备列表接口""" API_URL = Config().get('OpenPlatform_API').get('User2').get('DeviceList') excel = DATA_PATH + '/OpenPlatform_Player.xlsx' def setUp(self): self.client = HTTPClient(url=self.API_URL, method='GET') logger.info('开始测试') def tearDown(self): logger.info('结束测试') def test_DeviceList01(self): """简单验证查询用户常用设备列表接口容错""" datas = ExcelReader(self.excel, sheet='UserSearch').data for d in range(0, len(datas)): if datas[d]['is_execute'] == 'N': continue else: with self.subTest(data=datas[d]['CaseNo'] + datas[d]['describe']): self.setUp() # logger.debug(datas[d]) expect = json.loads( ast.literal_eval(json.dumps(datas[d]['expection']))) casename = str(datas[d]['describe']) caseNo = str(datas[d]['CaseNo']) #请求的参数剔除期望值列、是否执行列、描述列、用例编号列 datas[d].pop('expection') datas[d].pop('is_execute') datas[d].pop('describe') datas[d].pop('CaseNo') params = datas[d] res = self.client.send(params=params) # resultlist =[caseNo,casename,params,expect,res.text] # resultdata.qppend(resultlist) # logger.debug(res.text) result = JMESPathExtractor().extract(query='success', body=res.text) res_message = JMESPathExtractor().extract(query='message', body=res.text) res_error = JMESPathExtractor().extract(query='error', body=res.text) res_code = JMESPathExtractor().extract(query='code', body=res.text) responseTime = JMESPathExtractor().extract( query='responseTime', body=res.text) res_data = JMESPathExtractor().extract(query='data', body=res.text) msg = '\n请求地址:' + res.url + '\n返回结果:' + res.text if 'message' in expect.keys(): self.assertEqual(expect['message'], res_message, msg=msg) if 'error' in expect.keys(): self.assertEqual(expect['error'], res_error, msg=msg) self.assertEqual(expect['code'], res_code, msg=msg) if 'data' in expect.keys() and expect['data']: self.assertEqual(expect['data'], res_data, msg=msg) self.tearDown()
class TestProductChannelCreate(unittest.TestCase): """产品渠道添加接口""" API_URL = Config().get('OpenPlatform_API').get('ProductChannel').get('ProductChannelCreate') excel = DATA_PATH + '/OpenPlatform_Merchant.xlsx' def setUp(self): self.client = HTTPClient(url=self.API_URL, method='POST') self.mid = OpenPlatformCommon.getmid() self.cid = OpenPlatformCommon.getcid() logger.info('开始测试') def tearDown(self): logger.info('结束测试') def test_ProductChannelCreate01(self): """简单验证添加产品渠道接口容错""" datas = ExcelReader(self.excel,sheet='ProductChannel').data for d in range(0,len(datas)): if datas[d]['is_execute'] == 'N': continue else: with self.subTest(data=datas[d]['CaseNo']+datas[d]['describe']): self.setUp() # logger.debug(datas[d]) expect = datas[d]['expect_code'] casename = str(datas[d]['describe']) caseNo = str(datas[d]['CaseNo']) #请求的参数剔除期望值列、是否执行列、描述列、用例编号列 datas[d].pop('expect_code') datas[d].pop('is_execute') datas[d].pop('describe') datas[d].pop('CaseNo') if datas[d]['productId'] == '{pid}': datas[d]['productId'] = OpenPlatformCommon.getpid(self.mid) if datas[d]['channelId'] == '{cid}': datas[d]['channelId'] = self.cid #转换为json格式 params = json.dumps(datas[d]) headers={'Content-Type': "application/json"} res = self.client.send(data=params,headers=headers) # resultlist =[caseNo,casename,params,expect,res.text] # resultdata.qppend(resultlist) # logger.debug(res.text) result = JMESPathExtractor().extract(query='success', body=res.text) message = JMESPathExtractor().extract(query='message', body=res.text) msg = '\n请求地址:'+ res.url + '\n请求数据:' + params + '\n返回结果:' + res.text self.assertEqual(expect, str(result).lower(),msg=msg) self.assertNotIn('未知错误', str(message),msg=msg) self.tearDown() def test_ProductChannelCreate02(self): """验证添加产品渠道成功后返回""" data = {"productId": "39ef52a391245e17ae89d8166ddfd666", "channelId": "39ef52a390e53c09739be5209d765d6b"} params = json.dumps(data) headers={'Content-Type': "application/json"} res = self.client.send(data=params,headers=headers) result = JMESPathExtractor().extract(query='success', body=res.text) message = JMESPathExtractor().extract(query='message', body=res.text) msg = '\n请求地址:'+ res.url + '\n请求数据:' + params + '\n返回结果:' + res.text
def main() -> None: """ Runs the pipeline """ config = "config_test.yml" try: config = Config(config) except FileNotFoundError: print("configuration file: %s not found" % config, file=sys.stderr) sys.exit(1) # dictConfig(config.get("logging"))f log = logging.getLogger(__name__) log.info("Started") # Initialize Data Loader dl = dal.DataLoader(config) # Read csv data = dl.get_data() # Run Sum Pipeline sump = smp.TrainingPipe(config) data = sump.transform(data) # Run Subtract Pipeline subp = sbp.PreprocessPipe(config) data = subp.transform(data) # Save csv dl.save_csv(data)
class TestBaiDu(unittest.TestCase): URL = Config().get('URL') excel = DATA_PATH + '/baidu.xlsx' def sub_setUp(self): # 初始页面是main page,传入浏览器类型打开浏览器 self.page = BaiDuMainPage(browser_type='chrome').get( self.URL, maximize_window=True) #self.driver = webdriver.Chrome(executable_path=DRIVER_PATH+'\chromedriver.exe') #self.driver.get(self.URL) def sub_tearDown(self): #self.driver.quit() self.page.quit() def test_search(self): datas = ExcelReader(self.excel).data for d in datas: with self.subTest(data=d): self.sub_setUp() #self.driver.find_element(*self.locator_kw).send_keys(d['search']) #self.driver.find_element(*self.locator_su).click() self.page.search(d['search']) time.sleep(2) self.page = BaiDuResultPage(self.page) # 页面跳转到result page links = self.page.result_links #links = self.driver.find_elements(*self.locator_result) for link in links: logger.info(link.text) self.sub_tearDown()
class TestBaiDu(unittest.TestCase): URL = Config().get('uri') excel = DATA_PATH + '/baidu.xlsx' locator_kw = (By.ID, 'kw') locator_su = (By.ID, 'su') locator_result = (By.XPATH, '//div[contains(@class, "result")]/h3/a') def sub_setUp(self): self.driver = webdriver.Chrome(executable_path=DRIVER_PATH + '\chromedriver.exe') self.driver.get(self.URL) def sub_tearDown(self): self.driver.quit() def test_search(self): datas = ExcelReader(self.excel).data for d in datas: with self.subTest(data=d): self.sub_setUp() self.driver.find_element(*self.locator_kw).send_keys( d['search']) self.driver.find_element(*self.locator_su).click() time.sleep(2) links = self.driver.find_elements(*self.locator_result) for link in links: logger.info(link.text) self.sub_tearDown()
def getmcode(mid): """获取商户编号,商户名称,商户简称,商户类型,商户状态""" params = {"id": mid} url = Config().get('OpenPlatform_API').get('Merchant').get( 'MerchantGet') client = HTTPClient(url=url, method='GET') res = client.send(params=params) mcode = JMESPathExtractor().extract(query='data.code', body=res.text) mname = JMESPathExtractor().extract(query='data.name', body=res.text) mshortname = JMESPathExtractor().extract(query='data.shortName', body=res.text) #返回的商户类型 mtype = JMESPathExtractor().extract(query='data.type', body=res.text) #返回的商户类型名称 mtypename = JMESPathExtractor().extract(query='data.typeName', body=res.text) #返回的商户状态值 mstate = JMESPathExtractor().extract(query='data.state', body=res.text) #返回的商户状态 mstatename = JMESPathExtractor().extract(query='data.stateName', body=res.text) #返回的商户主体 mprincipal = JMESPathExtractor().extract(query='data.principal', body=res.text) #返回的社会统一信用码 mcreditcode = JMESPathExtractor().extract(query='data.creditCode', body=res.text) #返回的法人信息 mlegalrepresentative = JMESPathExtractor().extract( query='data.legalRepresentative', body=res.text) return mcode, mname, mshortname, mtype, mtypename, mstate, mstatename
def get_registinfo(): """ -----获取游客注册信息----- """ datas = { "type": 1, "channelNo": 81036962, "packageNo": 81036962001, "ip": "59.41.117.126", "machineCode": "AotutestRegister", "appId": "8103xqzESJOPvBzwHikLWwTXHfF6iZzE", "terminalType": 1, "osVersion": "Android.8.3.1", "machineModel": "MI 9", "payload": {}, "networkState": 0, "wifiName": "MISnet" } headers = {'Content-Type': "application/json"} url = Config().get('OpenPlatform_API').get('Player').get('Regist') client = HTTPClient(url=url, method='POST') res = client.send(data=json.dumps(datas), headers=headers) if JMESPathExtractor().extract(query='success', body=res.text): # res_openId = JMESPathExtractor().extract(query='data.openId', body=res.text) # res_unionId = JMESPathExtractor().extract(query='data.unionId', body=res.text) # res_nickname = JMESPathExtractor().extract(query='data.nickname', body=res.text) # res_account = JMESPathExtractor().extract(query='data.account', body=res.text) # res_password = JMESPathExtractor().extract(query='data.password', body=res.text) msg = JMESPathExtractor().extract(query='data', body=res.text) else: msg = "注册失败" return msg
class TestLoginout(unittest.TestCase): """登录登出测试""" URL = Config().get('URL') def setUp(self): self.page = LoginPage(browser_type='chrome').get(self.URL) def sub_tearDown(self): self.page.quit() def test_login(self): #输入用户名、密码、验证码,点击登录 self.page.set_username('admin') self.page.set_password('qkatest') self.page.set_code('123456') self.page.click_login WebDriverWait(self.page, 10).until( EC.presence_of_element_located(self.page.defaulttab), '1-登录失败') #验证登录的用户名是否为‘admin’,不等于将抛出异常 now_user = self.page.find_element_by_xpath( '//*[@id="header-nav"]/ul/li[4]/a/span').text if now_user == 'admin': print('登录成功!') else: raise NameError('用户名错误!')
def test_payment_channel2(self): '''支付通道2测试''' test_action = get_func_name() money = Config().get("money") try: CS = ChannelSelect(self.driver).select DPage2 = CS(self.driver) PaywayName = DPage2.get_payway_name(cn=0) Banklist, Bank_dic, Test_bank = DPage2.get_bank_detail DPage2.sumbit(money) bank_handle = DPage2.exchange_bank_page DPage2.close_bank_page(bank_handle) DPage2.return_payment_page assert bank_handle print("Test Success! ") print("Test PayWay:{}".format(PaywayName)) print("Test BankName:{}".format(Test_bank)) print("Available banks:{}".format(Banklist)) print(Bank_dic) result = self.result[0] ReturnCode = 0 logger.info("第三方支付跳转成功") except Exception as e: result = self.result[1] ReturnCode = 1 logger.error("Test Fail! Reason:{}".format(e)) finally: time.sleep(1) data = {test_action: {"result": result, "ReturnCode": ReturnCode}} self.data["suite"].update(data)
def getpid(mid, category=1, platform=0): """ -----获取产品id----- 参数-mid:所属商户id 参数-category:产品类型 1-APP 2-H5 3-小程序 参数-platform:产品APP平台 0-安卓 1-苹果 """ datas = { "merchantId": mid, "introduction": "Autotest自动化自动创建产品", "name": "Autotest测试", "department": "Web研发部门", "ecology": 0, "iconUrl": "Autotest", "category": category, "state": 1, "setting": { "platform": platform, "packageName": "Autotest", "signature": "Autotest", "bundleID": "Autotest.bundleID", "appId": "Autotest.appId", "h5Type": 0, "h5PlatformName": "AutotestH5", "h5Address": "Autotest.H5", "smallProgramId": "AutotestsmallProgramId", "smallPlatformType": 0 } } headers = {'Content-Type': "application/json"} url = Config().get('OpenPlatform_API').get('Product').get('Product') client = HTTPClient(url=url, method='POST') res = client.send(data=json.dumps(datas), headers=headers) pid = JMESPathExtractor().extract(query='data', body=res.text) return pid
def create_user(apps, schema_editor): config = Config() User.objects.create_superuser( username=config.superuser.username, email=config.superuser.email, password=config.superuser.password, )
def test_payment_channel1(self): '''支付通道1跳转''' money = Config().get("money") test_action = get_func_name() try: CS = ChannelSelect(self.driver).select DPage = CS(self.driver) PaywayName = DPage.get_payway_name(cn=1) # 选择第一个支付通道,获取 DPage.sumbit(money) # 提交 bank_handle = DPage.exchange_bank_page element = DPage.is_element_exist DPage.close_bank_page(bank_handle) DPage.return_payment_page assert element print("Test Success! ") print("Test PayWay:{}".format(PaywayName)) result = self.result[0] ReturnCode = 0 logger.info("第三方支付跳转成功") except Exception as e: print(str(e)) result = self.result[1] ReturnCode = 1 logger.error("Test Fail! Reason:{}".format(e)) finally: time.sleep(1) data = {test_action: {"result": result, "ReturnCode": ReturnCode}} self.data["suite"].update(data)
def main(): cfg = Config.fromfile('../src/config/testa.py') print(cfg) # init logger before other steps logger = setup_logger(logging.DEBUG) logger.info('test: {}'.format('pass'))
def get_path(key): config = Config.get_config() data_path = Path(config["base_path"]) / config[key] if not os.path.exists(data_path): os.mkdir(data_path) return data_path
class TestGuild(object): """docstring for TestGuild""" API_URL = Config().get('API_URL').get('InfoCheck') excel = DATA_PATH + '\APITest.xlsx' def test_checkinfo(self): datas = ExcelReader(self.excel).data print(datas)
def send_email(data): # 发送emil g = Config().get('email') e = Email(title=g.get('title'), message=g.get('message'), receiver=g.get('receiver'), HOST=g.get('HOST'), sender=g.get('sender'), password=g.get('password'), path=data) e.send()
def del_players(): # Load cfg = Config('config.ini') cfg.read() while True: # List of players print('Players:') for p in cfg.players: print('\t{}'.format(p.name)) # Get name to delete name = input('Please insert a player name to remove ' '(blank to save and quit): ') if name == "": break filtered_players = [p for p in cfg.players if p.name != name] if len(cfg.players) > len(filtered_players): print('Deleted {} players.'.format( len(cfg.players) - len(filtered_players))) cfg.players = filtered_players else: print('No players with that name.') # Save new list of players cfg.write()