# coding = utf-8 import unittest import jsonpath import requests from Conf.Oracle import Oracle from MainExecute.readConfig import ReadConfig from Lib.headers import heads url = ReadConfig().get_http('baseurl') + '/ms-goods/cart/list' class CartList(unittest.TestCase): def test_cart_list(self): res = requests.get(url, params=None, headers=heads) product_sum = jsonpath.jsonpath(res.json(), '$...productId')[0] oraDb = Oracle() sql = '''Select t.product_id From bas_cust_cart t Where t.con_id =:con_id''' con_id = 'e08296fa2ed84476890c8eb7d4d2b78f' lists = oraDb.queryBy(sql, {'con_id': con_id})[0][0] self.assertEqual(product_sum, lists, msg='数据错误') if __name__ == '__main__': t = CartList() t.test_cart_list()
# coding=utf-8 import unittest import jsonpath import requests from MainExecute.readConfig import ReadConfig from Lib.headers import heads url = ReadConfig().get_http('baseurl') + '/ms-goods/product/index/all/list' # print(url) # 首页商品列表 class GetList(unittest.TestCase): def test_index_list(self): res = requests.get(url, params=None, headers=heads) msg1 = jsonpath.jsonpath(res.json(), '$.msg')[0] msg2 = jsonpath.jsonpath(res.json(), '$...productId') # print(msg2) self.assertEqual(msg1, '成功') return msg2 # oraDb = Oracle() # sql = """Select t.product_id From pnt_product t, pnt_brand d # Where t.product_type In ('0','1') And t.pro_status In ('0','4') And t.shop_type Like '%app%' And t.brand_id = d.id # Order By d.c_index Desc ,t.display_sequence Desc""" # lists = oraDb.queryBy(sql) # msg3 = []
# coding = utf-8 import unittest import jsonpath import requests from Conf.Oracle import Oracle from MainExecute.readConfig import ReadConfig from Lib.headers import heads from MainInterface.index_all_list import GetList product_id = GetList().test_index_list()[0] url = ReadConfig().get_http( 'baseurl') + '/ms-goods/reviews/countproductreview/' + product_id class CountProductReview(unittest.TestCase): def test_count_product_review(self): res = requests.get(url, params=None, headers=heads) msg1 = jsonpath.jsonpath(res.json(), '$.msg')[0] self.assertEqual(msg1, '成功') oraDb = Oracle() sql = '''Select Count(1) From pnt_product_reviews t Where t.product_id =: product_id''' lists = oraDb.queryBy(sql, {'product_id': 'product_id'})[0][0] msg2 = jsonpath.jsonpath(res.json(), '$..count')[0] self.assertEqual(msg2, lists) if __name__ == '__main__': t = CountProductReview() t.test_count_product_review()
# coding = urt-8 import unittest import jsonpath import requests from MainExecute.readConfig import ReadConfig from Lib.headers import heads url = ReadConfig().get_http( 'baseurl') + '/ms-sys/operation-navigation/operation/list' print(url) class GetOperatiponList(unittest.TestCase): def test_get_operation_list(self): res = requests.get(url, params=None, headers=heads) msg1 = jsonpath.jsonpath(res.json(), '$.msg')[0] print(msg1) self.assertEqual(msg1, '成功') if __name__ == '__main__': t = GetOperatiponList() t.test_get_operation_list()
# coding = utf-8 import json import time import unittest import jsonpath import requests from MainExecute.readConfig import ReadConfig from MainInterface.address_isdefault import AddressIsdefault from MainInterface.confirm_query_quick import ConfirmQuery from Lib.headers import heads from MainInterface.index_all_list import GetList url = ReadConfig().get_http('baseurl') + '/ms-order/order-put/order/put/price' class PutPrice(unittest.TestCase): def test_put_price(self): # 获取商品首购价 firstPrice = ConfirmQuery().test_confirm_query_quick()[0] # 获取商品复购价 rePrice = ConfirmQuery().test_confirm_query_quick()[1] # 获取商品价格 productPrice = ConfirmQuery().test_confirm_query_quick()[2] # 获取商品id product_id = GetList().test_index_list()[0] # 获取地址信息 memberAddressId = AddressIsdefault().test_address_isdefault()[0] # 获取时间戳 tag = time.time()
# coding = utf-8 import unittest import jsonpath import requests from MainExecute.readConfig import ReadConfig from Lib.headers import heads url = ReadConfig().get_http( 'baseurl') + '/ms-promotion/assist-free/myself/index' class AssistMyselfList(unittest.TestCase): def test_assist_myself_list(self): res = requests.get(url, params=None, headers=heads) msg1 = jsonpath.jsonpath(res.json(), '$.msg')[0] self.assertEqual(msg1, '成功') if __name__ == '__main__': t = AssistMyselfList() t.test_assist_myself_list()
# coding = utf-8 import unittest import jsonpath import requests from MainExecute.readConfig import ReadConfig from Lib.headers import heads url = ReadConfig().get_http('baseurl') + '/ms-order/order/cherk/add' class OrderCheckAdd(unittest.TestCase): def test_order_check_add(self): res = requests.get(url, params=None, headers=heads) msg = jsonpath.jsonpath(res.json(), '$.msg')[0] self.assertEqual(msg, '成功') if __name__ == '__main__': t = OrderCheckAdd() t.test_order_check_add()
# coding = utf-8 import unittest import jsonpath import requests from Conf.Oracle import Oracle from MainExecute.readConfig import ReadConfig from Lib.headers import heads from MainInterface.index_all_list import GetList url = ReadConfig().get_http('baseurl') + '/ms-goods/product/index/confirm/query/quick' class ConfirmQuery(unittest.TestCase): def test_confirm_query_quick(self): product_id = GetList().test_index_list()[0] data1 = {"productId": product_id} res = requests.post(url, json=data1, headers=heads) firstPrice = jsonpath.jsonpath(res.json(), '$...firstPrice')[0] rePrice = jsonpath.jsonpath(res.json(), '$...rePrice')[0] productPrice = jsonpath.jsonpath(res.json(), '$...productPrice')[0] return firstPrice, rePrice, productPrice oraDb = Oracle() sql = '''Select (1-t.befor_agent/100)*t.buy_price,(1-t.after_agent/100)*t.buy_price From pnt_product t Where t.product_id =:product_id''' lists = oraDb.queryBy(sql, {'product_id': product_id}) self.assertEqual(firstPrice, lists[0][0]) self.assertEqual(rePrice, lists[0][1])
import unittest import jsonpath import requests from MainExecute.readConfig import ReadConfig from Lib.headers import heads url = ReadConfig().get_http('baseurl') + '/ms-member/customer/info/get' class GetInfo(unittest.TestCase): def test_get_info(self): res = requests.get(url, params=None, headers=heads) # print(res.json()) msg1 = jsonpath.jsonpath(res.json(), '$.msg')[0] # print('我是msg1:'+msg1) self.assertEqual(msg1, '成功') con_id = jsonpath.jsonpath(res.json(), '$..conId')[0] return con_id if __name__ == '__main__': t = GetInfo() t.test_get_info()
# coding = utf-8 import json import unittest import jsonpath import requests from MainExecute.readConfig import ReadConfig url = ReadConfig().get_http('baseurl_admin2') + '/auth/login' def auth_login(): data1 = { "username": "******", "password": "******", "channel": "4" } res = requests.post(url, json=data1) # print(res.json()) token = jsonpath.jsonpath(res.json(), '$..Authorization')[0] return token
# coding = utf-8 import unittest import jsonpath import requests from MainExecute.readConfig import ReadConfig from Lib.headers import heads url = ReadConfig().get_http('baseurl') + '/ms-promotion/coupon/homepage/list' class CouponHomepageList(unittest.TestCase): def test_coupon_homepage_list(self): res = requests.get(url, params=None, headers=heads) msg1 = jsonpath.jsonpath(res.json(), '$.msg')[0] self.assertEqual(msg1, '成功') if __name__ == '__main__': t = CouponHomepageList t.test_coupon_homepage_list()
# coding = utf-8 import unittest import jsonpath import requests from Lib.headers import heads from MainExecute.readConfig import ReadConfig from MainInterface.get_info import GetInfo from MainInterface.index_all_list import GetList from MainInterface.order_put import OrderPut orderId = OrderPut().test_order_put()[0] url = ReadConfig().get_http('baseurl') + '/ms-order/order/info/' + orderId print(url) class OrderInfo(unittest.TestCase): def test_order_info(self): res = requests.get(url, params=None, headers=heads) print(res.json()) orderId_res = jsonpath.jsonpath(res.json(), '$..orderId')[0] conId_res = jsonpath.jsonpath(res.json(), '$..conId')[0] orderTotal_res = float( '%.2f' % (jsonpath.jsonpath(res.json(), '$..orderTotal')[0])) productId_res = jsonpath.jsonpath(res.json(), '$...productId')[0] # print(productId_res) conId = GetInfo().test_get_info() # print(conId) orderTotal = OrderPut().test_order_put()[2]
# coding = utf-8 import unittest import jsonpath import requests from MainExecute.readConfig import ReadConfig from Lib.headers import heads url = ReadConfig().get_http( 'baseurl') + '/ms-promotion/coupon-detail/active/payed/coupon' class ActivePayedCoupon(unittest.TestCase): def test_active_payed_coupon(self): res = requests.post(url, json=None, headers=heads) # print(res.json()) msg1 = jsonpath.jsonpath(res.json(), '$.msg')[0] self.assertEqual(msg1, '成功') if __name__ == '__main__': t = ActivePayedCoupon() t.test_active_payed_coupon()
# coding = utf-8 import unittest import jsonpath import requests from MainExecute.readConfig import ReadConfig from Lib.headers import heads url = ReadConfig().get_http('baseurl') + '/ms-promotion/promotion/advertisement/list?adPosition=1' class AdvertisementList(unittest.TestCase): def test_advertisement_list(self): res = requests.get(url, params=None, headers=heads) msg1 = jsonpath.jsonpath(res.json(), '$.msg')[0] self.assertEqual(msg1, '成功') if __name__ == '__main__': t = AdvertisementList() t.test_advertisement_list()
# coding = utf-8 import unittest import jsonpath import requests from MainExecute.readConfig import ReadConfig from Lib.headers import heads from MainInterface.index_all_list import GetList product_id = GetList().test_index_list()[0] # print(product_id) url = ReadConfig().get_http( 'baseurl') + '/ms-goods/product/index/detail/new/' + product_id class IndexDetailNew(unittest.TestCase): def test_index_detail_new(self): res = requests.get(url, params=None, headers=heads) msg1 = jsonpath.jsonpath(res.json(), '$.msg')[0] self.assertEqual(msg1, '成功') if __name__ == '__main__': t = IndexDetailNew() t.test_index_detail_new()
# coding = utf-8 import unittest import jsonpath import requests from MainExecute.readConfig import ReadConfig from Lib.headers import heads url = ReadConfig().get_http('baseurl') + '/ms-promotion/coupon/listbystatus' class CouponListByStatus(unittest.TestCase): def test_coupon_list_by_status(self): res = requests.get(url, params=None, headers=heads) msg1 = jsonpath.jsonpath(res.json(), '$.msg')[0] self.assertEqual(msg1, '成功') if __name__ == '__main__': t = CouponListByStatus() t.test_coupon_list_by_status()
# coding = utf-8 import unittest import jsonpath import requests from Conf.mySql import Mysql from MainExecute.readConfig import ReadConfig from MainInterface.get_info import GetInfo from Lib.headers import heads url = ReadConfig().get_http( 'baseurl') + '/ms-order/member-address/address/isdefault' class AddressIsdefault(unittest.TestCase): def test_address_isdefault(self): res = requests.get(url, params=None, headers=heads) # print(res.json()) address_id = int(jsonpath.jsonpath(res.json(), '$..id')[0]) provinceId = int(jsonpath.jsonpath(res.json(), '$..provinceId')[0]) # print(provinceId) # print(res.json()) # print(address_id) oraDb = Mysql() con_id = GetInfo().test_get_info() sql = '''select * from member_address t where is_default = '1'AND t.con_id =(%s)''' lists = oraDb.queryBy(sql, con_id) # print(lists) address_id_mysql = lists[0][0] # print(lists)
# coding = utf-8 import json import unittest import jsonpath import requests from MainExecute.readConfig import ReadConfig from MainInterface.address_isdefault import AddressIsdefault from MainInterface.confirm_query_quick import ConfirmQuery from MainInterface.get_freight import GetFreight from Lib.headers import heads from MainInterface.index_all_list import GetList url = ReadConfig().get_http('baseurl') + '/ms-order/order-put/order/put/freight' class OrderPutFreight(unittest.TestCase): def test_order_put_freight(self): # 获取地址信息 memberAddressId = AddressIsdefault().test_address_isdefault()[0] # 获取商品id product_id = GetList().test_index_list()[0] # 获取商品首购价 firstPrice = ConfirmQuery().test_confirm_query_quick()[0] # 获取商品复购价 rePrice = ConfirmQuery().test_confirm_query_quick()[1] # 获取商品价格 productPrice = ConfirmQuery().test_confirm_query_quick()[2] # 入参格式化 data = json.dumps({"isUsePoints": "1", "memberAddressId": memberAddressId, "putProductItemsList": [
import requests import jsonpath as jsonpath from MainExecute.readConfig import ReadConfig from DataSource.readExcel import readExcel xls_info = readExcel().get_xls('personinfo.xls', 'Sheet1') openid = xls_info[1][0] # print(openid) unionid = xls_info[1][1] # print(unionid) url = ReadConfig().get_http('baseurl') + '/ms-auth/auth/app/login/wechat' # print(url) data = {"openidApp": openid, "unionid": unionid} headerP = {"version": "3.2.0", "mobileBrand": "IOS", "anonymousId": "6E7B9681-F967-4728-8303-DA04C16A253B"} heads = { "channel": "5", 'headerParams': json.dumps(headerP), "Authorization": "d2a57dc1d883fd21fb9951699df71cc7" } class LoginWechat(unittest.TestCase): # @staticmethod def test_login_wechat(self): res = requests.post(url, json=data, headers=heads)
import unittest import jsonpath import requests from MainExecute.readConfig import ReadConfig from Lib.headers import heads url = ReadConfig().get_http('baseurl') + '/ms-sys/api-config-cache/list' # 协议版本缓存 class ConfigList(unittest.TestCase): def test_get_config_list(self): res = requests.get(url, params=None, headers=heads) # print(res.json()) msg1 = jsonpath.jsonpath(res.json(), '$.msg')[0] print(msg1) self.assertEqual(msg1, '成功') # oraDb = Oracle() # sql = """select * from tld_orders where con_no =: con_no """ # msg2 = oraDb.queryBy(sql, {'con_no': '260053441'}) # self.assertEqual(msg1, msg2) if __name__ == '__main__': t = ConfigList() t.test_get_config_list()
# coding = utf-8 import json import unittest import jsonpath import requests from MainExecute.readConfig import ReadConfig from Lib.headers import heads from MainInterface.order_put import OrderPut url = ReadConfig().get_http('baseurl') + '/ms-order/pay/topay' class PayToPay(unittest.TestCase): def test_pay_to_pay(self): orderId = OrderPut().test_order_put()[0] data = {"orderId": orderId, "tradeType": "APP"} res = requests.post(url, data=json.dumps(data), headers=heads) # print(res.json()) msg1 = jsonpath.jsonpath(res.json(), '$.msg')[0] self.assertEqual(msg1, '成功') if __name__ == '__main__': t = PayToPay() t.test_pay_to_pay()