示例#1
0
class Tesat002():
    @pytest.mark.parametrize("email,icon,nickName,note,password,username,ass",
                             read_excel_list("E:\\ceshi.xls"))
    def test_register(self, email, icon, nickName, note, password, username,
                      ass):
        data = {
            "email": email,
            "icon": icon,
            "nickName": nickName,
            "note": note,
            "password": password,
            "username": username
        }
        r = requests.post(url=HOST + "/admin/register", json=data)
        print(r.text)
        assert ass in r.text
示例#2
0
# 登录功能
from Common import Request, Assert, read_excel
import allure
import pytest

request = Request.Request()
assertion = Assert.Assertions()
idsList=[]
excel_list = read_excel.read_excel_list('./document/test.xlsx')
length = len(excel_list)
for i in range(length):
    idsList.append(excel_list[i].pop())




url = 'http://192.168.1.137:8080/'
head = {}

@allure.feature("登录功能")
class Test_login:

    @allure.story("登录")
    def test_login(self):
        # =后面 :  request对象 调用了  post_request  方法,传入了两个参数
        # = 前面:  将方法 返回的 对象/变量  起一个名字
        login_resp = request.post_request(url=url+'admin/login',
                                            json={"username": "******", "password": "******"})

        # 响应 . text  :  就是获取 text属性的内容,这个就是 响应正文 (str 格式)
        resp_text = login_resp.text
示例#3
0
import allure
import pytest
from Common import Request, Assert, read_excel, Tools

request = Request.Request()
assertions = Assert.Assertions()

url = 'http://192.168.60.132:1811/'
excel_list = read_excel.read_excel_list('./document/注册.xlsx')
ids_list = []
for i in range(len(excel_list)):
    # 删除excel_list中每个小list的最后一个元素,并赋值给ids_pop
    ids_pop = excel_list[i].pop()
    # 将ids_pop添加到 ids_list 里面
    ids_list.append(ids_pop)


@allure.feature('虚拟商城用户模块')
class Test_user():
    @allure.story("注册接口_成功")
    def test_signup1(self):
        signup_resp = request.post_request(url=url + 'user/signup',
                                           json={
                                               "phone":
                                               Tools.phone_num(),
                                               "pwd":
                                               'aaa123456',
                                               "rePwd":
                                               'aaa123456',
                                               "userName":
                                               Tools.random_str_abc(3) +
示例#4
0
import allure
import pytest
from Common import Request, Assert, read_excel

request = Request.Request()

assertions = Assert.Assertions()

head = {}
fl_id = 0
excel_list = read_excel.read_excel_list('./document/商品分类.xlsx')
ids_list = []
for i in range(len(excel_list)):
    # 删除excel_list中每个小list的最后一个元素,并赋值给ids_pop
    ids_pop = excel_list[i].pop()
    # 将ids_pop添加到 ids_list 里面
    ids_list.append(ids_pop)


@allure.feature("商品分类模块")
class Test_info:
    @allure.story("登录接口")
    def test_login(self):
        login_resp = request.post_request(
            url='http://192.168.60.132:8080/admin/login',
            json={
                "username": "******",
                "password": "******"
            })
        assertions.assert_code(login_resp.status_code, 200)
        login_resp_json = login_resp.json()
示例#5
0
import allure
from Common import Assert, Request, read_excel
import pytest

F = 0
excel_list = read_excel.read_excel_list('./document/商品分类参数化.xlsx')
a = []
for i in range(len(excel_list)):
    list_i__pop = excel_list[i].pop()
    a.append(list_i__pop)

coupon_list = read_excel.read_excel_list('./document/优惠券.xlsx')
B = []
for i in range(len(coupon_list)):
    data_Coupon = coupon_list[i].pop()
    B.append(data_Coupon)

request = Request.Request()

assertions = Assert.Assertions()
head = {}
ids = 0


@allure.feature('获取用户信息')
class Test_info:
    @allure.story('登录接口')
    def test_login(self):
        login_resp = request.post_request(
            url='http://192.168.60.132:8080/admin/login',
            json={
示例#6
0
import allure
import pytest
from Common import Assert
from Common import Request
from Common import read_excel

assertions = Assert.Assertions()
request = Request.Request()

excel_list = read_excel.read_excel_list("./document/test.xlsx")

idsList = []
len1 = len(excel_list)
for i in range(len1):
    a = excel_list[i].pop()
    idsList.append(a)


@allure.feature("演示模块")
class Testdemo(object):
    @allure.story("演示功能")
    @pytest.mark.parametrize('name,pwd,msg', excel_list, ids=idsList)
    def test_case_demo(self, name, pwd, msg):
        login_data = {"username": name, "password": pwd}
        login_resp = request.post_request(
            url="http://qa.guoyasoft.com:8099/admin/login", json=login_data)
        # .assert_code 用来断言 状态码 ; 第一个参数 填 响应的状态码, 第二个参数 期望值
        assertions.assert_code(login_resp.status_code, 200)
        # 获取响应正文  字典格式
        login_resp_json = login_resp.json()
        # .assert_in_text 用来断言字符 第一个参数填 比较多的那个字符; 第二参数填 这个字符 是否存在第一个字符里面
from Common import Tools1, read_excel, Assert, Request
import pytest
request = Request.Request()
assertion = Assert.Assertions()
phone = Tools1.phone_num()
pwd = Tools1.random_str_abc(2) + Tools1.random_123(4)
pwd1 = Tools1.random_str_abc(2) + Tools1.random_123(5)
userName = Tools1.random_str_abc(3) + Tools1.random_123(2)
import allure
head = {}
url = 'http://192.168.60.132:1811'

lists = []
excel_list = read_excel.read_excel_list('./table/zhuce.xlsx')
for i in range(len(excel_list)):
    lists.append(excel_list[i].pop())


@allure.feature('用户')
class Test_order():
    @allure.story('注册2')
    @pytest.mark.parametrize('phones,pwdd,rePwdd,userNamee,cod',
                             excel_list,
                             ids=lists)
    def test_singup2(self, phones, pwdd, rePwdd, userNamee, cod):
        post_resp = request.post_request(url=url + '/user/signup',
                                         json={
                                             "phone": phones,
                                             "pwd": pwdd,
                                             "rePwd": pwdd,
                                             "userName": userNamee
示例#8
0
import allure
import pytest
from Common import read_excel
from Common import Request, Assert

assertions = Assert.Assertions()

request = Request.Request()
url = 'http://192.168.60.132:8080'
excel_list = read_excel.read_excel_list("../day06/documents/test.xlsx")
idsList = []
for i in range(len(excel_list)):
    idsList.append(excel_list[i].pop())

myToken = ''
head = {'Authorization': myToken}
f_order_id = 0
s_order_id = 0
id = []


@allure.feature("登录模块")
class TestLogin(object):
    @allure.story("登录系统")
    @pytest.mark.parametrize('name,pwd,msg', excel_list, ids=idsList)
    def test_case_login(self, pwd, name, msg):
        login_data = {"username": name, "password": pwd}
        login_resp = request.post_request(url=url + "/admin/login",
                                          json=login_data)
        # .assert_code 用来断言 状态码 ; 第一个参数 填 响应的状态码, 第二个参数 期望值
        assertions.assert_code(login_resp.status_code, 200)
示例#9
0
from Common import Request, Assert, read_excel
import allure
import pytest

request = Request.Request()
assertion = Assert.Assertions()
head = {}
idsList = []
tuihuo_id = 0

excel_list = read_excel.read_excel_list('./document/退货原因.xlsx')
length = len(excel_list)
for i in range(length):
    idsList.append(excel_list[i].pop())

url = 'http://192.168.1.137:8080/'


@allure.feature('退货原因模块')
class Test_tuihuo:
    @allure.story('登录')
    def test_login(self):
        login_resp = request.post_request(url=url + 'admin/login',
                                          json={
                                              "username": "******",
                                              "password": "******"
                                          })
        resp_text = login_resp.text
        print(type(resp_text))
        resp_dict = login_resp.json()
        print(type(resp_dict))
示例#10
0
from Common import Request, Assert, read_excel, Tools
import pytest, allure

request = Request.Request()
assertions = Assert.Assertions()
excel_list = read_excel.read_excel_list('../../document/注册用例.xlsx')
ids_list = []
for i in range(len(excel_list)):
    ids_list.append(excel_list[i].pop())
tool_pwd = Tools.random_str_abc(3) + Tools.random_123(3)
tool_username = Tools.random_str_abc(3) + Tools.random_123(1)
tool_phone = Tools.phone_num()


@allure.feature('注册模块')
class Test_new:
    @allure.story('注册新用户_成功')
    @pytest.mark.zhuce
    def test_zhuce(self):
        zhuce_resp = request.post_request(
            url='http://192.168.60.132:1811/user/signup',
            json={
                "phone": tool_phone,
                "pwd": tool_pwd,
                "rePwd": tool_pwd,
                "userName": tool_username
            })
        assertions.assert_code(zhuce_resp.status_code, 200)
        resp_json = zhuce_resp.json()
        assertions.assert_in_text(resp_json['respDesc'], '成功')
示例#11
0
import allure
import pytest

from Common import Assert,Request,Login,read_excel
url = Login.url
head = Login.Login().get_token()
assertions = Assert.Assertions()
request = Request.Request()
A = 0
b = []
goods = read_excel.read_excel_list('./document/退货.xlsx')
for i in range(len(goods)):
    list_i__pop = goods[i].pop()
    b.append(list_i__pop)

@allure.feature('退货窗口')
class Test_return:
    @allure.story('查询退货')
    def test_sel_goods(self):
        sel_resp = request.get_request(url=url + 'returnReason/list', params={'pageNum': 1, 'pageSize': 5},headers=head)
        assertions.assert_code(sel_resp.status_code,200)
        sel_resp_json = sel_resp.json()
        assertions.assert_in_text(sel_resp_json['message'],'成功')
        data_ = sel_resp_json['data']
        list_ = data_['list']
        one = list_[0]
        global A
        A = one['id']
    @allure.story('删除退货')
    def test_del_goods(self):
        del_resp = request.post_request(url=url + 'returnReason/delete', params={'ids': A}, headers=head)
示例#12
0
from Common import Request, login, Assert, read_excel
request = Request.Request()
assertion = Assert.Assertions()
head = {}
idd = 0
lists = []
import pytest
import allure

excel_list = read_excel.read_excel_list('./table/youhuijuan.xlsx')
for i in range(len(excel_list)):
    lists.append(excel_list[i].pop())


@allure.feature('优惠卷')
class Test_sku():
    # @pytest.mark.zhixin
    @allure.story('获取优惠卷列表')
    def test_huoqu(self):
        global head
        head = login.Test_login().test_login()
        resp = request.get_request(
            url='http://192.168.60.132:8080/coupon/list',
            params={
                'pageNum': 1,
                'pageSize': 10
            },
            headers=head)
        resp_dict = resp.json()
        assertion.assert_code(resp.status_code, 200)
        assertion.assert_in_text(resp_dict['message'], '成功')
示例#13
0
import allure, pytest
from Common import Assert, Request, read_excel, Tools

assertions = Assert.Assertions()
request = Request.Request()
A = []
excel_list = read_excel.read_excel_list('./document/用户注册测试用例.xlsx')
for i in range(len(excel_list)):
    i__pop = excel_list[i].pop()
    A.append(i__pop)


@allure.feature('注册模块测试')
class Test_zc:
    # @pytest.mark.parametrize('phone,pwd,rePwd,userName,resp',excel_list,ids=A)
    @allure.story('注册模块')
    def test_NUMB(self):
        zc_resp = request.post_request(
            url='http://192.168.60.132:1811/user/signup',
            json={
                "phone": Tools.phone_num(),
                "pwd": 'ab12345',
                "rePwd": 'ab12345',
                "userName": Tools.random_str_abc(3) + Tools.random_123(3)
            })
        assertions.assert_code(zc_resp.status_code, 200)
        zc_resp_json = zc_resp.json()

        assertions.assert_in_text(zc_resp_json["respCode"], '0')

    @allure.story('注册失败')
示例#14
0
from Common import Request, login, Assert, read_excel, Shell
import allure
import pytest

idds = []
shell = Shell.Shell()

assertion = Assert.Assertions()
lg = login.Test_login()
request = Request.Request()
head = {}
lists = []
excel_list = read_excel.read_excel_list('./table/tianjia.xlsx')
for i in range(len(excel_list)):
    lists.append(excel_list[i].pop())


@allure.feature('商品管理')
class Test_shangping():
    @allure.story('获取商品分类')
    def test_huoqu(self):
        global head
        head = lg.test_login()
        resp = request.get_request(
            url='http://192.168.60.132:8080/productCategory/list/0',
            params={
                'pageNum': 1,
                'pageSize': 5
            },
            headers=head)
        json_dict = resp.json()
示例#15
0
import allure
import pytest

from Common import Shell, read_excel, Assert, Request

request = Request.Request()
assertion = Assert.Assertions()
shell = Shell.Shell

idds = []
excel_list = read_excel.read_excel_list('./table/demlu.xlsx')
for i in range(len(excel_list)):
    idds.append(excel_list[i].pop())
head = {}


@allure.feature('测试')
class Test_Login():
    @allure.story('测试登录')
    def test_login(self):
        resp = request.post_request(
            url='http://192.168.60.132:8080/admin/login',
            json={
                "password": "******",
                "username": "******"
            })

        resp_dict = resp.json()
        assertion.assert_code(resp.status_code, 200)
        assertion.assert_in_text(resp_dict['message'], '成功')
示例#16
0
from Common import Request, login, Assert, read_excel
import pytest
import allure

request = Request.Request()
assertion = Assert.Assertions()
head = {}
idd = 0
list = []
excel_list = read_excel.read_excel_list('./table/tuihuo.xlsx')
for i in range(len(excel_list)):
    list.append(excel_list[i].pop())


@allure.feature('退货')
class Test_tuihuo():
    @allure.story('获取退货')
    def test_huoqu(self):
        global head
        head = login.Test_login().test_login()
        response = request.get_request(
            url='http://192.168.60.132:8080/returnReason/list',
            params={
                'pageNum': 1,
                'pageSize': 5
            },
            headers=head)
        json_dict = response.json()
        assertion.assert_code(response.status_code, 200)
        assertion.assert_in_text(json_dict['message'], '成功')