def test_scene3(self): user = { "phoneArea": "86", "phoneNumber": "200000000033", "password": "******" } delete_id = {"id": "82317363"} newaddress = { "id": "", "receiverName": "杨", "cellPhone": "15226541128", "province": "河北省", "city": "石家庄市", "area": "裕华区", "addressDetail": "新校区" } login_result = SendHttp().run_http(self.login_url, 'POST', user) self.assertEqual(login_result['message'], "success") skulist_result = SendHttp().sent_get(self.skulist_url) self.assertEqual(skulist_result['message'], "success") delete_result = SendHttp().sent_post_bycookies(self.delete_url, Common.getcookies(user), delete_id) self.assertEqual(delete_result['code'], 400) newaddress_result = SendHttp().sent_post_bycookies( self.addAddress_url, Common.getcookies(user), newaddress) self.assertEqual(newaddress_result['code'], 200)
def test_scene2(self): # 登录成功 user = { "phoneArea": "86", "phoneNumber": "200000000044", "password": "******" } result = SendHttp().run_http(self.LoginUrl, "POST", user) self.assertEqual(result['code'], 200) self.assertEqual(result['message'], 'success') # 新建订单 para = { "receiverName": "张三", "cellPhone": "12345678901", 'addressDetail': "浙江大学", "province": "浙江省", "city": "杭州市", "area": "滨江区" } SendHttp().sent_post_bycookies(self.NewAddressUrl, Common.getcookies(user), para) self.assertEqual(result['code'], 200) self.assertEqual(result['message'], 'success') # 删除订单 address_result = SendHttp().sent_get_bycookies(self.AddressListUrl, Common.getcookies(user)) aid = address_result['result']['list'][0]['id'] para = {"id": aid} SendHttp().sent_post_bycookies(self.DeleteAddress, Common.getcookies(user), para) self.assertEqual(address_result['code'], 200) self.assertEqual(address_result['message'], 'success')
def test_scene3(self): # 登录 user = {"phoneArea": "86", "phoneNumber": "200000000011", "password": "******"} result = SendHttp().run_http(self.LoginUrl, "POST", user) self.assertEqual(result['code'], 200) self.assertEqual(result['message'], 'success') # 获取所有商品的sku列表 sku_result = SendHttp().run_http(self.Skulisturl, "GET") # 查询获取地址 address_result = SendHttp().sent_get_bycookies(self.AddressListUrl, Common.getcookies(user)) pro = address_result['result']['list'][0]['province'] city = address_result['result']['list'][0]['city'] area = address_result['result']['list'][0]['area'] # 计算运费 addressDetails = address_result['result']['list'][0]['addressDetail'] para = {"id": 1, "addressDetail": addressDetails} SendHttp().run_http(self.TransportFeeUrl, "GET", para) # 提交订单 submit_data = {"skuIds": "1", "skuNumbers": "1,1", "stockIds": "74966312,74966313", "receiverName": "张三", "cellPhone": "200000000011", "addressDetail": addressDetails, "province": pro, "city": city, "area": area, "voiceStatus": 0, "needInvoice": 0, "invoiceHead": "", "transportFee": 0, "logisticsCompanyId": 1, "accessSource": "noSource", "accessDevice": 0} SendHttp().sent_get_bycookies(self.AddressListUrl, Common.getcookies(user), submit_data)
def test_scene1(self): # 登录 user = {"phoneArea": "86", "phoneNumber": "200000000044", "password": "******"} result = SendHttp().run_http(self.LoginUrl, "POST", user) self.assertEqual(result['code'], 200) self.assertEqual(result['message'], 'success') # 查询获取地址 address_result = SendHttp().sent_get_bycookies(self.AddressListUrl, Common.getcookies(user)) # 删除收获地址 aid = address_result['result']['list'][0]['id'] print(id) para = {"id": aid} delete_result = SendHttp().sent_post_bycookies(self.Deleteurl, Common.getcookies(user), para)
def test_skuList(self): user = { "phoneArea": "86", "phoneNumber": "200000000044", "password": "******" } submit_data = { "skuIds": "2,3", "skuNumbers": "1,1", "stockIds": "74966312,74966313", "receiverName": "张三", "cellPhone": "12615813537", "addressDetail": "1 栋 3 单元", "province": "1", "city": "1", "area": "1", "voiceStatus": 0, "needInvoice": 0, "invoiceHead": "", "transportFee": 0, "logisticsCompanyId": 1, "accessSource": "noSource", "accessDevice": 0 } resultSubmit = SendHttp().sent_post_bycookies(self.SubmitUrl, Common.getcookies(user), submit_data)
def test_listFail_by_WrongPwd(self): user = { "phoneArea": "86", "phoneNumber": "20000000000", "password": "******" } SendHttp().sent_get_bycookies(self.url, Common.getcookies(user))
def test_scene02(self): cookie = Common.getcookies(self.user) list_result = SendHttp().sent_get_bycookies(self.listurl, cookie) id_num = int(list_result['result']['total']) id_list = list(range(id_num)) for index in range(len(id_list)): id_list[index] = list_result['result']['list'][index]['id'] self.assertEqual(list_result['code'], 200) para = {"id": id_list[id_num - 1]} del_result = SendHttp().send_post_bycookies(self.delurl, para, cookie) self.assertEqual(del_result['code'], 200) add_para = { "id": "", "receiverName": "测试用户", "cellPhone": "12345678900", "province": "浙江省", "city": "杭州市", "area": "滨江市", "addressDetail": "浙江大学" } add_result = SendHttp().send_post_bycookies(self.addurl, add_para, cookie) self.assertEqual(add_result['code'], 200)
def test_address_by_Login(self): user = { "phoneArea": "86", "phoneNumber": "20000000000", "password": "******" } SendHttp().sent_get_bycookies(self.url, Common.getcookies(user))
def test_scene3(self): # 登录成功 user = { "phoneArea": "86", "phoneNumber": "200000000044", "password": "******" } result = SendHttp().run_http(self.LoginUrl, "POST", user) self.assertEqual(result['code'], 200) self.assertEqual(result['message'], 'success') # 新建订单 para = { "receiverName": "张三", "cellPhone": "12345678901", 'addressDetail': "浙江大学", "province": "浙江省", "city": "杭州市", "area": "滨江区" } SendHttp().sent_post_bycookies(self.NewAddressUrl, Common.getcookies(user), para) self.assertEqual(result['code'], 200) self.assertEqual(result['message'], 'success') # 提交订单 submit_data = { "skuIds": "2,3", "skuNumbers": "1,1", "stockIds": "74966312,74966313", "receiverName": "张三", "cellPhone": "12615813537", "addressDetail": "1 栋 3 单元", "province": "1", "city": "1", "area": "1", "voiceStatus": 0, "needInvoice": 0, "invoiceHead": "", "transportFee": 0, "logisticsCompanyId": 1, "accessSource": "noSource", "accessDevice": 0 } resultSubmit = SendHttp().sent_post_bycookies(self.SubmitUrl, Common.getcookies(user), submit_data) self.assertEqual(resultSubmit['code'], 200) self.assertEqual(resultSubmit['message'], 'success')
def getIdList(self): cookie = Common.getcookies(self.user) list_result = SendHttp().sent_get_bycookies(self.listurl, cookie) id_num = int(list_result['result']['total']) id_list = list(range(id_num)) for index in range(len(id_list)): id_list[index] = list_result['result']['list'][index]['id'] return id_list
def test_Scene1(self): user = { "phoneArea": "86", "phoneNumber": "200000000033", "password": "******" } newaddress = { "id": "", "receiverName": "小飞龙", "cellPhone": "15226541128", "province": "河北省", "city": "石家庄市", "area": "裕华区", "addressDetail": "新校区" } submit = { "skuIds": "3", "skuNumbers": "1", "stockIds": "74966313", "receiverName": "小飞龙", "cellPhone": "15226541128", "addressDetail": "新校区", "province": "河北省", "city": "石家庄市", "area": "裕华区", "voiceStatus": 0, "needInvoice": 0, "invoiceHead": "", "transportFee": 6, "logisticsCompanyId": 1, "accessSource": "noSource", "accessDevice": 0 } login_result = SendHttp().run_http(self.login_url, "POST", user) self.assertEqual(login_result['code'], 200) self.assertEqual(login_result['message'], "success") skulist_result = SendHttp().sent_get(self.skulist_url) self.assertEqual(skulist_result['message'], "success") newaddress_result = SendHttp().sent_post_bycookies( self.addAddress_url, Common.getcookies(user), newaddress) self.assertEqual(newaddress_result['code'], 200) submit_result = SendHttp().sent_post_bycookies(self.submit_url, Common.getcookies(user), submit) self.assertEqual(submit_result['message'], "success")
def test_second(self): user = { "phoneArea": "86", "phoneNumber": "200000000055", "password": "******" } address = { "addressDetail": "浙江省_杭州市_滨江区", "id": "\"1\"", "tm": "1545038153217" } detial = { "skuIds": "3", "skuNumbers": "1", "stockIds": "74966313", "receiverName": "小飞龙", "cellPhone": "12345678909", "addressDetail": "河北师范", "province": "四川省", "city": "成都市", "area": "锦江区", "voiceStatus": 0, "needInvoice": 0, "invoiceHead": "", "transportFee": 6, "logisticsCompanyId": 1, "accessSource": "noSource", "accessDevice": 0 } login_result = SendHttp().run_http(self.loginurl, "POST", user) self.assertEqual(login_result['code'], 200) self.assertEqual(login_result['message'], "success") fee_result = SendHttp().sent_get(self.feeurl, address) self.assertEqual(fee_result['code'], 400) self.assertEqual(fee_result['message'], "请求失败") list_result = SendHttp().sent_get_bycookies(self.listurl, Common.getcookies(user)) self.assertEqual(list_result['code'], 200) self.assertEqual(list_result['message'], "success") submit_result = SendHttp().sent_post_bycookies(self.submiturl, Common.getcookies(user), detial) self.assertEqual(submit_result['code'], 200) self.assertEqual(submit_result['message'], "success")
def build_Data(self,path): ''' 使用工厂方法(现已修改) 根据报文类型(水文、气象)以及根目录: 1、获取所有匹配的文件全目录集合 2、 :param data_type: :return: ''' # stations_list= self.getmatchingFiles(os.path.join(path,self.station.stationname),self.date) # 先获取文件目录 # 注意此处获取的文件全路径时传入的时间的当月的全部文件 files,ignorefiles=self.getmatchingFiles(os.path.join(path,self.station.stationname),self.date) # 创建空的dataframe # 注意此处与HydrologyData.getDataResult中均用到Common.DateHelper(self.date)!!!!!需要再修改 date_helper = Common.DateHelper(self.date) temp_date = date_helper.date_factory(enum_model.DataType.Hydrology) df_all= self.__creatNaDataframe(temp_date.list_date_allmonth) # temp_perclock_data=None ''' 下面重新修改 1 遍历文件集合 2 对当前的文件根据其类型实例化对应的内部类 3 调用getDataResult方法 ''' for temp_file in files: # 遍历文件名集合,并对其分类 # 使用工厂方式创建的水文和气象数据对象均要实现getDataResult方法 temp_data_hy=None temp_data_me = None # 此处不再使用判断传入的类型,改为遍历的水文、气象两种类型的数据 # for temp_enum in enum_model.DataType: print("正在录入%s"%temp_file.fullname) temp_data_hy = self.HydrologyData(temp_file.fullname, self.station, temp_file.targetdate, temp_file.element) result_hy = temp_data_hy.getDataResult() if result_hy is None: continue df_all = df_all.combine_first(result_hy) temp_data_me = self.MeteorologyData(temp_file.fullname, self.station, temp_file.targetdate, temp_file.element) result_me = temp_data_me.getDataResult() if result_me is None: continue df_all = df_all.combine_first(result_me) print("录入成功") # if data_type is enum_model.DataType.Hydrology: # # 此处有问题,遍历的file对象应该是对每个file对象获取其对应的时间,而不能使用self.date # temp_data= self.HydrologyData(temp_file.fullname,self.station,temp_file.targetdate,temp_file.element) # elif data_type is enum_model.DataType.Meteorology: # temp_data= self.MeteorologyData(temp_file.fullname,self.station,temp_file.targetdate,temp_file.element) # result=temp_data.getDataResult() # df_all=df_all.combine_first(result) # temp_perclock_data.getDataResult() return df_all
def setUp(self): self.logurl = "/common/fgadmin/login" self.listurl = "/fgadmin/address/list?tm=1545495924820" self.delurl = "/fgadmin/address/delete" self.addurl = "/fgadmin/address/new" self.suburl = "/fgadmin/orders/submit" self.feeurl = "/common/getTransportFee?id=1&addressDetail=%E6%B5%99%E6%B1%9F%E7%9C%81_%E6%9D%AD%E5%B7%9E%E5%B8%82_%E6%BB%A8%E6%B1%9F%E5%B8%82&tm=1545553794046" self.skuurl = "/common/skuList" self.user = { "phoneArea": "86", "phoneNumber": "200000000077", "password": "******" } self.cookie = Common.getcookies(self.user)
def test_scene04(self): log_result = SendHttp().send_post(self.logurl, self.user) self.assertEqual(log_result['code'], 200) cookie = Common.getcookies(self.user) list_result = SendHttp().sent_get_bycookies(self.listurl, cookie) id_num = int(list_result['result']['total']) id_list = list(range(id_num)) for index in range(len(id_list)): id_list[index] = list_result['result']['list'][index]['id'] self.assertEqual(list_result['code'], 200) para = {"id": id_list[id_num - 1]} del_result = SendHttp().send_post_bycookies(self.delurl, para, cookie) self.assertEqual(del_result['code'], 200) add_para = { "id": "", "receiverName": "测试用户", "cellPhone": "12345678900", "province": "浙江省", "city": "杭州市", "area": "滨江市", "addressDetail": "浙江大学" } add_result = SendHttp().send_post_bycookies(self.addurl, add_para, cookie) self.assertEqual(add_result['code'], 200) submit_data = { "skuIds": "2,3", "skuNumbers": "1,1", "stockIds": "74966312,74966313", "receiverName": "测试用户", "cellPhone": "12345678900", "addressDetail": "浙江大学", "province": "浙江省", "city": "杭州市", "area": "滨江市", "voiceStatus": 0, "needInvoice": 0, "invoiceHead": "", "transportFee": 0, "logisticsCompanyId": 1, "accessSource": "noSource", "accessDevice": 0 } sub_result = SendHttp().send_post_bycookies(self.suburl, submit_data, self.cookie) self.assertEqual(sub_result['code'], 200)
def test_scene2(self): # 登录 user = {"phoneArea": "86", "phoneNumber": "200000000011", "password": "******"} result = SendHttp().run_http(self.LoginUrl, "POST", user) self.assertEqual(result['code'], 200) self.assertEqual(result['message'], 'success') # 查询获取地址 address_result = SendHttp().sent_get_bycookies(self.AddressListUrl, Common.getcookies(user)) pro = address_result['result']['list'][0]['province'] city = address_result['result']['list'][0]['city'] area = address_result['result']['list'][0]['area'] # 添加收获地址 address = {"id": "", "receiverName": "李四", "cellPhone": "200000000011", "province": "江苏省", "city": "南京市", "area": "鼓楼区", "addressDetail": "南京大学"} add_result = SendHttp().sent_post_bycookies(self.Addurl, Common.getcookies(user), address) # 删除收获地址 id = address_result['result']['list'][0]['id'] delete_result = SendHttp().sent_post_bycookies(self.Deleteurl, Common.getcookies(user), id)
def test_scene2(self): # 登录 user = {"phoneArea": "86", "phoneNumber": "200000000066", "password": "******"} login_result = SendHttp().run_http(self.LoginUrl, "POST", user) self.assertEqual(login_result['code'], 200) self.assertEqual(login_result['message'], 'success') # 查询收货地址 cookie = Common.getcookies(user) address_result = SendHttp().sent_get_bycookies(self.AddressListUrl, cookie) self.assertEqual(address_result['code'], 200) self.assertEqual(address_result['message'], 'success') # 计算运费 address_list1 = address_result['result']['list'][0] province = address_list1['province'] city = address_list1['city'] area = address_list1['area'] address_id = address_list1["id"] addresstoDetial = province + "_" + city + "_" + area para = {"id": address_id, "addressDetail": addresstoDetial} fee_result = SendHttp().run_http(self.TransportFeeUrl, "GET", para) fee = fee_result['result'] print("运费为:", fee) self.assertEqual(fee_result['code'], 200) self.assertEqual(fee_result['message'], 'success') # 提交订单 receiverName = address_list1['receiverName'] cellPhone = address_list1['cellPhone'] addressDetail = address_list1['addressDetail'] submit_para = { "skuIds": "2,3", "skuNumbers": "1,1", "stockIds": "74966312,74966313", "receiverName": receiverName, "cellPhone": cellPhone, "addressDetail": addressDetail, "province": province, "city": city, "area": area, "voiceStatus": 0, "needInvoice": 0, "invoiceHead": "", "transportFee": fee, "logisticsCompanyId": 1, "accessSource": "noSource", "accessDevice": 0 } submit_result = SendHttp().sent_post_bycookies(self.SubmitUrl, cookie, submit_para) self.assertEqual(submit_result['code'], 200) self.assertEqual(submit_result['message'], 'success')
def test_scene4(self): # 登录失败 user = { "phoneArea": "86", "phoneNumber": "200000000044", "password": "******" } result = SendHttp().run_http(self.LoginUrl, "POST", user) self.assertEqual(result['code'], 400) self.assertEqual(result['message'], '用户名或者密码错误') # 查询收货地址list失败 address_result = SendHttp().sent_get_bycookies(self.AddressListUrl, Common.getcookies(user)) self.assertEqual(address_result['code'], 403) self.assertEqual(address_result['message'], '请重新登录')
def test_scene4(self): # 登录失败 user = {"phoneArea": "86", "phoneNumber": "200000000011", "password": "******"} result = SendHttp().run_http(self.LoginUrl, "POST", user) self.assertEqual(result['code'], 400) self.assertEqual(result['message'], '用户名或者密码错误') # 查询获取地址 address_result = SendHttp().sent_get_bycookies(self.AddressListUrl, Common.getcookies(user)) # 计算运费 try: addressDetails = address_result['result']['list'][0]['addressDetail'] para = {"id": 1, "addressDetail": addressDetails} SendHttp().run_http(self.TransportFeeUrl, "GET", para) except KeyError: print("获取运费失败")
def test_scene4(self): user = { "phoneArea": "86", "phoneNumber": "200000000033", "password": "******" } skulist = {"goodsId": 1} delete_id = {"id": "82317363"} login_result = SendHttp().run_http(self.login_url, 'POST', user) self.assertEqual(login_result['message'], "success") skulist_result = SendHttp().run_http(self.skulist_url, 'GET', skulist) self.assertEqual(skulist_result['message'], "success") delete_result = SendHttp().sent_post_bycookies(self.delete_url, Common.getcookies(user), delete_id) self.assertEqual(delete_result['code'], 400)
def getDataResult(self): """ 获取数据: 具体步骤如下: 1 生成时间list 2 读取指定文件 3 对读取后的dataframe进行转换 4 将最终结果返回 存在的设计问题: 由于是外侧类的工厂方法调用,而外侧的类中getmatchingFiles方法是生成该月的所有匹配文件集合 :return: """ date_helper = Common.DateHelper(self.targetdate) temp_date = date_helper.date_factory(enum_model.DataType.Meteorology) isOK = self.getTargetDayData() # 若读取时出错时直接跳出 if isOK == False: return if self.element.lower() != 'ws': # self.__read_table() # 删除数据的date列 del self.result['date'] # 转置 self.result = self.result.T # 切片获取0-23点的数据,去掉min与max self.result = self.result[:-2] # 对df的index赋值 self.result.index = temp_date.list_date # 对df的columns赋值 # columns就是at hu 等等 self.result.columns = [self.element] # 注意风向风速的要特殊处理!!! elif self.element.lower() == 'ws': # 获取第一行(相当于是列头)ß columns = self.result.columns # 获取剔除第一个日期之外的其他值 self.result = pd.DataFrame(columns)[1:] # 修改形状 self.result = pd.DataFrame(self.result.values.reshape((24, 2))) self.result.index = temp_date.list_date self.result.columns = ['WD', 'WS'] return self.result
def test_addressnew1(self): user = { "phoneArea": "86", "phoneNumber": "200000000066", "password": "******" } para = { "id": "", "receiverName": "张三", "cellPhone": "12345678901", "addressDetail": "浙江大学", "province": "浙江省", "city": "杭州市", "area": "滨江区" } result = SendHttp().sent_post_bycookies(self.url, Common.getcookies(user), para) self.assertEqual(result['code'], 200) self.assertEqual(result['message'], 'success')
def test_addressnew21(self): user = { "phoneArea": "86", "phoneNumber": "200000000066", "password": "******" } para = { "id": "", "receiverName": "张三", "cellPhone": "12345678901", "addressDetail": "浙江大学", "province": "浙江省", "city": "杭州市", "area": "滨江区" } result = SendHttp().sent_post_bycookies(self.url, Common.getcookies(user), para) # self.assertEqual(result['code'], 400) # self.assertEqual(result['message'], '请求参数不正确') # 用例失败,code:200 message:success if self.assertEqual(result['code'], 200): print('添加重复的地址成功,用例失败')
def test_scene2(self): user = { "phoneArea": "86", "phoneNumber": "200000000033", "password": "******" } fee = { "addressDetail": "浙江省_杭州市_滨江区", "id": "1", "tm": "1545038153217" } submit = { "skuIds": "3", "skuNumbers": "1", "stockIds": "74966313", "receiverName": "小飞龙", "cellPhone": "15226541128", "addressDetail": "新校区", "province": "河北省", "city": "石家庄市", "area": "裕华区", "voiceStatus": 0, "needInvoice": 0, "invoiceHead": "", "transportFee": 6, "logisticsCompanyId": 1, "accessSource": "noSource", "accessDevice": 0 } skulist_result = SendHttp().sent_get(self.skulist_url) self.assertEqual(skulist_result['message'], "success") fee_result = SendHttp().sent_get(self.fee_url, fee) self.assertEqual(fee_result['code'], 200) submit_result = SendHttp().sent_post_bycookies(self.submit_url, Common.getcookies(user), submit) self.assertEqual(submit_result['message'], "success")
def test_scene5(self): # 登录成功 user = { "phoneArea": "86", "phoneNumber": "200000000044", "password": "******" } result = SendHttp().run_http(self.LoginUrl, "POST", user) self.assertEqual(result['code'], 200) self.assertEqual(result['message'], 'success') # 查询地址 address_result = SendHttp().sent_get_bycookies(self.AddressListUrl, Common.getcookies(user)) pro = address_result['result']['list'][0]['province'] city = address_result['result']['list'][0]['city'] area = address_result['result']['list'][0]['area'] self.assertEqual(address_result['code'], 200) self.assertEqual(address_result['message'], 'success') # 计算运费 para = {"id": 1, "addressDetail": pro + "_" + city + "_" + area} resultFee = SendHttp().run_http(self.TransportFeeUrl, "GET", para) self.assertEqual(resultFee['code'], 200) self.assertEqual(resultFee['message'], 'success') # 新建订单 para = { "receiverName": "张三", "cellPhone": "12345678901", 'addressDetail': "浙江大学", "province": "浙江省", "city": "杭州市", "area": "滨江区" } SendHttp().sent_post_bycookies(self.NewAddressUrl, Common.getcookies(user), para) self.assertEqual(result['code'], 200) self.assertEqual(result['message'], 'success') # 提交订单 submit_data = { "skuIds": "2,3", "skuNumbers": "1,1", "stockIds": "74966312,74966313", "receiverName": "张三", "cellPhone": "12615813537", "addressDetail": "1 栋 3 单元", "province": pro, "city": city, "area": area, "voiceStatus": 0, "needInvoice": 0, "invoiceHead": "", "transportFee": 0, "logisticsCompanyId": 1, "accessSource": "noSource", "accessDevice": 0 } resultSubmit = SendHttp().sent_post_bycookies(self.SubmitUrl, Common.getcookies(user), submit_data) self.assertEqual(resultSubmit['code'], 200) self.assertEqual(resultSubmit['message'], 'success') # 删除订单 address_result = SendHttp().sent_get_bycookies(self.AddressListUrl, Common.getcookies(user)) aid = address_result['result']['list'][0]['id'] para = {"id": aid} SendHttp().sent_post_bycookies(self.DeleteAddress, Common.getcookies(user), para) self.assertEqual(address_result['code'], 200) self.assertEqual(address_result['message'], 'success')
def test_fail_del03(self): cookie = Common.getcookies(self.user) para = {"id": ""} del_result = SendHttp().send_post_bycookies(self.delurl, para, cookie) self.assertEqual(del_result['code'], 400)
def test_success_del(self): ID_LIST = self.getIdList() cookie = Common.getcookies(self.user) para = {"id": ID_LIST[0]} del_result = SendHttp().send_post_bycookies(self.delurl, para, cookie) self.assertEqual(del_result['code'], 200)
def test_scene1(self): # 登录 user = { "phoneArea": "86", "phoneNumber": "200000000044", "password": "******" } resultLogin = SendHttp().run_http(self.LoginUrl, "POST", user) self.assertEqual(resultLogin['code'], 200) self.assertEqual(resultLogin['message'], 'success') # 获取skuList,goodsId=1 goodsId = 1 resultSkuList = SendHttp().run_http( self.SkuListUrl + "?" + str(goodsId), "GET") self.assertEqual(resultSkuList['code'], 200) self.assertEqual(resultSkuList['message'], 'success') # 实现获取list address_result = SendHttp().sent_get_bycookies(self.AddressListUrl, Common.getcookies(user)) pro = address_result['result']['list'][0]['province'] city = address_result['result']['list'][0]['city'] area = address_result['result']['list'][0]['area'] self.assertEqual(address_result['code'], 200) self.assertEqual(address_result['message'], 'success') # 获取运费 para = {"id": 1, "addressDetail": "河北省_石家庄市_裕华区"} resultFee = SendHttp().run_http(self.TransportFeeUrl, "GET", para) self.assertEqual(resultFee['code'], 200) self.assertEqual(resultFee['message'], 'success') # 新建地址 para = { "receiverName": "张三", "cellPhone": "12345678901", 'addressDetail': "浙江大学", "province": "浙江省", "city": "杭州市", "area": "滨江区" } resultNewAddress = SendHttp().sent_post_bycookies( self.NewAddressUrl, Common.getcookies(user), para) self.assertEqual(resultNewAddress['code'], 200) self.assertEqual(resultNewAddress['message'], 'success') # 提交订单 submit_data = { "skuIds": "2,3", "skuNumbers": "1,1", "stockIds": "74966312,74966313", "receiverName": "张三", "cellPhone": "12615813537", "addressDetail": "1 栋 3 单元", "province": pro, "city": city, "area": area, "voiceStatus": 0, "needInvoice": 0, "invoiceHead": "", "transportFee": 0, "logisticsCompanyId": 1, "accessSource": "noSource", "accessDevice": 0 } resultSubmit = SendHttp().sent_post_bycookies(self.SubmitUrl, Common.getcookies(user), submit_data) self.assertEqual(resultSubmit['code'], 200) self.assertEqual(resultSubmit['message'], 'success')
def tearDown(self): SendHttp().sent_get_bycookies(self.url, Common.getcookies(self.user), self.lists)