Commit 1f99b730 authored by Cornelius Edward's avatar Cornelius Edward

tijiao

parent b55d8aad
File added
import path_setting
from in_common.base_request import BaseRequest
import pytest
class send_reqest(BaseRequest):
def __init__(self):
self.data = self.api_load(path_setting.LOGIN_CONFIG)
print(self.data)
def login_passwd(self,current_city_id,phone,password,face_token=""):
self.params["current_city_id"] = current_city_id
self.params["phone"] = phone
self.params["password"] = password
self.params["face_token"] = face_token
return self.api_send(self.data["password"])
if __name__ == '__main__':
print(send_reqest().login_passwd("beijing", "17796839512", 123456, ""))
password:
method: post
url: /api/accounts/login/password
params:
current_city_id: ${current_city_id}
data:
phone: ${phone}
password: ${password}
face_token: ${face_token}
json: {}
......@@ -70,11 +70,12 @@ class BaseRequest:
# 接口请求的封装
def api_send(self, req: dict):
host = self.api_load(path_setting.HOSTYAML_CONFIG)
raw = yaml.dump(req) # 将一个python对象生成为yaml文档
for key, value in self.params.items():
raw = raw.replace(f"${{{key}}}", repr(value))
req = yaml.safe_load(raw)
print('req:',req)
# print('------', req.get('headers'))
# hd = req.get('headers')
# if hd == None:
......
......@@ -6,6 +6,7 @@ sys.path.append(BASE_DIR)
HOSTYAML_CONFIG = os.path.join(BASE_DIR, "backend_auto", "host.yaml")
APYAML_CONFIG = os.path.join(BASE_DIR, "backend_auto/all_backend_api", "account_request.yaml")
LOGIN_VFC = os.path.join(BASE_DIR, "backend_auto/test_backend_data/account_data", "login_vfc.yaml")
LOGIN_PASSWD = os.path.join(BASE_DIR, "backend_auto/test_backend_data/accounts_data", "login_passwd.yaml")
LOGIN_CONFIG = os.path.join(BASE_DIR, "backend_auto/all_backend_api", "accounts_request.yaml")
if __name__ == '__main__':
print("==========",HOSTYAML_CONFIG)
#!/usr/bin/env python
# -*- coding:utf-8 -*-
import pytest
from ids_list import get_ids
import path_setting
from in_common.base_request import BaseRequest
from all_backend_api.accounts_request import send_reqest
class TestLoginPasswd:
data = BaseRequest().api_load(path_setting.LOGIN_PASSWD)
loginpasswd_case, loginpasswd_data = get_ids(data, "password")
@pytest.mark.parametrize("param",loginpasswd_data,ids=loginpasswd_case)
def test_login_passwd(self,param):
print(param["password"])
r = send_reqest().login_passwd(param["current_city_id"], param["phone"], param["password"])
if r["error"] == 1:
assert r["message"] == param["assert"]
password:
#成功登录case
-
case: "成功登录case--密码正常登录case"
current_city_id: "beijing"
phone: "17796839512"
password: 123456
assert: "17796839512"
#登录失败case
-
case: "登录失败case--手机号错误"
current_city_id: "beijing"
phone: "17796839510"
password: 123456
assert: "手机号或密码不正确"
-
case: "登录失败case--密码错误"
current_city_id: "beijing"
phone: "17796839512"
password: 1234567
assert: "手机号或密码不正确"
-
case: "登录失败case--手机号格式非数字"
current_city_id: "beijing"
phone: "177968395qq"
password: 123456
assert: "该手机号未注册过更美,请先注册!"
-
case: "登录失败case--手机号为空"
current_city_id: "beijing"
phone: ""
password: 123456
assert: "该手机号未注册过更美,请先注册!"
-
case: "登录失败case--密码为空"
current_city_id: "beijing"
phone: "17796839512"
password:
assert: "手机号或密码不正确"
-
case: "登录失败case--都为空"
current_city_id: "beijing"
phone:
password:
assert: "该手机号未注册过更美,请先注册!"
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment