commit
This commit is contained in:
parent
789bc15a06
commit
04a492919b
|
@ -61,4 +61,14 @@ conn.commit()
|
|||
pymysql操作数据库, 默认是开启了事务
|
||||
所以在执行增删改的相关操作之后一定要提交事务才会生效
|
||||
连接对象.commit()
|
||||
|
||||
|
||||
2052976,2053131,2053207,2053209,2053220,2053130,2038001,2038000,2037999,2037620,2037619,2053284,2053301,2048577,2053317,2053323,2052877,2052857,2052846,2052844,2053045,2053357,2048575,2048576
|
||||
|
||||
|
||||
7,6,9,14,9,7,20,2,6,4,32,7,3,13,7,7,19,26,7,6,2,3,10,8
|
||||
|
||||
|
||||
810500,809502,810623,914941,914947,914936
|
||||
|
||||
"""
|
|
@ -0,0 +1,9 @@
|
|||
课程内容:
|
||||
实战接口:编写充值功能的测试用例
|
||||
关于unittest中用例环境管理的配置方法(用例执行的前置条件/后置条件):利用setupClass解决了充值之前登录的问题
|
||||
充值前后数据库校验,涉及到decimal数据类型
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
# 日志文件相关配置
|
||||
[LOG]
|
||||
# 自定义日志收集器名称
|
||||
LOG_LOGGER = floralog
|
||||
# 日志收集等级
|
||||
LOG_LEVEL = DEBUG
|
||||
# 输出到文件的日志等级
|
||||
LOG_FILE_LEVEL = DEBUG
|
||||
# 输出到控制台的日志等级
|
||||
LOG_SH_LEVEL = ERROR
|
||||
# 日志文件的名称
|
||||
LOG_FILENAME = all.log
|
||||
# 日志格式
|
||||
LOG_FORMATS = %%(asctime)s ---%%(name)s--- [%%(filename)s-->line:%%(lineno)d] - %%(levelname)s: %%(message)s
|
||||
|
||||
[ENV]
|
||||
BASE_URL = http://api.lemonban.com/futureloan
|
||||
BASE_HEADERS = {'X-lemonban-Media-Type': 'lemonban.v2'}
|
||||
PHONE = 131
|
||||
|
||||
|
||||
[MYSQL]
|
||||
HOST=120.78.128.25
|
||||
PORT=3306
|
||||
USER=future
|
||||
PASSWORD=123456
|
||||
CHARSET=utf8
|
||||
|
||||
[TEST]
|
||||
PHONE=15500005678
|
||||
PWD=00005678
|
||||
LOGIN_URL=/member/login
|
||||
lOGIN_METHOD=post
|
|
@ -0,0 +1,22 @@
|
|||
"""
|
||||
=================================
|
||||
Author: Flora Chen
|
||||
Time: 2020/3/17 21:15
|
||||
-_- -_- -_- -_- -_- -_- -_- -_-
|
||||
=================================
|
||||
"""
|
||||
import os
|
||||
from configparser import ConfigParser
|
||||
from python27Class.unitTest.class03282020.conf.handle_dir import CONF_DIR
|
||||
|
||||
class HandleConfig(ConfigParser):
|
||||
"""
|
||||
配置文件解析器类的封装
|
||||
"""
|
||||
def __init__(self, filename):
|
||||
super().__init__()
|
||||
self.read(filename, encoding='utf-8')
|
||||
|
||||
conf = HandleConfig(os.path.join(CONF_DIR, 'config.ini'))
|
||||
|
||||
|
|
@ -0,0 +1,43 @@
|
|||
"""
|
||||
=================================
|
||||
Author: Flora Chen
|
||||
Time: 2020/3/21 19:49
|
||||
-_- -_- -_- -_- -_- -_- -_- -_-
|
||||
=================================
|
||||
"""
|
||||
import os
|
||||
|
||||
"""
|
||||
|
||||
相关路径处理
|
||||
|
||||
"""
|
||||
|
||||
# 项目目录路径
|
||||
|
||||
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||
|
||||
# 配置文件路径
|
||||
|
||||
CONF_DIR = os.path.join(BASE_DIR, "conf")
|
||||
|
||||
# 用例数据路径
|
||||
|
||||
DATA_DIR = os.path.join(BASE_DIR, "testdata")
|
||||
|
||||
# 日志文件路径
|
||||
|
||||
LOG_DIR = os.path.join(BASE_DIR, "logs")
|
||||
|
||||
# 测试报告文件路径
|
||||
|
||||
REPORT_DIR = os.path.join(BASE_DIR, "reports")
|
||||
|
||||
# 测试用例文件路径
|
||||
|
||||
CASES_DIR = os.path.join(BASE_DIR, "testcases")
|
||||
|
||||
# 第三方库文件路径
|
||||
|
||||
LIB_DIR = os.path.join(BASE_DIR, "library")
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
"""
|
||||
=================================
|
||||
Author: Flora Chen
|
||||
Time: 2020/3/28 11:19
|
||||
-_- -_- -_- -_- -_- -_- -_- -_-
|
||||
=================================
|
||||
"""
|
||||
import decimal
|
||||
|
||||
a = 601.1
|
||||
b = decimal.Decimal('601.1')
|
||||
c = decimal.Decimal(601.1)
|
||||
|
||||
print(a) # 601.1
|
||||
print(b) # 601.1
|
||||
print(c) # 601.1000000000000227373675443232059478759765625
|
||||
|
||||
"""
|
||||
decimal类型的数据,要保持数据的精度,要加引号。
|
||||
"""
|
||||
num1 = 2.3
|
||||
num2 = 1.1
|
||||
print(num1-num2) # 1.1999999999999997
|
||||
|
||||
num3 = decimal.Decimal('2.3')
|
||||
num4 = decimal.Decimal('1.1')
|
||||
print(num3-num4) # 1.2
|
|
@ -0,0 +1,57 @@
|
|||
"""
|
||||
=================================
|
||||
Author: Flora Chen
|
||||
Time: 2020/3/25 14:23
|
||||
-_- -_- -_- -_- -_- -_- -_- -_-
|
||||
=================================
|
||||
"""
|
||||
|
||||
from requests import request
|
||||
from python27Class.unitTest.class03282020.conf.handle_config import conf
|
||||
import jsonpath
|
||||
|
||||
|
||||
def loginapi(method, url, headers, data):
|
||||
"""
|
||||
登录的接口
|
||||
:param url:
|
||||
:param method:
|
||||
:param headers:
|
||||
:param data:
|
||||
:return:
|
||||
"""
|
||||
response = request(method=method, url=url, headers=headers, json=data)
|
||||
token_type = jsonpath.jsonpath(response.json(), '$.data..token_info..token_type')[0]
|
||||
token = jsonpath.jsonpath(response.json(), '$.data..token_info..token')[0]
|
||||
member_id = jsonpath.jsonpath(response.json(), '$.data..id')[0]
|
||||
return token_type, token, member_id
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
url = conf.get('ENV', 'BASE_URL') + '/member/login'
|
||||
headers = eval(conf.get('ENV', 'BASE_HEADERS'))
|
||||
user = {"mobile_phone": conf.get('TEST', 'PHONE'), "pwd": conf.get('TEST', 'PWD')}
|
||||
method = 'post'
|
||||
token_info = loginapi(method, url, headers, user)
|
||||
print(type(token_info[0]))
|
||||
print(token_info[0] + ' ' + token_info[1], token_info[2])
|
||||
|
||||
|
||||
"""
|
||||
{'code': 0, 'msg': 'OK',
|
||||
'data':
|
||||
{'id': 7800355,
|
||||
'leave_amount': 0.0,
|
||||
'mobile_phone': '15500005678',
|
||||
'reg_name': '小柠檬',
|
||||
'reg_time': '2020-03-21 21:26:09.0',
|
||||
'type': 0,
|
||||
'token_info':
|
||||
{'token_type': 'Bearer',
|
||||
'expires_in': '2020-03-25 14:36:51',
|
||||
'token': 'eyJhbGciOiJIUzUxMiJ9.eyJtZW1iZXJfaWQiOjc4MDAzNTUsImV4cCI6MTU4NTExODIxMX0.pNjMUeC9v638hR_LiKRvnJqBljaSKmMIO6NtVIzLVdwj_jgG8xb5845eK-w8u-zygsg-7k3R6fsg1nYpMP70bA'
|
||||
}
|
||||
},
|
||||
'copyright': 'Copyright 柠檬班 © 2017-2019 湖南省零檬信息技术有限公司 All Rights Reserved'
|
||||
}
|
||||
"""
|
|
@ -0,0 +1,51 @@
|
|||
"""
|
||||
=================================
|
||||
Author: Flora Chen
|
||||
Time: 2020/3/28 9:55
|
||||
-_- -_- -_- -_- -_- -_- -_- -_-
|
||||
=================================
|
||||
"""
|
||||
import unittest
|
||||
|
||||
class MyTest(unittest.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
"""
|
||||
每条用例执行之前都会执行
|
||||
:return:
|
||||
"""
|
||||
print('-----------1------setUp----')
|
||||
pass
|
||||
|
||||
def tearDown(self):
|
||||
"""
|
||||
每条用例执行之后都会执行
|
||||
:return:
|
||||
"""
|
||||
print('-----------2-----tearDown-----')
|
||||
pass
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
"""
|
||||
该测试用例类中所有用例执行之前都会执行
|
||||
:return:
|
||||
"""
|
||||
print('-----------3----setUpClass------')
|
||||
pass
|
||||
|
||||
@classmethod
|
||||
def tearDownClass(cls):
|
||||
"""
|
||||
该测试用例类中所有用例执行之后都会执行
|
||||
:return:
|
||||
"""
|
||||
print('-----------4-----tearDownClass-----')
|
||||
pass
|
||||
|
||||
def test_01(self):
|
||||
self.assertEqual(100, 100)
|
||||
|
||||
def test_02(self):
|
||||
self.assertEqual(200, 200)
|
||||
|
Loading…
Reference in New Issue