def driver_select_api(self, currentPage='1', rows='10', mobile='', name='', carNo='', recentLineStart='', recentLineEnd=''): '''查询已关联的外请车''' self.logger.info('##### {0} #####'.format(__name__)) try: payload = { 'currentPage': currentPage, 'rows': rows, 'partnerNo': self.partnerNo, 'name': name, 'mobile': mobile, 'carNo': carNo, 'recentLineStart': recentLineStart, 'recentLineEnd': recentLineEnd } response = HttpClient().get(self.__driverSelectApiUrl, self.__head_dict, payload) return response except Exception as e: Log().error('查询已关联的外请车发生异常:{0}'.format(e)) return None
def supplier_update(self, supplierId, name='', type='', contactPersonName='', contactPersonMobile='', contactPersonIdNo='', contactPersonIdCardPhoto='', businessLicencePhoto='', businessPermitPhoto='', taxRegistrationCertificatePhoto='', contractPhoto=''): '''修改供应商信息''' try: payload = { 'supplierId': supplierId, 'name': name, 'type': type, 'contactPersonName': contactPersonName, 'contactPersonMobile': contactPersonMobile, 'contactPersonIdNo': contactPersonIdNo, 'contactPersonIdCardPhoto': contactPersonIdCardPhoto, 'businessLicencePhoto': businessLicencePhoto, 'businessPermitPhoto': businessPermitPhoto, 'taxRegistrationCertificatePhoto': taxRegistrationCertificatePhoto, 'contractPhoto': contractPhoto, } response = HttpClient().post_json(self.__supplierUpdateApiUrl, payload, self.__head_dict) return response except Exception as e: Log().error('修改供应商信息发生异常:{0}'.format(e)) return None
def payment_single(self, wayBillId, paymentMethod=None, amountType=None, amount='', password='', verifiCode=''): try: payload = { 'wayBillId': wayBillId, # 运单ID,String,必填 'paymentMethod': paymentMethod, # 支付方式,int【贷款付商户=3】、【余额付司机=2】、【白条付司机=1】、【线下支付=4】 'amountType': amountType, # 预付款1,油卡2,到付款3,尾款4,总运费9 'amount': amount, # 实际支付金额,double 'password': password, # 使用线下支付时必填,其他不填; 'verifiCode': verifiCode, # 可能会有,非必填 } response = HttpClient().post_json(self.__paymentSingleApiUrl, header_dict=self.__head_dict, body_dict=payload, param_dict=payload) return response except Exception as e: Log().error('单条支付接口调用异常:{0}'.format(e)) return None
def payment_export(self, currentPage='', rows='', searchMode='', globalCondition='', sendCity='', arriveCity='', carNo='', driverName='', applyDateFirst='1', applyDateLast='', carType='', amountType='', approveDateFirst='', approveDateLast='', paySchedule='', isLoan=''): ''' 支付列表导出 ''' try: payload = { 'searchMode': searchMode, # global:全部字段模糊查询 general:普通条件查询 'currentPage': currentPage, # 当前页 'rows': rows, # 行数 'globalCondition': globalCondition, # 全部字段模糊查询条件 'sendCity': sendCity, # 出发城市 'arriveCity': arriveCity, # 到达城市 'carNo': carNo, # 车牌号 'driverName': driverName, # 司机姓名 'applyDateFirst': applyDateFirst, # 用车日期查询开始 'applyDateLast': applyDateLast, # 用车日期查询截止 'carType': carType, # 用车性质 'amountType': amountType, # 运费类型,cash - 预付款、oilFee - 油卡金额、destAmt - 到付款、retAmt - 尾款 'approveDateFirst': approveDateFirst, # 支付审批日期开始 'approveDateLast': approveDateLast, # 支付审批日期截止 'paySchedule': paySchedule, # 支付进度,UNPAID - 未支付、SUCCESS - 已支付、PAYING - 支付中、FAIL - 支付失败 'isLoan': isLoan # 是否贷款,1 - 是,0 - 否 } response = HttpClient().post_json(self.__paymentExportApiUrl, header_dict=self.__head_dict, param_dict=payload) return response except Exception as e: Log().error('支付列表导出接口调用异常:{0}'.format(e)) return None
def setUp(self): self.logger = Log() self.logger.info( '####################### TestReceiptUploadWayBill START #######################' ) carType = str(random.randint(1, 2)) applyDate = time.strftime('%Y-%m-%d') photoAirWay = FileUtil.getProjectObsPath() + '/image/photoAirWay.jpg' self.wayBillId = CreateWayBill().create_waybill( carType, applyDate, photoAirWay, '北京', '北京', '', '天津', '天津', '', '1000', '10', '0.01', '0.02', '0.03', '0.04', '1', '备注我要录单测试', 'TMS', '零担', '10', '100', '1000', '10000', '100000', '20', '30', '40', '50', 'DD001', 'YK001', 'LSVAM4187C2184847', '6222810001000', '中国银行', '张三')[0] self.receipt_0 = FileUtil.getProjectObsPath( ) + os.path.sep + 'image' + os.path.sep + 'logo.png'
def count_amt_get(self, countName, applyDateFirst='', applyDateLast='', sendCity='', arriveCity='', carNo='', driverName='', isCanLoan='', globalCondition='', searchMode='searchMode:general'): try: payload = { 'countName': countName, # 需统计的金额:amtFee 总运费,cash 预付款,oilFee 油卡,destAmtConfirm 到付金额,retAmtConfirm 尾款金额 'applyDateFirst': applyDateFirst, # 用车日期查询开始 'applyDateLast': applyDateLast, # 用车日期查询截止 'sendCity': sendCity, # 出发城市 'arriveCity': arriveCity, # 到达城市 'carNo': carNo, # 车牌号 'driverName': driverName, # 司机姓名 'isCanLoan': isCanLoan, # 是否可贷款,1:可贷款,0:不可贷款 'globalCondition': globalCondition, 'searchMode': searchMode, } response = HttpClient().get(self.__countAmtGetApiUrl, self.__head_dict, payload) return response except Exception as e: Log().error('待支付合计金额统计值获取接口调用异常:{0}'.format(e)) return None
def loan_create(self, loanAmount='', recipientName='', recipientAccount='', depositBank='', remarks='', demandLoanDate=''): '''创建大额贷款记录''' try: payload = { 'loanAmount': loanAmount, # 贷款金额, 'loanCustomer': self.partnerNo, # 贷款客户, 'recipientName': recipientName, # 收款户名, 'recipientAccount': recipientAccount, # 收款账号, 'depositBank': depositBank, # 开户行, 'remarks': remarks, # 备注信息, 'partnerNo': self.partnerNo, # 物流公司标识, 'demandLoanDate': demandLoanDate, # 需求放款日期, } response = HttpClient().post_json(self.__loanCreateApiUrl, payload, self.__head_dict) return response except Exception as e: Log().error('创建大额贷款记录发生异常:{0}'.format(e)) return None
def user_update(self, userId='', roleId='', name='', userName='', mobile='', isLoginApp='', projectId='', carType=''): '''修改账号''' try: dataAuth = "{{'tableAuthList':[{{'name':'AppTransportCashModel','propAuthList':[{{'name':'projectId'," \ "'values':'{0}'}},{{'name':'carType','values':'{1}'}}]}},{{'name':'TmsProjectModel','propAuthList'" \ ":[{{'name':'projectId','values':'{1}'}}]}}]}}".format(projectId, carType) payload = { 'partnerNo': self.partnerNo, 'loginId': userId, 'role': roleId, 'name': name, 'userName': userName, 'mobile': mobile, 'isLoginApp': isLoginApp, 'dataAuth': dataAuth, } response = HttpClient().post_json(self.__userUpdateApiUrl, payload, self.__head_dict, payload) return response except Exception as e: Log().error('修改账号发生异常:{0}'.format(e)) return None
def my_driver_update(self, driverId='', mobile='', name='', idNo='', photoDriverCard='', frontIdCard='', backIdCard=''): '''新增自有司机''' try: payload = { 'driverId': driverId, 'mobile': mobile, 'name': name, 'idNo': idNo, 'photoDriverCard': photoDriverCard, 'frontIdCard': frontIdCard, 'backIdCard': backIdCard, 'partnerNo': self.partnerNo, } response = HttpClient().post_json(self.__myDriverUpdateApiUrl, payload, self.__head_dict) return response except Exception as e: Log().error('新增自有司机发生异常:{0}'.format(e)) return None
def setUp(self): self.logger = Log() self.logger.info( '########################### TestMyCarDelete START ###########################' ) self.carNo = DataUtil().genneratorCarNo() self.carModel = DataUtil().genneratorCarTypeInfo() self.carLength = DataUtil().genneratorCarLength() self.buycarTime = time.strftime('%Y-%m-%d') self.photoDriverCard = 'http://yudian.ufile.ucloud.com.cn/a0e806f9-c3d3-479d-bca4-e992a0c7412c.jpg?UCloudPublicKey=ucloudtangshd@weifenf.com14355492830001993909323&Expires=&Signature=BOj9MjmPyxmvu0wzzlJVGoueyx8=' self.photoCar = 'http://yudian.ufile.ucloud.com.cn/69eec140-f95d-4af7-9aaf-c57b8442d799.jpg?UCloudPublicKey=ucloudtangshd@weifenf.com14355492830001993909323&Expires=&Signature=bPzioEVJ8i4E3iXi+Yx7KQSeHvw=' self.carId = CreateMyCar().create_my_car(self.carNo, self.carModel, self.carLength, '10', '', self.buycarTime, '长城', self.photoDriverCard, self.photoCar)
def line_update(self, id='', sendProvince='', sendCity='', arriveProvince='', arriveCity='', mileage='', arriveTime='', projectId=''): '''根据ID修改线路''' try: payload = { 'id': id, 'sendProvince': sendProvince, 'sendCity': sendCity, 'arriveProvince': arriveProvince, 'arriveCity': arriveCity, 'mileage': mileage, 'arriveTime': arriveTime, 'projectId': projectId, } response = HttpClient().post_json(self.__lineUpdateApiUrl, payload, self.__head_dict) return response except Exception as e: Log().error('根据ID修改线路发生异常:{0}'.format(e)) return None
def cost_settings_select(self, currentPage='1', rows='1000', sendCity='', arriveCity='', carType='', carLength='', carModel='', projectId=''): '''收入成本参数配置列表查询''' try: payload = { 'currentPage': currentPage, 'rows': rows, 'sendCity': sendCity, 'arriveCity': arriveCity, 'carType': carType, 'carLength': carLength, 'carModel': carModel, 'projectId': projectId, } response = HttpClient().post_json(self.__costSettingsSelectApiUrl, payload, self.__head_dict) return response except Exception as e: Log().error('收入成本参数配置列表查询发生异常:{0}'.format(e)) return None
def setUp(self): self.logger = Log() self.logger.info( '########################### TestGetDetailWayBill START ###########################' ) self.carType = str(random.randint(1, 2)) self.applyDate = time.strftime('%Y-%m-%d') photoAirWay = FileUtil.getProjectObsPath() + '/image/photoAirWay.jpg' self.wayBillId = CreateWayBill().create_waybill( self.carType, self.applyDate, photoAirWay, '北京', '北京', '', '天津', '天津', '', '1000', '10', '0.01', '0.02', '0.03', '0.04', '1', '备注我要录单测试', 'TMS', '零担', '10', '100', '1000', '10000', '100000', '20', '30', '40', '50', 'DD001', 'YK001', 'LSVAM4187C2184847', '6222810001000', '中国银行', '张三')[0] Settings().system_params_update() WayBillDelete().waybill_delete(self.wayBillId)
def statement_export(self, billType='', applyDateFirst='', applyDateLast='', verificDateStart='', verificDateEnd='', sendCity='', arriveCity='', driver='', project='', supplier='', verificStatus=''): '''客户/供应商对账单导出''' try: payload = { 'billType': billType, # 对账单类型,1-客户对账单;2-供应商对账单 'applyDateFirst': applyDateFirst, 'applyDateLast': applyDateLast, 'verificDateStart': verificDateStart, 'verificDateEnd': verificDateEnd, 'sendCity': sendCity, 'arriveCity': arriveCity, 'driver': driver, 'project': project, 'supplier': supplier, 'verificStatus': verificStatus, #核销状态,非必填。0:未核销,1:已核销;非必填 } response = HttpClient().post_form(self.__statementExportApiUrl, payload, self.__head_dict) return response except Exception as e: Log().error('客户/供应商对账单导出发生异常:{0}'.format(e)) return None
def setUp(self): self.logger = Log() self.logger.info('########################### TestSupplierUpdate START ###########################') self.name = '哇哈哈集团' self.contactPersonMobile = DataUtil().createmoble() self.contactPersonIdNo = DataUtil().genneratorIdNo() self.contactPersonIdCardPhoto = "http://yudian.ufile.ucloud.com.cn/18d4d203-3712-43c7-93d9-9b791aa4806d.jpg?UCloudPublicKey=ucloudtangshd@weifenf.com14355492830001993909323&Expires=&Signature=CGRGouKFXGdBh3aI4+gK+nA5XmU=" self.businessLicencePhoto = "http://yudian.ufile.ucloud.com.cn/9503b68e-6e0b-40df-b30f-c7af545da878.jpg?UCloudPublicKey=ucloudtangshd@weifenf.com14355492830001993909323&Expires=&Signature=42hC+hmiXMNbRIoR8H4wipW0SI8=" self.businessPermitPhoto = "http://yudian.ufile.ucloud.com.cn/8539002d-b90f-4a1a-b19c-22b2135cbf6b.jpg?UCloudPublicKey=ucloudtangshd@weifenf.com14355492830001993909323&Expires=&Signature=hwTz+Pk8yffBXUwEbgSsoVU9QT4=" self.taxRegistrationCertificatePhoto = "http://yudian.ufile.ucloud.com.cn/b117b5e1-e4d5-47f6-8e81-50bb344c3896.jpg?UCloudPublicKey=ucloudtangshd@weifenf.com14355492830001993909323&Expires=&Signature=4+YLofibFNAqF1PhOFoNSqu4CN4=" self.contractPhoto = "http://yudian.ufile.ucloud.com.cn/b2098698-56e7-425e-9186-61dbb966310a.jpg?UCloudPublicKey=ucloudtangshd@weifenf.com14355492830001993909323&Expires=&Signature=IknyOZi+hHvHpyajfp8HI3aANqA=" self.supplierId = CreateSupplier().create_supplier(self.name, '1', '李经理', self.contactPersonMobile, self.contactPersonIdNo, self.contactPersonIdCardPhoto, self.businessLicencePhoto, self.businessPermitPhoto, self.taxRegistrationCertificatePhoto, self.contractPhoto)
def payment_receipt_select(self, currentPage='1', rows='10', applyDateFirst='', applyDateLast='', sendCity='', arriveCity='', carNo='', driverName='', isCanLoan='', globalCondition='', searchMode='general'): try: payload = { 'currentPage': currentPage, # 当前页 'rows': rows, # 行数 'applyDateFirst': applyDateFirst, # 用车日期查询开始 'applyDateLast': applyDateLast, # 用车日期查询截止 'sendCity': sendCity, # 出发城市 'arriveCity': arriveCity, # 到达城市 'carNo': carNo, # 车牌号 'driverName': driverName, # 司机姓名 'isCanLoan': isCanLoan, # 是否可贷款,1:可贷款,0:不可贷款 'globalCondition': globalCondition, # 普通的查询条件 'searchMode': searchMode, # 查询方式,高级查询general,普通查询global } response = HttpClient().get(self.__paymentReceiptSelectApiUrl, self.__head_dict, payload) return response except Exception as e: Log().error('回单支付列表查询接口调用异常:{0}'.format(e)) return None
class TestCreateWaybillEmploy(unittest.TestCase): # 物流云APP 新建外请车运单 def setUp(self): """前置条件准备""" self.logger = Log() self.logger.info( '########################### TestCreateWaybill START ###########################' ) config = ReadYaml(FileUtil.getProjectObsPath() + '/config/config.yaml').getValue() app_package = config['appPackage_wuliuyun'] app_activity = config['appActivity_wuliuyun'] # AppUiDriver(appPackage=app_package, appActivity=app_activity).app_ui_driver() # 单例测试 启动driver self.employ_driver = config['employ_driver_mobile'] self.driver = AppUiDriver(appPackage=app_package, appActivity=app_activity).get_driver() self.driver_tool = DriverOperation(self.driver) self.driver.start_activity(app_activity=app_activity, app_package=app_package) DbOperation().delete_waybill_driver(mobile=self.employ_driver) pass def tearDown(self): """测试环境重置""" DbOperation().delete_waybill_driver(mobile=self.employ_driver) self.logger.info( '########################### TestCreateWaybill END ###########################' ) pass def test_create_waybill_employ(self): # 新建外请车运单 create_waybill = WaybillCreateWuLiuYun(self.driver) WuLiuYunWaybillTab(self.driver).wait_main_page() WuLiuYunWaybillTab(self.driver).go_to_create_waybill() self.driver_tool.getScreenShot('test_create_waybill_employ') create_waybill.input_basic_info(car_type='1') create_waybill.input_goods_info() create_waybill.input_driver_info(car_type='1', mobile=self.employ_driver) create_waybill.input_cost_info() create_waybill.commit_waybill_info() self.driver_tool.getScreenShot('test_create_waybill_employ') main_page = WuLiuYunWaybillTab(self.driver).wait_main_page() self.assertTrue(main_page) waybill = DbOperation().select_waybill_state(self.employ_driver)[0] self.assertEqual(waybill, 'W')
class DriverSelectApi(object): ''' 我的外请车列表,查询结果是已关联的外请车 /api/tms/driver/listTmsAppDriver ''' __slots__ = ('__driverSelectApiUrl', 'partnerNo', '__head_dict', 'logger') def __init__(self): config = ReadYaml(FileUtil.getProjectObsPath() + '/config/config.yaml').getValue() self.__driverSelectApiUrl = "https://{0}:{1}{2}/api/tms/driver/listTmsAppDriver".format( config['tms_api_host'], config['tms_api_port'], config['tms_api_path']) self.__head_dict = { 'token': config['tms_api_token'], 'yd_oauth': config['tms_api_token'], } self.partnerNo = config['partnerNo'] self.logger = Log() def driver_select_api(self, currentPage='1', rows='10', mobile='', name='', carNo='', recentLineStart='', recentLineEnd=''): '''查询已关联的外请车''' self.logger.info('##### {0} #####'.format(__name__)) try: payload = { 'currentPage': currentPage, 'rows': rows, 'partnerNo': self.partnerNo, 'name': name, 'mobile': mobile, 'carNo': carNo, 'recentLineStart': recentLineStart, 'recentLineEnd': recentLineEnd } response = HttpClient().get(self.__driverSelectApiUrl, self.__head_dict, payload) return response except Exception as e: Log().error('查询已关联的外请车发生异常:{0}'.format(e)) return None
class TestWaybillReceiptUpload(unittest.TestCase): """凯京车主APP 回单上传""" def setUp(self): """前置条件准备""" self.logger = Log() self.logger.info( '########################### TestWaybillReceiptUpload START ###########################' ) config = ReadYaml(FileUtil.getProjectObsPath() + '/config/config.yaml').getValue() # 读取配置文件 app_package = config['appPackage_chezhu'] # APP 包名 app_activity = config['appActivity_chezhu'] # APP 启动activity # AppUiDriver(appPackage=app_package, appActivity=app_activity).app_ui_driver() self.mobile = config['mobile_register'] # 认证司机手机号 self.driver = AppUiDriver(app_package, app_activity).get_driver() # 获取appium driver CreateWayBill(self.mobile).arrive_confirm() # 创建运单并确认发车及到达确认 self.driver_tools = DriverOperation(self.driver) self.driver.start_activity( app_activity=app_activity, app_package=app_package) # 重启APP 保证case从主页面开始执行 pass def tearDown(self): """测试环境重置""" DbOperation().delete_waybill_driver(self.mobile) # 删除case中操作的运单 self.logger.info( '########################### TestWaybillReceiptUpload END ###########################' ) pass def test_bvt_waybill_receipt_upload(self): """回单上传操作""" upload_receipt = WaybillReceiptUploadCheZhu(self.driver) MainTabCheZhu(self.driver).close_driver_loan_ads() self.driver_tools.getScreenShot('waybill_receipt_upload') WaybillMainCheZhu(self.driver).go_to_waybill_detail() # 跳转运单回单上传操作页面 self.driver_tools.getScreenShot('waybill_receipt_upload') upload_receipt.add_receipt_image() # 添加回单照片 upload_receipt.add_receipt_info('自动化回单异常') # 添加回单异常信息 upload_receipt.upload_receipt() # 上传回单相关信息 wait_page = MainTabCheZhu(self.driver).wait_main_page() self.driver_tools.getScreenShot('waybill_receipt_upload') self.assertTrue(wait_page) # 检查操作完成后页面activity是否切换为主列表页 waybill_state = DbOperation().select_waybill_state( self.mobile)[0] # 判断运单状态是否变为 H回单已上传 self.assertEqual(waybill_state, 'H')
def loan_amt_get(self): '''可借款金额统计''' try: response = HttpClient().get(self.__loanAmtGetApiUrl,self.__head_dict) return response except Exception as e: Log().error('可借款金额统计接口调用异常:{0}'.format(e)) return None
def setUp(self): self.logger = Log() self.logger.info( '######################## TestDepartureConfirmWayBill START ########################' ) carType = str(random.randint(1, 2)) applyDate = time.strftime('%Y-%m-%d') photoAirWay = FileUtil.getProjectObsPath() + '/image/photoAirWay.jpg' self.wayBillId = CreateWayBill().create_waybill( carType, applyDate, photoAirWay, '北京', '北京', '', '天津', '天津', '', '1000', '10', '0.01', '0.02', '0.03', '0.04', '1', '备注我要录单测试', 'TMS', '零担', '10', '100', '1000', '10000', '100000', '20', '30', '40', '50', 'DD001', 'YK001', 'LSVAM4187C2184847', '6222810001000', '中国银行', '张三')[0] wayBillNo = WayBillDetailGet().waybill_detail_get(self.wayBillId).json( )['content']['transportCashDetail']['tmsBillCode'] self.logger.info('定位信息批量导出的运单号是:{0}'.format(wayBillNo))
class TestDriverRelevanceSelect(unittest.TestCase): '''用于录单时获取外请车列表''' def setUp(self): self.logger = Log() self.logger.info( '########################### TestDriverRelevanceSelect START ###########################' ) self.mobile = DataUtil().createmoble() self.idNo = DataUtil().genneratorIdNo() self.carNo = DataUtil().genneratorCarNo() self.carLength = DataUtil().genneratorCarLength() self.carModel = DataUtil().genneratorCarTypeInfo() self.photoIdFront = FileUtil.getProjectObsPath( ) + os.path.sep + 'image' + os.path.sep + 'frontIdCard.jpg' self.photoIdReserve = FileUtil.getProjectObsPath( ) + os.path.sep + 'image' + os.path.sep + 'backIdCard.jpg' self.photoDriverCard = FileUtil.getProjectObsPath( ) + os.path.sep + 'image' + os.path.sep + 'photoDriverCard.jpg' self.photoTransPort = FileUtil.getProjectObsPath( ) + os.path.sep + 'image' + os.path.sep + 'photoTransPort.jpg' self.loginId = CreateDriver().create_driver( '孙师傅', self.mobile, self.idNo, self.photoIdFront, self.photoIdReserve, self.photoDriverCard, self.photoTransPort, self.carNo, self.carLength, self.carModel, '10')[0] def tearDown(self): self.logger.info( '############################ TestDriverRelevanceSelect END ############################' ) pass def test_driver_select_success(self): '''用于录单时获取外请车列表''' response = DriverSelect().driver_select() self.logger.info('用于录单时获取外请车列表返回状态码:{0}'.format(response)) self.assertEqual(response.status_code, 200) self.assertEqual(response.json()['code'], 0) self.logger.info('用于录单时获取外请车列表查询结果是:{0}'.format(response.json())) driver_list = response.json()['content'] if driver_list != []: L = [] for driver in driver_list: L.append(str(driver['loginId'])) self.assertIn(self.loginId, L, 'Driver selected fail!') else: self.logger.error('Driver selected fail!')
def wrapper(self, *args, **kwargs): try: u = origin_func(self, *args, **kwargs) return u except Exception as e: Log().error(e) self.driver.quit() raise
def setUp(self): """前置条件准备""" config = ReadYaml(FileUtil.getProjectObsPath() + '/config/config.yaml').getValue() app_package = config['appPackage_chezhu'] app_activity = config['appActivity_chezhu'] # AppUiDriver(appPackage=app_package, appActivity=app_activity).app_ui_driver() self.logger = Log() self.driver = AppUiDriver(appPackage=app_package, appActivity=app_activity).get_driver() self.driver_operation = DriverOperation(self.driver) self.driver.start_activity(app_activity=app_activity, app_package=app_package) self.logger.info( '########################### TestLogout START ###########################' ) pass
class TestCarCertification(unittest.TestCase): """凯京车主APP 车辆认证""" def setUp(self): """前置条件准备""" self.logger = Log() self.logger.info( '########################### TestCarCertification START ###########################' ) config = ReadYaml(FileUtil.getProjectObsPath() + '/config/config.yaml').getValue() app_package = config['appPackage_chezhu'] app_activity = config['appActivity_chezhu'] # AppUiDriver(appPackage=app_package, appActivity=app_activity).app_ui_driver() self.mobile = config['mobile_unregister'] self.db = DbOperation() self.driver = AppUiDriver(appPackage=app_package, appActivity=app_activity).get_driver() self.db.update_driver_info() self.driver.start_activity(app_activity=app_activity, app_package=app_package) pass def tearDown(self): """测试环境重置""" self.db.initialize_driver_info(self.mobile) self.logger.info( '########################### TestCarCertification END ###########################' ) pass def test_bvt_car_certification(self): """车辆认证""" car_certificate = CarCertificateCheZhu(self.driver) choosePhoto = ChoosePhotoCheZhu(self.driver) MainTabCheZhu(self.driver).goto_person_center() # 进入个人中心 PersonCenterCheZhu(self.driver).goto_certification_page() # 进入认证页面 car_certificate.upload_car_img_first() # 选择行驶证正面照片 choosePhoto.choose_driving_license_front() car_certificate.upload_car_img_second() # 选择行驶证反面照片 choosePhoto.choose_id_card_back() car_certificate.input_car_number() car_certificate.choose_car_info() car_certificate.submit_car_info() WalletOpenCheZhu(self.driver).wait_page() driver_info = self.db.select_driver_info(self.mobile) self.assertEqual('Y', driver_info['isCarCertificate'])
class TestCostSettingsGet(unittest.TestCase): ''' 获取收入成本参数配置详情''' def setUp(self): self.logger = Log() self.logger.info( '########################### TestSystemParamsGet START ###########################' ) self.carType = random.sample([1, 2], 1)[0] self.sendProvince = '浙江' self.sendCity = '杭州' self.sendDistrict = '' self.arriveProvince = '安徽' self.arriveCity = '合肥' self.arriveDistrict = '' self.stationAProvince = '上海' self.stationACity = '上海' self.stationADistrict = '' self.stationBProvince = '' self.stationBCity = '' self.stationBDistrict = '' self.carLength = DataUtil().genneratorCarLength() self.carModel = DataUtil().genneratorCarTypeInfo() self.calculateType = random.sample([1, 2, 3, 4], 1)[0] self.perIncome = random.uniform(0, 99999) self.oilCost = random.uniform(0, 99999) self.roadCost = random.uniform(0, 99999) self.repairCost = random.uniform(0, 99999) self.depreciationCost = random.uniform(0, 99999) self.insurance = random.uniform(0, 99999) self.personCost = random.uniform(0, 99999) self.taxRate = random.uniform(0, 100) self.otherCost = random.uniform(0, 99999) self.infoCost = random.uniform(0, 99999) self.Id, self.kilometers, self.projectId = CostSettings( ).create_cost_settings( '', self.carType, self.sendProvince, self.sendCity, self.arriveDistrict, self.arriveProvince, self.arriveCity, self.arriveDistrict, self.stationAProvince, self.stationACity, self.stationADistrict, self.stationBProvince, self.stationBCity, self.stationBDistrict, self.carLength, self.carModel, self.calculateType, self.perIncome, self.oilCost, self.roadCost, self.repairCost, self.depreciationCost, self.insurance, self.personCost, self.taxRate, self.otherCost, self.infoCost) def tearDown(self): self.logger.info( '############################ TestSystemParamsGet END ############################' ) def test_cost_settings_get_success(self): '''获取收入成本参数配置详情''' response = CostSettingsGet().cost_settings_get(self.Id) self.logger.info('获取收入成本参数配置详情返回状态码:{0}'.format(response)) self.logger.info('获取收入成本参数配置详情返回结果是:{0}'.format(response.json())) self.assertEqual(response.status_code, 200) self.assertEqual(response.json()['code'], 0)
def approval_total_amt_get(self): try: response = HttpClient().get(self.__approvalTotalAmtGetApiUrl, self.__head_dict) return response except Exception as e: Log().error('到达支付列表接口调用异常:{0}'.format(e)) return None
class TestWalletCash(unittest.TestCase): """凯京车主APP 提现""" def setUp(self): """前置条件准备""" self.logger = Log() self.logger.info( '########################### TestWalletCash START ###########################' ) config = ReadYaml(FileUtil.getProjectObsPath() + '/config/config.yaml').getValue() app_package = config['appPackage_chezhu'] app_activity = config['appActivity_chezhu'] # AppUiDriver(appPackage=app_package, appActivity=app_activity).app_ui_driver() self.mobile = config['mobile_register'] self.wallet_pwd = config['wallet_pwd_register'] self.driver = AppUiDriver(app_package, app_activity).get_driver() self.driver_tools = DriverOperation(self.driver) PayForDriver(self.mobile).pay_for_driver() self.driver.start_activity(app_activity=app_activity, app_package=app_package) pass def tearDown(self): """测试环境重置""" self.logger.info( '########################### TestWalletCash END ###########################' ) pass @unittest.skip('skip cash case') def test_bvt_wallet_cash(self): """钱包提现""" wallet = WalletMainCheZhu(self.driver) wallet_cash = WalletCashCheZhu(self.driver) MainTabCheZhu(self.driver).goto_person_center() PersonCenterCheZhu(self.driver).goto_user_wallet() self.driver_tools.getScreenShot('wallet_cash') wallet.go_to_cash() wallet_cash.wallet_cash() WalletPasswordCheZhu(self.driver).send_password(self.wallet_pwd) wallet_cash.cash_confirm() self.driver_tools.getScreenShot('wallet_cash') wait_page = MainTabCheZhu(self.driver).wait_main_page() self.assertTrue(wait_page) # 检查操作完成后页面activity是否切换为主列表页 wallet_balance = int(wallet.get_wallet_balance()) self.assertEqual(wallet_balance, 0)
def approval_credit_total_amt_get(self): try: response = HttpClient().get(self.__approvalCreditTotalAmtGetApiUrl, self.__head_dict) return response except Exception as e: Log().error('获取今日授信中系统的金额接口调用异常:{0}'.format(e)) return None
class TestChangeWaybill(unittest.TestCase): # 物流云APP 运单修改运单 def setUp(self): """前置条件准备""" self.logger = Log() self.logger.info( '########################### TestChangeWaybill START ###########################' ) config = ReadYaml(FileUtil.getProjectObsPath() + '/config/config.yaml').getValue() app_package = config['appPackage_wuliuyun'] app_activity = config['appActivity_wuliuyun'] # AppUiDriver(appPackage=app_package, appActivity=app_activity).app_ui_driver() self.driver_mobile = config['employ_driver_mobile'] self.driver = AppUiDriver(appPackage=app_package, appActivity=app_activity).get_driver() self.driver_tool = DriverOperation(self.driver) CreateWayBill(self.driver_mobile).saveWayBill() self.driver.start_activity(app_activity=app_activity, app_package=app_package) pass def tearDown(self): """测试环境重置""" DbOperation().delete_waybill_driver(mobile=self.driver_mobile) self.logger.info( '########################### TestChangeWaybill END ###########################' ) pass def test_change_waybill(self): # 运单 修改运单 change_waybill = WaybillChangeWuLiuYun(self.driver) WuLiuYunWaybillTab(self.driver).go_to_waybill_detail() self.driver_tool.getScreenShot('test_confirm_waybill') WuLiuYunWaybillDetail(self.driver).go_to_change_page(type=0) change_waybill.change_waybill(totalAmt='66', preAmt='1', oilAmt='2', destAmt='3', lastAmt='4') change_waybill.commit_change() self.driver_tool.getScreenShot('test_confirm_waybill') page = WuLiuYunWaybillDetail(self.driver).wait_detail_page() self.assertTrue(page)