Commit 10cd4ef3 authored by 小刘's avatar 小刘

登录修改调试

parent f1b0a368
common_config = {
"host": "http://192.168.32.31",
"host": "http://192.168.32.36",
"db_config": {
'database': 'edu-admin',
"user": 'read_user',
......@@ -11,7 +10,12 @@ common_config = {
"mongo_db_config": {
"host": 'yf2.jksxb.cn',
"port": 27017
},
"mysql_config": {
'database': '',
'user': 'root',
'password': 'mysqlLan2vWfdstv8',
'host': 'yf1.jksxb.cn',
'port': 3306
}
}
# coding=utf-8
import psycopg2
import pymongo
import pymysql
from common.common_config import common_config
class OperationDb:
# 获取pg数据库配置
database_config = common_config.get("db_config")
# 获取mysql数据库配置
mysql_database_config = common_config.get('mysql_config')
@classmethod
def query_sql(cls, sql_str):
# 创建连接对象
......@@ -18,9 +22,33 @@ class OperationDb:
print('查询结束')
return results
@classmethod
def execute_mysql(cls, sql_str, Type=True):
"""
@param sql_str: sql语句
@param Type: True为查询,False为其他
@return: 查询返回tuple,其他返回bool
"""
try:
db = pymysql.connect(**cls.mysql_database_config)
cursor = db.cursor()
cursor.execute(sql_str)
db.commit()
if Type:
results = cursor.fetchall()
else:
cursor.close()
return True
return results
except Exception as e:
db.rollback()
print(e)
return False
finally:
db.close()
class OperationMongoDb:
class OperationMongoDb:
database_config = common_config.get("mongo_db_config")
@classmethod
......@@ -57,5 +85,3 @@ if __name__ == "__main__":
condition = {"createTime": "2021-04-09"}
fields = {'_id': 0, "schoolAreaId": 1, "subject": 1, 'studentId': 1}
omd.query_data(table_name, condition=condition, fields=fields)
......@@ -3,16 +3,17 @@ import pytest
import jsonpath
from script import default_header
from common.common_config import common_config
from script.db_config import db_configs
from script.db_config import db_configs, mysql_configs
from script.base_api.service_user.auth import auth_employee_post
from script.defalut_account import accounts
from script.base_api.service_user.departments import departments_schools_get
from script.base_api.service_user.wxMini import wxMini_auth_post
from script.xin_project_patriarch_app.xin_patriarch_app.xin_patriach_static.xin_public_class.xin_global_static import StaticGlobal
def pytest_addoption(parser):
# 注册一个命令行选项host
parser.addoption("--host", default="http://192.168.32.31", dest="env", help="set test run env")
parser.addoption("--host", default="http://192.168.32.36", dest="env", help="set test run env")
# 注册一个命令行选项db
parser.addoption("--db", default="yf1", dest="db", help="set test database")
# 注册一个命令行选项account
......@@ -27,6 +28,10 @@ def get_host(pytestconfig):
allure.attach(body=common_config["host"], name='测试环境', attachment_type=allure.attachment_type.TEXT)
# 初始化测试数据库配置
common_config["db_config"] = db_configs.get(pytestconfig.getoption('--db'))
# 初始化mysql数据库
common_config["mysql_config"] = mysql_configs.get(pytestconfig.getoption('--db'))
# 配置登录
StaticGlobal.SERVER = pytestconfig.getoption('--host')
@allure.title('极运营登录前置')
......
......@@ -6,11 +6,48 @@ db_configs = {
"host": '192.168.32.36',
"port": 5432
},
"31": {
'database': 'postgres',
"user": 'dev',
"password": 'mko0PL<.;?',
"host": '192.168.32.31',
"port": 5432
},
"yf1": {
'database': 'edu-admin',
"user": 'read_user',
"password": 'c5JJUqmtTeaSaOTN2gs7',
"user": 'postgres',
"password": 'bnryQXJTO1fTPTvJpgeF',
"host": '132.232.15.12',
"port": 5432
}
}
mysql_configs = {
"31": {
'database': '',
'user': 'root',
'password': 'mysqlLan2vWfdstv8',
'host': '192.168.32.31',
'port': 3306
},
"36": {
'database': '',
'user': 'root',
'password': 'mysqlLan2vWfdstv8',
'host': '192.168.32.36',
'port': 3306
},
"94": {
'database': '',
'user': 'root',
'password': 'mysqlLan2vWfdstv8',
'host': '172.10.62.94',
'port': 3306
},
"yf1": {
'database': '',
'user': 'root',
'password': 'mysqlLan2vWfdstv8',
'host': 'yf1.jksxb.cn',
'port': 3306
}
}
......@@ -3,7 +3,6 @@ import time
import allure
import jsonpath
import pytest
from pytest_assume.plugin import assume
from script.base_api import app_class_schoolAreaId_getSameLevelSchoolArea_get
......@@ -13,7 +12,7 @@ from script.xin_project_patriarch_app.xin_patriarch_app.xin_patriach_static.xin_
from script.xin_project_patriarch_app.xin_patriarch_app.xin_patriach_static.xin_students_message.xin_query_students_message import QueryStudentsMessage
from script.xin_project_patriarch_app.xin_static.xin_crm.xin_apply.xin_pay_order import PayOrder
from script.xin_project_patriarch_app.xin_static.xin_crm.xin_apply.xin_save_order import SaveOrder
from script.xin_project_patriarch_app.xin_static.xin_crm.xin_student import CreateStudent
from script.xin_project_patriarch_app.xin_static.xin_crm.xin_students.xin_create_studens import CrmCreateStudents
from script.xin_project_patriarch_app.xin_static.xin_educational.xin_class_handle.xin_add_class import CreateClass
from script.xin_project_patriarch_app.xin_static.xin_educational.xin_course_handle.xin_course import CreateCourse
from script.xin_project_patriarch_app.xin_static.xin_educational.xin_network import NetWork
......@@ -32,11 +31,12 @@ class TestChooseClasses:
def setup_class(self):
self.server = StaticGlobal.SERVER
print(self.server)
self.schoolArea = StaticGlobal.SCHOOL
self.studentPho = '189' + datetime.datetime.now().strftime('%d%H%M%S')
students_data = CreateStudent(server=self.server, contactInfo=self.studentPho).create_student()
self.userId = students_data['data']['list'][0]['studentId']
self.header = AuthHeaders(server=self.server, username=self.studentPho, password='geek1234').get_auth_headers()
students_data = CrmCreateStudents(server=self.server, studentPrimPhoneNo=self.studentPho).create_student()
self.userId = students_data['data']['studentId']
"""
先让选课中心有一个班级,保证后面的断言正确
"""
......@@ -47,7 +47,23 @@ class TestChooseClasses:
year=StaticGlobal.YEAR,
term=StaticGlobal.TERM).create_course()['data']['content'][0]['courseId']
self.class_id = CreateClass(server=self.server, courseId=course_id, schoolArea=self.schoolArea).create_class()['classId']
order_id = SaveOrder(server=self.server, studentId=self.userId, amount=100, details=[{
"classId": self.class_id,
"num": 10,
"discountId": "",
"category": "CLASS"
}]).save_order()['data']
PayOrder(server=self.server, orderId=order_id, payInfos=[
{
"payChannel": "CASH",
"payAmount": 100
}
]).pay_order()
time.sleep(3)
NetWork(server=self.server, resignClassIds=[self.class_id]).network_set()
self.header = AuthHeaders(server=self.server, username=self.studentPho).get_auth_headers()
# 断言校区
@allure.story('选课中心-校区')
......@@ -58,7 +74,7 @@ class TestChooseClasses:
with assume: assert query_data['code'] == 0
with assume: assert query_data['data'][0]['student']['schoolArea'] == '3052'
with assume: assert query_data['data'][0]['student']['schoolName'] == '测试成都校区'
with assume: assert self.studentPho in query_data['data'][0]['student']['phones']
# with assume: assert self.studentPho in query_data['data'][0]['student']['phones']
# 断言可选中心校
@allure.story('选课中心-校区')
......@@ -263,8 +279,8 @@ class TestChooseClasses:
@allure.description('学生购买了新生班,不能看到常规班')
def test_choose_buy_new_not_groove(self):
studentPho = '144' + datetime.datetime.now().strftime('%S%f')
students_data = CreateStudent(server=self.server, contactInfo=studentPho).create_student()
userId = students_data['data']['list'][0]['studentId']
students_data = CrmCreateStudents(server=self.server, studentPrimPhoneNo=studentPho).create_student()
userId = students_data['data']['studentId']
course_id = CreateCourse(server=self.server,
productType='主线课程',
classType='新生',
......@@ -295,8 +311,8 @@ class TestChooseClasses:
@allure.description('学生购买了副线班,不能看到常规班和精品班')
def test_choose_buy_subLine_not_groove(self):
studentPho = '173' + datetime.datetime.now().strftime('%S%f')
students_data = CreateStudent(server=self.server, contactInfo=studentPho).create_student()
userId = students_data['data']['list'][0]['studentId']
students_data = CrmCreateStudents(server=self.server, studentPrimPhoneNo=studentPho).create_student()
userId = students_data['data']['studentId']
order_id = SaveOrder(server=self.server, studentId=userId, amount=100, details=[{
"classId": self.class_id,
"num": 10,
......@@ -320,8 +336,8 @@ class TestChooseClasses:
@allure.description('购买了当期前的常规班,不能看到常规班、和精品班,能看到新生班')
def test_choose_buy_before_groove_not_now(self):
studentPho = '173' + datetime.datetime.now().strftime('%S%f')
students_data = CreateStudent(server=self.server, contactInfo=studentPho).create_student()
userId = students_data['data']['list'][0]['studentId']
students_data = CrmCreateStudents(server=self.server, studentPrimPhoneNo=studentPho).create_student()
userId = students_data['data']['studentId']
course_id = CreateCourse(server=self.server,
productType='主线课程',
classType='极趣班',
......@@ -353,9 +369,12 @@ class TestChooseClasses:
@allure.title('购买了当期的常规班,可以看到常规班')
@allure.description('购买了当期的常规班,能看到常规班,不能看到新生班和精品班')
def test_choose_buy_now_groove(self):
"""
能看到其他科目的新生班,以及本科目的0元班,后期改进
"""
studentPho = '173' + datetime.datetime.now().strftime('%S%f')
students_data = CreateStudent(server=self.server, contactInfo=studentPho).create_student()
userId = students_data['data']['list'][0]['studentId']
students_data = CrmCreateStudents(server=self.server, studentPrimPhoneNo=studentPho).create_student()
userId = students_data['data']['studentId']
course_id = CreateCourse(server=self.server,
productType='主线课程',
classType='极趣班',
......@@ -378,19 +397,34 @@ class TestChooseClasses:
]).pay_order()
time.sleep(2)
choose_data = ChooseClasses(server=self.server, studentId=userId, schoolAreaId=self.schoolArea).choose_class()
with assume: assert choose_data.get('code') == 0
with assume: assert '极趣班' in jsonpath.jsonpath(choose_data, '$..classType')
with assume: assert '专题' in jsonpath.jsonpath(choose_data, '$..classType')
with assume: assert '新生' not in jsonpath.jsonpath(choose_data, '$..classType')
with assume: assert '一对一定制班' not in jsonpath.jsonpath(choose_data, '$..classType')
with assume:
assert choose_data.get('code') == 0
assert_data = choose_data.get('data')
# 以下断言是验证可以显示购买科目外其它科目的常规班,以及本科目的0元班级
for data in assert_data:
if data.get('classType') == '新生' and data.get('amount') == 0.0:
with assume:
assert data.get('subject') in ['数学', '语文', '英语', '物理', '化学']
elif data.get('classType') == '新生' and data.get('amount') != 0.0:
with assume:
assert data.get('subject') != '数学'
else:
pass
with assume:
assert '极趣班' in jsonpath.jsonpath(choose_data, '$..classType')
with assume:
assert '专题' in jsonpath.jsonpath(choose_data, '$..classType')
with assume:
assert '一对一定制班' not in jsonpath.jsonpath(choose_data, '$..classType')
@allure.story('选课列表-班级')
@allure.title('购买了当期后的常规班,看不到常规班')
@allure.description('购买了当期后的常规班,不能看到常规班和精品班,能看到新生班')
def test_choose_buy_after_groove_not_now(self):
studentPho = '173' + datetime.datetime.now().strftime('%S%f')
students_data = CreateStudent(server=self.server, contactInfo=studentPho).create_student()
userId = students_data['data']['list'][0]['studentId']
students_data = CrmCreateStudents(server=self.server, studentPrimPhoneNo=studentPho).create_student()
userId = students_data['data']['studentId']
course_id = CreateCourse(server=self.server,
productType='主线课程',
classType='极趣班',
......@@ -423,8 +457,8 @@ class TestChooseClasses:
@allure.description('购买班级,班级显示已报名的标签')
def test_choose_buy_show_bought(self):
studentPho = '173' + datetime.datetime.now().strftime('%S%f')
students_data = CreateStudent(server=self.server, contactInfo=studentPho).create_student()
userId = students_data['data']['list'][0]['studentId']
students_data = CrmCreateStudents(server=self.server, studentPrimPhoneNo=studentPho).create_student()
userId = students_data['data']['studentId']
course_id = CreateCourse(server=self.server,
productType='主线课程',
classType='新生',
......@@ -459,8 +493,8 @@ class TestChooseClasses:
userId_list = []
for student_count in range(2):
studentPho = '167' + datetime.datetime.now().strftime('%S%f')
students_data = CreateStudent(server=self.server, contactInfo=studentPho).create_student()
userId = students_data['data']['list'][0]['studentId']
students_data = CrmCreateStudents(server=self.server, studentPrimPhoneNo=studentPho).create_student()
userId = students_data['data']['studentId']
userId_list.append(userId)
course_id = CreateCourse(server=self.server,
productType='副线课程',
......@@ -498,8 +532,8 @@ class TestChooseClasses:
userId_list = []
for student_count in range(2):
studentPho = '177' + datetime.datetime.now().strftime('%S%f')
students_data = CreateStudent(server=self.server, contactInfo=studentPho).create_student()
userId = students_data['data']['list'][0]['studentId']
students_data = CrmCreateStudents(server=self.server, studentPrimPhoneNo=studentPho).create_student()
userId = students_data['data']['studentId']
userId_list.append(userId)
course_id = CreateCourse(server=self.server,
productType='主线课程',
......@@ -537,8 +571,8 @@ class TestChooseClasses:
userId_list = []
for student_count in range(2):
studentPho = '188' + datetime.datetime.now().strftime('%S%f')
students_data = CreateStudent(server=self.server, contactInfo=studentPho).create_student()
userId = students_data['data']['list'][0]['studentId']
students_data = CrmCreateStudents(server=self.server, studentPrimPhoneNo=studentPho).create_student()
userId = students_data['data']['studentId']
userId_list.append(userId)
class_list = []
for class_count in range(2):
......
......@@ -8,7 +8,7 @@ from script.xin_project_patriarch_app.xin_patriarch_app.xin_patriach_static.xin_
from script.xin_project_patriarch_app.xin_patriarch_app.xin_patriach_static.xin_public_class.xin_global_static import StaticGlobal
from script.xin_project_patriarch_app.xin_static.xin_crm.xin_apply.xin_pay_order import PayOrder
from script.xin_project_patriarch_app.xin_static.xin_crm.xin_apply.xin_save_order import SaveOrder
from script.xin_project_patriarch_app.xin_static.xin_crm.xin_student import CreateStudent
from script.xin_project_patriarch_app.xin_static.xin_crm.xin_students.xin_create_studens import CrmCreateStudents
from script.xin_project_patriarch_app.xin_static.xin_educational.xin_class_handle.xin_add_class import CreateClass
from script.xin_project_patriarch_app.xin_static.xin_educational.xin_class_handle.xin_delete_class import DeleteClass
from script.xin_project_patriarch_app.xin_static.xin_educational.xin_class_handle.xin_update_class import UpdateClass
......@@ -25,22 +25,18 @@ class TestAuthChoseClassDetails:
self.server = StaticGlobal.SERVER
self.schoolArea = StaticGlobal.SCHOOL
self.studentPho = '145' + datetime.datetime.now().strftime('%S%f')
students_data = CreateStudent(server=self.server, contactInfo=self.studentPho).create_student()
self.userId = students_data['data']['list'][0]['studentId']
students_data = CrmCreateStudents(server=self.server, studentPrimPhoneNo=self.studentPho).create_student()
self.userId = students_data['data']['studentId']
"""
购买一个常规班
"""
course_id = CreateCourse(server=self.server,
classType='极趣班',
courseType='常规班课',
productType='主线课程',
year=StaticGlobal.YEAR,
term=StaticGlobal.TERM,
courseNumber=1,
totalPrice=10).create_course()['data']['content'][0]['courseId']
productType='主线课程').create_course()['data']['content'][0]['courseId']
self.class_id = CreateClass(server=self.server, courseId=course_id, schoolArea=self.schoolArea).create_class()['classId']
NetWork(server=self.server, resignClassIds=[self.class_id]).network_set()
order_id = SaveOrder(server=self.server, studentId=self.userId, amount=10, details=[{
order_id = SaveOrder(server=self.server, studentId=self.userId, amount=100, details=[{
"classId": self.class_id,
"num": 10,
"discountId": "",
......@@ -49,7 +45,7 @@ class TestAuthChoseClassDetails:
PayOrder(server=self.server, orderId=order_id, payInfos=[
{
"payChannel": "CASH",
"payAmount": 10
"payAmount": 100
}
]).pay_order()
time.sleep(3)
......@@ -222,8 +218,31 @@ class TestAuthSectionClassDetails:
self.server = StaticGlobal.SERVER
self.schoolArea = StaticGlobal.SCHOOL
self.studentPho = '145' + datetime.datetime.now().strftime('%S%f')
students_data = CreateStudent(server=self.server, contactInfo=self.studentPho).create_student()
self.userId = students_data['data']['list'][0]['studentId']
students_data = CrmCreateStudents(server=self.server, studentPrimPhoneNo=self.studentPho).create_student()
self.userId = students_data['data']['studentId']
"""
购买一个常规班
"""
course_id = CreateCourse(server=self.server,
classType='极趣班',
courseType='常规班课',
productType='主线课程').create_course()['data']['content'][0]['courseId']
self.class_id = CreateClass(server=self.server, courseId=course_id, schoolArea=self.schoolArea).create_class()['classId']
NetWork(server=self.server, resignClassIds=[self.class_id]).network_set()
order_id = SaveOrder(server=self.server, studentId=self.userId, amount=100, details=[{
"classId": self.class_id,
"num": 100,
"discountId": "",
"category": "CLASS"
}]).save_order()['data']
PayOrder(server=self.server, orderId=order_id, payInfos=[
{
"payChannel": "CASH",
"payAmount": 10
}
]).pay_order()
time.sleep(3)
# 获取当前时间后14天为分段上的结束时间
start_time = datetime.datetime.now() + timedelta(days=14)
......
......@@ -10,6 +10,7 @@ from script.xin_project_patriarch_app.xin_patriarch_app.xin_patriach_static.xin_
from script.xin_project_patriarch_app.xin_static.xin_crm.xin_apply.xin_pay_order import PayOrder
from script.xin_project_patriarch_app.xin_static.xin_crm.xin_apply.xin_save_order import SaveOrder
from script.xin_project_patriarch_app.xin_static.xin_crm.xin_student import CreateStudent
from script.xin_project_patriarch_app.xin_static.xin_crm.xin_students.xin_create_studens import CrmCreateStudents
from script.xin_project_patriarch_app.xin_static.xin_educational.xin_class_handle.xin_add_class import CreateClass
from script.xin_project_patriarch_app.xin_static.xin_educational.xin_class_handle.xin_update_class import UpdateClass
from script.xin_project_patriarch_app.xin_static.xin_educational.xin_course_handle.xin_course import CreateCourse
......@@ -25,8 +26,8 @@ class TestAuthUpdateChooseClass:
self.server = StaticGlobal.SERVER
self.schoolArea = StaticGlobal.SCHOOL
self.studentPho = '189' + datetime.datetime.now().strftime('%d%H%M%S')
students_data = CreateStudent(server=self.server, contactInfo=self.studentPho).create_student()
self.userId = students_data['data']['list'][0]['studentId']
students_data = CrmCreateStudents(server=self.server, studentPrimPhoneNo=self.studentPho).create_student()
self.userId = students_data['data']['studentId']
"""
购买一个常规班
"""
......
......@@ -15,7 +15,7 @@ from script.xin_project_patriarch_app.xin_patriarch_app.xin_patriach_static.xin_
from script.xin_project_patriarch_app.xin_patriarch_app.xin_patriach_static.xin_public_class.xin_global_static import StaticGlobal
from script.xin_project_patriarch_app.xin_static.xin_crm.xin_apply.xin_pay_order import PayOrder
from script.xin_project_patriarch_app.xin_static.xin_crm.xin_apply.xin_save_order import SaveOrder
from script.xin_project_patriarch_app.xin_static.xin_crm.xin_student import CreateStudent
from script.xin_project_patriarch_app.xin_static.xin_crm.xin_students.xin_create_studens import CrmCreateStudents
from script.xin_project_patriarch_app.xin_static.xin_educational.xin_class_handle.xin_add_class import CreateClass
from script.xin_project_patriarch_app.xin_static.xin_educational.xin_class_handle.xin_delete_class import DeleteClass
from script.xin_project_patriarch_app.xin_static.xin_educational.xin_course_handle.xin_course import CreateCourse
......@@ -37,8 +37,30 @@ class TestAuthAddClassToPurchase:
self.schoolArea = StaticGlobal.SCHOOL
# 新建一个学生
self.studentPho = '189' + datetime.datetime.now().strftime('%d%H%M%S')
students_data = CreateStudent(server=self.server, contactInfo=self.studentPho).create_student()
self.userId = students_data['data']['list'][0]['studentId']
students_data = CrmCreateStudents(server=self.server, studentPrimPhoneNo=self.studentPho).create_student()
self.userId = students_data['data']['studentId']
course_id = CreateCourse(server=self.server,
classType='专题',
courseType='专题班课',
productType='副线课程',
year=StaticGlobal.YEAR,
term=StaticGlobal.TERM).create_course()['data']['content'][0]['courseId']
self.class_id = CreateClass(server=self.server, courseId=course_id, schoolArea=self.schoolArea).create_class()['classId']
order_id = SaveOrder(server=self.server, studentId=self.userId, amount=100, details=[{
"classId": self.class_id,
"num": 10,
"discountId": "",
"category": "CLASS"
}]).save_order()['data']
PayOrder(server=self.server, orderId=order_id, payInfos=[
{
"payChannel": "CASH",
"payAmount": 100
}
]).pay_order()
time.sleep(3)
self.header = AuthHeaders(server=self.server, username=self.studentPho).get_auth_headers()
@allure.story('加入购课单')
......@@ -121,8 +143,8 @@ class TestAuthAddClassToPurchase:
def test_full_class_add_purchase(self):
# 新建一个学生报班,让班级满员
studentPho_two = '189' + datetime.datetime.now().strftime('%d%H%M%S')
students_data_two = CreateStudent(server=self.server, contactInfo=studentPho_two).create_student()
userId_two = students_data_two['data']['list'][0]['studentId']
students_data_two = CrmCreateStudents(server=self.server, studentPrimPhoneNo=studentPho_two).create_student()
userId_two = students_data_two['data']['studentId']
# header_two = AuthHeaders(server=self.server, username=self.studentPho).get_auth_headers()
# 新建一个班级
course_id = CreateCourse(server=self.server,
......
......@@ -11,6 +11,7 @@ from script.xin_project_patriarch_app.xin_static.xin_crm.xin_apply.xin_pay_order
from script.xin_project_patriarch_app.xin_static.xin_crm.xin_apply.xin_save_order import SaveOrder
from script.xin_project_patriarch_app.xin_static.xin_crm.xin_apply.xin_scrap_order.xin_scrap_order import ScrapOrder
from script.xin_project_patriarch_app.xin_static.xin_crm.xin_student import CreateStudent
from script.xin_project_patriarch_app.xin_static.xin_crm.xin_students.xin_create_studens import CrmCreateStudents
from script.xin_project_patriarch_app.xin_static.xin_educational.xin_class_handle.xin_add_class import CreateClass
from script.xin_project_patriarch_app.xin_static.xin_educational.xin_course_handle.xin_course import CreateCourse
from script.xin_project_patriarch_app.xin_static.xin_finance.xin_carryover.carryover import CarryOver
......@@ -19,6 +20,9 @@ from script.xin_project_patriarch_app.xin_static.xin_user.xin_patriarch_login im
"""
学生没有购买过班级
2021年5月25日
业务逻辑修改,学生没有购买班级不能登录家长APP
"""
......@@ -28,9 +32,9 @@ from script.xin_project_patriarch_app.xin_static.xin_user.xin_patriarch_login im
# def setup_class(self):
# self.server = StaticGlobal.SERVER
# self.studentPho = '133' + datetime.datetime.now().strftime('%S%f')
# students_data = CreateStudent(server=self.server, contactInfo=self.studentPho).create_student()
# students_data = CrmCreateStudents(server=self.server, studentPrimPhoneNo=self.studentPho).create_student()
# self.userId = students_data['data']['list'][0]['studentId']
# self.headers = AuthHeaders(server=self.server, username=self.studentPho, password='geek1234').get_auth_headers()
# self.header = AuthHeaders(server=self.server, username=self.studentPho, password='geek1234').get_auth_headers()
#
# """
# 验证没有报班,班级列表为空
......@@ -44,11 +48,11 @@ from script.xin_project_patriarch_app.xin_static.xin_user.xin_patriarch_login im
# with assume: assert query_data['code'] == 0
# with assume: assert query_data['msg'] == '成功'
# with assume: assert query_data['data']['studentClassInfoDtoList'] == []
#
#
# """
# 学生购买了常规班,副线班,精品班
# """
"""
学生购买了常规班,副线班,精品班
"""
@allure.epic('家长APP接口自动化测试')
......@@ -57,267 +61,311 @@ class TestAuthHaveClasses:
def setup_class(self):
self.server = StaticGlobal.SERVER
self.studentPho = '133' + datetime.datetime.now().strftime('%S%f')
self.students_data = CreateStudent(server=self.server, contactInfo=self.studentPho).create_student()
self.userId = self.students_data['data']['list'][0]['studentId']
# self.create_class_data = [['主线课程', '极趣班', '常规班课', '数学'],
# ['主线课程', '极思班', '常规班课', '语文'],
# ['主线课程', '极智班', '常规班课', '英语'],
# ['主线课程', '一对一定制班', '精品定制课', '数学'],
# ['副线课程', '专题', '专题班课', '数学'],
# ['副线课程', '五四制班', '集训班课', '语文'],
# ['副线课程', '公开课', '服务班课', '英语']]
# self.details = []
# for class_data in self.create_class_data:
# self.course_id = CreateCourse(server=self.server,
# productType=class_data[0],
# classType=class_data[1],
# courseType=class_data[2],
# subject=class_data[3]).create_course()['data']['content'][0]['courseId']
# class_id = CreateClass(server=self.server, courseId=self.course_id).create_class()['classId']
# self.details.append({
# "classId": class_id,
# "num": 10,
# "discountId": "",
# "category": "CLASS"
# })
# order_id = SaveOrder(server=self.server, studentId=self.userId, amount=700, details=self.details).save_order().get('data')
#
# PayOrder(server=self.server, orderId=order_id, payInfos=[
# {
# "payChannel": "CASH",
# "payAmount": 700
# }
# ]).pay_order()
# time.sleep(3)
self.headers = AuthHeaders(server=self.server, username=self.studentPho, password='geek1234').get_auth_headers()
# @allure.story('学生有在读班级')
# @allure.title('查询学生所有的班级')
# @allure.description('查询学生所有的班级,验证有常规班')
# def test_query_all(self):
# query_data = QueryClass(server=self.server, headers=self.headers, studentId=self.userId).query_class_list()
# with assume: assert query_data['code'] == 0
# with assume: assert query_data['msg'] == '成功'
# with assume: assert query_data['data']['studentClassInfoDtoList'] != []
# with assume: assert '常规班课' in jsonpath.jsonpath(query_data, '$...courseType')
# with assume: assert self.details[0]['classId'] in jsonpath.jsonpath(query_data, '$...classId')
# with assume: assert self.details[1]['classId'] in jsonpath.jsonpath(query_data, '$...classId')
# with assume: assert self.details[2]['classId'] in jsonpath.jsonpath(query_data, '$...classId')
# with assume: assert self.details[3]['classId'] in jsonpath.jsonpath(query_data, '$...classId')
# with assume: assert self.details[4]['classId'] in jsonpath.jsonpath(query_data, '$...classId')
# with assume: assert self.details[5]['classId'] in jsonpath.jsonpath(query_data, '$...classId')
# with assume: assert self.details[6]['classId'] in jsonpath.jsonpath(query_data, '$...classId')
#
# @allure.story('学生有在读班级')
# @allure.title('数学科目筛选')
# @allure.description('查询在读班级中有数学科目,没有语文科目')
# def test_query_have_subject(self):
# query_data = QueryClass(server=self.server, headers=self.headers, studentId=self.userId, subjects=['数学']).query_class_list()
# with assume: assert query_data['code'] == 0
# with assume: assert query_data['msg'] == '成功'
# with assume: assert jsonpath.jsonpath(query_data, '$...subject')[0] == '数学'
# with assume: assert jsonpath.jsonpath(query_data, '$...subject')[0] != '语文'
#
# @allure.story('学生有在读班级')
# @allure.title('语文科目筛选')
# @allure.description('查询在读班级中有语文科目,没有数学科目')
# def test_query_not_subject(self):
# query_data = QueryClass(server=self.server, headers=self.headers, studentId=self.userId, subjects=['语文']).query_class_list()
# with assume: assert query_data['code'] == 0
# with assume: assert query_data['msg'] == '成功'
# with assume: assert query_data['data']['studentClassInfoDtoList'] != []
# with assume: assert jsonpath.jsonpath(query_data, '$...subject')[0] == '语文'
#
# @allure.story('学生有在读班级')
# @allure.title('常规班课筛选')
# @allure.description('查询在读班级中班型只有常规班课')
# def test_query_classType(self):
# query_data = QueryClass(server=self.server, headers=self.headers, studentId=self.userId, courseTypes=['常规班课']).query_class_list()
# with assume: assert query_data['code'] == 0
# with assume: assert query_data['msg'] == '成功'
# with assume: assert jsonpath.jsonpath(query_data, '$...courseType')[0] == '常规班课'
# with assume: assert jsonpath.jsonpath(query_data, '$...courseType')[0] != '精品定制课'
#
# @allure.story('学生有在读班级')
# @allure.title('集训班课筛选')
# @allure.description('查询在读班级中班型只有集训班')
# def test_query_not_classType(self):
# query_data = QueryClass(server=self.server, headers=self.headers, studentId=self.userId, courseTypes=['集训班课']).query_class_list()
# with assume: assert query_data['code'] == 0
# with assume: assert query_data['msg'] == '成功'
# with assume: assert query_data['data']['studentClassInfoDtoList'] != []
#
# @allure.story('学生有在读班级')
# @allure.title('春期段筛选')
# @allure.description('查询在读班级中期段为春的班级')
# def test_query_classTerm(self):
# query_data = QueryClass(server=self.server, headers=self.headers, studentId=self.userId, classTerms=['春']).query_class_list()
# with assume: assert query_data['code'] == 0
# with assume: assert query_data['msg'] == '成功'
# with assume: assert jsonpath.jsonpath(query_data, '$...classTerm')[0] == '春'
# with assume: assert jsonpath.jsonpath(query_data, '$...classTerm')[0] != '秋'
#
# @allure.story('学生有在读班级')
# @allure.title('寒期段筛选')
# @allure.description('查询在读班级中期段没有寒期段的班级')
# def test_query_not_classTerm(self):
# query_data = QueryClass(server=self.server, headers=self.headers, studentId=self.userId, classTerms=['寒']).query_class_list()
# with assume: assert query_data['code'] == 0
# with assume: assert query_data['msg'] == '成功'
# with assume: assert query_data['data']['studentClassInfoDtoList'] == []
#
# @allure.story('学生有在读班级')
# @allure.title('科目、期段、班型筛选')
# @allure.description('查询在读班级中符合筛选条件的班级')
# def test_query_all_option(self):
# query_data = QueryClass(server=self.server, headers=self.headers, studentId=self.userId, subjects=['数学'], classTerms=['春'], courseTypes=['常规班课']).query_class_list()
# with assume: assert query_data['code'] == 0
# with assume: assert query_data['msg'] == '成功'
# with assume: assert '春' in jsonpath.jsonpath(query_data, '$...classTerm')
# with assume: assert '秋' not in jsonpath.jsonpath(query_data, '$...classTerm')
# with assume: assert '数学' in jsonpath.jsonpath(query_data, '$...subject')
# with assume: assert '英语' not in jsonpath.jsonpath(query_data, '$...subject')
# with assume: assert '常规班课' in jsonpath.jsonpath(query_data, '$...courseType')
# with assume: assert '副线班课' not in jsonpath.jsonpath(query_data, '$...courseType')
#
# @allure.story('学生有在读班级')
# @allure.title('班级年级验证')
# @allure.description('查询在读班级中年级正确')
# def test_query_graduate(self):
# query_data = QueryClass(server=self.server, headers=self.headers, studentId=self.userId, classStatus=1).query_class_list()
# with assume: assert query_data['code'] == 0
# with assume: assert query_data['msg'] == '成功'
# with assume: assert query_data['data']['studentClassInfoDtoList'] == []
# @allure.story('学生有在读班级')
# @allure.title('验证作废订单,列表不展示该班级')
# @allure.description('验证作废订单,列表不展示该班级')
# def test_cancellation_order_query_class(self):
# # 创建一个班级
# course_id = CreateCourse(server=self.server,
# productType='主线课程',
# classType='极趣班',
# courseType='常规班课',
# year=StaticGlobal.YEAR,
# term=StaticGlobal.TERM).create_course()['data']['content'][0]['courseId']
# class_id = CreateClass(server=self.server, courseId=course_id).create_class()['classId']
# order_id = SaveOrder(server=self.server, studentId=self.userId, amount=100, details=[{
# "classId": class_id,
# "num": 10,
# "discountId": "",
# "category": "CLASS"
# }]).save_order()['data']
#
# # 购买该班级
# PayOrder(server=self.server, orderId=order_id, payInfos=[
# {
# "payChannel": "CASH",
# "payAmount": 100
# }
# ]).pay_order()
#
# # 因为入班要走MQ,所以要停留
# time.sleep(2)
#
# # 作废订单
# ScrapOrder(server=self.server, order_id=order_id).scrap_order()
# time.sleep(1)
#
# # 查询学生的在读班级
# query_data = QueryClass(server=self.server, headers=self.headers, studentId=self.userId).query_class_list()
# with assume: assert query_data.get('code') == 0
# with assume: assert query_data.get('msg') == '成功'
# with assume: assert query_data.get('data').get('studentClassInfoDtoList') == []
# with assume: assert query_data.get('data').get('xiZiStatus') is False
# @allure.story('学生有在读班级')
# @allure.title('验证结转,列表不展示该班级')
# @allure.description('验证结转,列表不展示该班级')
# def test_carry_query_class(self):
# # 创建一个班级
# course_id = CreateCourse(server=self.server,
# productType='主线课程',
# classType='极思班',
# courseType='常规班课',
# year=StaticGlobal.YEAR,
# term=StaticGlobal.TERM).create_course()['data']['content'][0]['courseId']
# class_id = CreateClass(server=self.server, courseId=course_id).create_class()['classId']
# order_id = SaveOrder(server=self.server, studentId=self.userId, amount=100, details=[{
# "classId": class_id,
# "num": 10,
# "discountId": "",
# "category": "CLASS"
# }]).save_order()['data']
#
# # 购买该班级
# PayOrder(server=self.server, orderId=order_id, payInfos=[
# {
# "payChannel": "CASH",
# "payAmount": 100
# }
# ]).pay_order()
#
# # 因为入班要走MQ,所以要停留
# time.sleep(2)
#
# # 结转该班级
# CarryOver(server=self.server, studentId=self.userId).return_carry_over(class_id=class_id)
# time.sleep(1)
#
# # 查询学生在读班级
# query_data = QueryClass(server=self.server, headers=self.headers, studentId=self.userId).query_class_list()
# with assume: assert query_data.get('code') == 0
# with assume: assert query_data.get('msg') == '成功'
# with assume: assert query_data.get('data').get('studentClassInfoDtoList') == []
# with assume: assert query_data.get('data').get('xiZiStatus') is False
# @allure.story('学生有在读班级')
# @allure.title('验证退费,列表不展示该班级')
# @allure.description('验证退费,列表不展示该班级')
# def test_return_premium_query_class(self):
# # 创建一个班级
# course_id = CreateCourse(server=self.server,
# productType='主线课程',
# classType='极思班',
# courseType='常规班课',
# year=StaticGlobal.YEAR,
# term=StaticGlobal.TERM).create_course()['data']['content'][0]['courseId']
# class_id = CreateClass(server=self.server, courseId=course_id).create_class()['classId']
# order_id = SaveOrder(server=self.server, studentId=self.userId, amount=100, details=[{
# "classId": class_id,
# "num": 10,
# "discountId": "",
# "category": "CLASS"
# }]).save_order()['data']
#
# # 购买该班级
# PayOrder(server=self.server, orderId=order_id, payInfos=[
# {
# "payChannel": "CASH",
# "payAmount": 100
# }
# ]).pay_order()
#
# # 因为入班要走MQ,所以要停留
# time.sleep(2)
#
# # 退费班级
# FinanceRefund(server=self.server, studentId=self.userId).finance_refund(class_id=class_id)
# time.sleep(1)
#
# # 查询班级
# query_data = QueryClass(server=self.server, headers=self.headers, studentId=self.userId).query_class_list()
# with assume: assert query_data.get('code') == 0
# with assume: assert query_data.get('msg') == '成功'
# with assume: assert query_data.get('data').get('studentClassInfoDtoList') == []
# with assume: assert query_data.get('data').get('xiZiStatus') is False
# 新建学生
self.students_data = CrmCreateStudents(server=self.server, studentPrimPhoneNo=self.studentPho).create_student()
# 这是之前的新建线索,拿不到studentId,已废弃
# self.students_data = CreateStudent(server=self.server, contactInfo=self.studentPho).create_student()
self.userId = self.students_data.get('data').get('studentId')
self.create_class_data = [['主线课程', '极趣班', '常规班课', '数学'],
['主线课程', '极思班', '常规班课', '语文'],
['主线课程', '极智班', '常规班课', '英语'],
['主线课程', '一对一定制班', '精品定制课', '数学'],
['副线课程', '专题', '专题班课', '数学'],
['副线课程', '五四制班', '集训班课', '语文'],
['副线课程', '公开课', '服务班课', '英语']]
self.details = []
for class_data in self.create_class_data:
self.course_id = CreateCourse(server=self.server,
productType=class_data[0],
classType=class_data[1],
courseType=class_data[2],
subject=class_data[3]).create_course()['data']['content'][0]['courseId']
class_id = CreateClass(server=self.server, courseId=self.course_id).create_class()['classId']
self.details.append({
"classId": class_id,
"num": 10,
"discountId": "",
"category": "CLASS"
})
order_id = SaveOrder(server=self.server, studentId=self.userId, amount=700, details=self.details).save_order().get('data')
PayOrder(server=self.server, orderId=order_id, payInfos=[
{
"payChannel": "CASH",
"payAmount": 700
}
]).pay_order()
time.sleep(3)
self.headers = AuthHeaders(server=self.server, username=self.studentPho).get_auth_headers()
@allure.story('学生有在读班级')
@allure.title('查询学生所有的班级')
@allure.description('查询学生所有的班级,验证有常规班')
def test_query_all(self):
query_data = QueryClass(server=self.server, headers=self.headers, studentId=self.userId).query_class_list()
with assume: assert query_data['code'] == 0
with assume: assert query_data['msg'] == '成功'
with assume: assert query_data['data']['studentClassInfoDtoList'] != []
with assume: assert '常规班课' in jsonpath.jsonpath(query_data, '$...courseType')
with assume: assert self.details[0]['classId'] in jsonpath.jsonpath(query_data, '$...classId')
with assume: assert self.details[1]['classId'] in jsonpath.jsonpath(query_data, '$...classId')
with assume: assert self.details[2]['classId'] in jsonpath.jsonpath(query_data, '$...classId')
with assume: assert self.details[3]['classId'] in jsonpath.jsonpath(query_data, '$...classId')
with assume: assert self.details[4]['classId'] in jsonpath.jsonpath(query_data, '$...classId')
with assume: assert self.details[5]['classId'] in jsonpath.jsonpath(query_data, '$...classId')
with assume: assert self.details[6]['classId'] in jsonpath.jsonpath(query_data, '$...classId')
@allure.story('学生有在读班级')
@allure.title('数学科目筛选')
@allure.description('查询在读班级中有数学科目,没有语文科目')
def test_query_have_subject(self):
query_data = QueryClass(server=self.server, headers=self.headers, studentId=self.userId, subjects=['数学']).query_class_list()
with assume: assert query_data['code'] == 0
with assume: assert query_data['msg'] == '成功'
with assume: assert jsonpath.jsonpath(query_data, '$...subject')[0] == '数学'
with assume: assert jsonpath.jsonpath(query_data, '$...subject')[0] != '语文'
@allure.story('学生有在读班级')
@allure.title('语文科目筛选')
@allure.description('查询在读班级中有语文科目,没有数学科目')
def test_query_not_subject(self):
query_data = QueryClass(server=self.server, headers=self.headers, studentId=self.userId, subjects=['语文']).query_class_list()
with assume: assert query_data['code'] == 0
with assume: assert query_data['msg'] == '成功'
with assume: assert query_data['data']['studentClassInfoDtoList'] != []
with assume: assert jsonpath.jsonpath(query_data, '$...subject')[0] == '语文'
@allure.story('学生有在读班级')
@allure.title('常规班课筛选')
@allure.description('查询在读班级中班型只有常规班课')
def test_query_classType(self):
query_data = QueryClass(server=self.server, headers=self.headers, studentId=self.userId, courseTypes=['常规班课']).query_class_list()
with assume: assert query_data['code'] == 0
with assume: assert query_data['msg'] == '成功'
with assume: assert jsonpath.jsonpath(query_data, '$...courseType')[0] == '常规班课'
with assume: assert jsonpath.jsonpath(query_data, '$...courseType')[0] != '精品定制课'
@allure.story('学生有在读班级')
@allure.title('集训班课筛选')
@allure.description('查询在读班级中班型只有集训班')
def test_query_not_classType(self):
query_data = QueryClass(server=self.server, headers=self.headers, studentId=self.userId, courseTypes=['集训班课']).query_class_list()
with assume: assert query_data['code'] == 0
with assume: assert query_data['msg'] == '成功'
with assume: assert query_data['data']['studentClassInfoDtoList'] != []
@allure.story('学生有在读班级')
@allure.title('春期段筛选')
@allure.description('查询在读班级中期段为春的班级')
def test_query_classTerm(self):
query_data = QueryClass(server=self.server, headers=self.headers, studentId=self.userId, classTerms=['春']).query_class_list()
with assume: assert query_data['code'] == 0
with assume: assert query_data['msg'] == '成功'
with assume: assert jsonpath.jsonpath(query_data, '$...classTerm')[0] == '春'
with assume: assert jsonpath.jsonpath(query_data, '$...classTerm')[0] != '秋'
@allure.story('学生有在读班级')
@allure.title('寒期段筛选')
@allure.description('查询在读班级中期段没有寒期段的班级')
def test_query_not_classTerm(self):
query_data = QueryClass(server=self.server, headers=self.headers, studentId=self.userId, classTerms=['寒']).query_class_list()
with assume: assert query_data['code'] == 0
with assume: assert query_data['msg'] == '成功'
with assume: assert query_data['data']['studentClassInfoDtoList'] == []
@allure.story('学生有在读班级')
@allure.title('科目、期段、班型筛选')
@allure.description('查询在读班级中符合筛选条件的班级')
def test_query_all_option(self):
query_data = QueryClass(server=self.server, headers=self.headers, studentId=self.userId, subjects=['数学'], classTerms=['春'], courseTypes=['常规班课']).query_class_list()
with assume: assert query_data['code'] == 0
with assume: assert query_data['msg'] == '成功'
with assume: assert '春' in jsonpath.jsonpath(query_data, '$...classTerm')
with assume: assert '秋' not in jsonpath.jsonpath(query_data, '$...classTerm')
with assume: assert '数学' in jsonpath.jsonpath(query_data, '$...subject')
with assume: assert '英语' not in jsonpath.jsonpath(query_data, '$...subject')
with assume: assert '常规班课' in jsonpath.jsonpath(query_data, '$...courseType')
with assume: assert '副线班课' not in jsonpath.jsonpath(query_data, '$...courseType')
@allure.story('学生有在读班级')
@allure.title('班级年级验证')
@allure.description('查询在读班级中年级正确')
def test_query_graduate(self):
query_data = QueryClass(server=self.server, headers=self.headers, studentId=self.userId, classStatus=1).query_class_list()
with assume: assert query_data['code'] == 0
with assume: assert query_data['msg'] == '成功'
with assume: assert query_data['data']['studentClassInfoDtoList'] == []
@allure.story('学生有在读班级')
@allure.title('验证作废订单,列表不展示该班级')
@allure.description('验证作废订单,列表不展示该班级')
def test_cancellation_order_query_class(self):
# 创建一个班级
course_id = CreateCourse(server=self.server,
productType='主线课程',
classType='极趣班',
courseType='常规班课',
year=StaticGlobal.YEAR,
term=StaticGlobal.TERM).create_course()['data']['content'][0]['courseId']
class_id = CreateClass(server=self.server, courseId=course_id).create_class()['classId']
order_id = SaveOrder(server=self.server, studentId=self.userId, amount=100, details=[{
"classId": class_id,
"num": 10,
"discountId": "",
"category": "CLASS"
}]).save_order()['data']
# 购买该班级
PayOrder(server=self.server, orderId=order_id, payInfos=[
{
"payChannel": "CASH",
"payAmount": 100
}
]).pay_order()
# 因为入班要走MQ,所以要停留
time.sleep(2)
# 作废订单
ScrapOrder(server=self.server, order_id=order_id).scrap_order()
time.sleep(1)
# 查询学生的在读班级
query_data = QueryClass(server=self.server, headers=self.headers, studentId=self.userId).query_class_list()
with assume: assert query_data.get('code') == 0
with assume: assert query_data.get('msg') == '成功'
with assume: assert class_id not in query_data.get('data').get('studentClassInfoDtoList')
with assume: assert query_data.get('data').get('xiZiStatus') is False
@allure.story('学生有在读班级')
@allure.title('验证结转,列表不展示该班级')
@allure.description('验证结转,列表不展示该班级')
def test_carry_query_class(self):
# 创建一个班级
course_id = CreateCourse(server=self.server,
productType='主线课程',
classType='极思班',
courseType='常规班课',
year=StaticGlobal.YEAR,
term=StaticGlobal.TERM).create_course()['data']['content'][0]['courseId']
class_id = CreateClass(server=self.server, courseId=course_id).create_class()['classId']
order_id = SaveOrder(server=self.server, studentId=self.userId, amount=100, details=[{
"classId": class_id,
"num": 10,
"discountId": "",
"category": "CLASS"
}]).save_order()['data']
# 购买该班级
PayOrder(server=self.server, orderId=order_id, payInfos=[
{
"payChannel": "CASH",
"payAmount": 100
}
]).pay_order()
# 因为入班要走MQ,所以要停留
time.sleep(2)
# 结转该班级
CarryOver(server=self.server, studentId=self.userId).return_carry_over(class_id=class_id)
time.sleep(1)
# 查询学生在读班级
query_data = QueryClass(server=self.server, headers=self.headers, studentId=self.userId).query_class_list()
with assume: assert query_data.get('code') == 0
with assume: assert query_data.get('msg') == '成功'
with assume: assert class_id not in jsonpath.jsonpath(query_data, '$...classId')
with assume: assert query_data.get('data').get('xiZiStatus') is False
@allure.story('学生有在读班级')
@allure.title('验证退费,列表不展示该班级')
@allure.description('验证退费,列表不展示该班级')
def test_return_premium_query_class(self):
# 创建一个班级
course_id = CreateCourse(server=self.server,
productType='主线课程',
classType='极思班',
courseType='常规班课',
year=StaticGlobal.YEAR,
term=StaticGlobal.TERM).create_course()['data']['content'][0]['courseId']
class_id = CreateClass(server=self.server, courseId=course_id).create_class()['classId']
order_id = SaveOrder(server=self.server, studentId=self.userId, amount=100, details=[{
"classId": class_id,
"num": 10,
"discountId": "",
"category": "CLASS"
}]).save_order()['data']
# 购买该班级
PayOrder(server=self.server, orderId=order_id, payInfos=[
{
"payChannel": "CASH",
"payAmount": 100
}
]).pay_order()
# 因为入班要走MQ,所以要停留
time.sleep(2)
# 退费班级
FinanceRefund(server=self.server, studentId=self.userId).finance_refund(class_id=class_id)
time.sleep(1)
# 查询班级
query_data = QueryClass(server=self.server, headers=self.headers, studentId=self.userId).query_class_list()
with assume: assert query_data.get('code') == 0
with assume: assert query_data.get('msg') == '成功'
with assume: assert class_id not in jsonpath.jsonpath(query_data, '$...classId')
with assume: assert query_data.get('data').get('xiZiStatus') is False
@allure.story('学生有在读班级')
@allure.title('验证转费给其他人,列表不展示该班级')
@allure.description('验证转费给其他人,列表不展示该班级')
def test_transfer_other_query_class(self):
pass
# 创建一个班级
course_id = CreateCourse(server=self.server,
productType='主线课程',
classType='极思班',
courseType='常规班课',
year=StaticGlobal.YEAR,
term=StaticGlobal.TERM).create_course()['data']['content'][0]['courseId']
class_id = CreateClass(server=self.server, courseId=course_id).create_class()['classId']
order_id = SaveOrder(server=self.server, studentId=self.userId, amount=100, details=[{
"classId": class_id,
"num": 10,
"discountId": "",
"category": "CLASS"
}]).save_order()['data']
# 购买该班级
PayOrder(server=self.server, orderId=order_id, payInfos=[
{
"payChannel": "CASH",
"payAmount": 100
}
]).pay_order()
# 因为入班要走MQ,所以要停留
time.sleep(2)
# 创建一个学生
studentPho = '134' + datetime.datetime.now().strftime('%S%f')
students_data = CreateStudent(server=self.server, contactInfo=studentPho).create_student()
userId = students_data['data']['list'][0]['studentId']
# 转费给其他人
FinanceRefund(server=self.server, studentId=self.userId).return_refund(class_id=class_id, to_student_id=userId)
time.sleep(1)
# 查询班级
query_data = QueryClass(server=self.server, headers=self.headers, studentId=self.userId).query_class_list()
with assume: assert query_data.get('code') == 0
with assume: assert query_data.get('msg') == '成功'
with assume: assert class_id not in jsonpath.jsonpath(query_data, '$...classId')
with assume: assert query_data.get('data').get('xiZiStatus') is False
@allure.story('学生有在读班级')
@allure.title('验证学生转班,在读班级列表展示正确')
......
......@@ -14,7 +14,7 @@ from script.xin_project_patriarch_app.xin_patriarch_app.xin_patriach_static.xin_
from script.xin_project_patriarch_app.xin_patriarch_app.xin_patriach_static.xin_query_class.xin_auth_class import QueryClass
from script.xin_project_patriarch_app.xin_static.xin_crm.xin_apply.xin_pay_order import PayOrder
from script.xin_project_patriarch_app.xin_static.xin_crm.xin_apply.xin_save_order import SaveOrder
from script.xin_project_patriarch_app.xin_static.xin_crm.xin_student import CreateStudent
from script.xin_project_patriarch_app.xin_static.xin_crm.xin_students.xin_create_studens import CrmCreateStudents
from script.xin_project_patriarch_app.xin_static.xin_educational.xin_class_handle.xin_add_class import CreateClass
from script.xin_project_patriarch_app.xin_static.xin_educational.xin_class_handle.xin_class_attendances.xin_attendances_class import AttendancesClass
from script.xin_project_patriarch_app.xin_static.xin_educational.xin_class_handle.xin_class_schedules.xin_query_class_schedules import QueryClassSchedules
......@@ -35,9 +35,9 @@ class TestStudentsCompletionClass:
def setup_class(self):
self.server = StaticGlobal.SERVER
self.studentPho = '133' + datetime.datetime.now().strftime('%S%f')
students_data = CreateStudent(server=self.server, contactInfo=self.studentPho).create_student()
self.userId = students_data['data']['list'][0]['studentId']
self.headers = AuthHeaders(server=self.server, username=self.studentPho, password='geek1234').get_auth_headers()
# students_data = CreateStudent(server=self.server, contactInfo=self.studentPho).create_student()
students_data = CrmCreateStudents(server=self.server, studentPrimPhoneNo=self.studentPho).create_student()
self.userId = students_data['data']['studentId']
self.create_class_data = [
['主线课程', '极趣班', '常规班课', '数学', '1', '1', 10, '三年级', 9384, 17623669485],
......@@ -118,9 +118,11 @@ class TestStudentsCompletionClass:
schedules_id=schedules_id,
username=self.create_class_data[self.class_list.index(classes_list)][9],
student_id=self.userId,
student_name='小黄测试学生三年级'
student_name='小黄测试学生'
).attendances_class()
self.headers = AuthHeaders(server=self.server, username=self.studentPho).get_auth_headers()
@allure.story('学生结业班级列表')
@allure.title('学生结业七天内,查询结业班级')
@allure.description('学生结业七天内,查询结业班级为空')
......
......@@ -8,7 +8,7 @@ from script.xin_project_patriarch_app.xin_patriarch_app.xin_patriach_static.xin_
from script.xin_project_patriarch_app.xin_patriarch_app.xin_patriach_static.xin_query_class.xin_query_students_class import QueryStudentsClass
from script.xin_project_patriarch_app.xin_static.xin_crm.xin_apply.xin_pay_order import PayOrder
from script.xin_project_patriarch_app.xin_static.xin_crm.xin_apply.xin_save_order import SaveOrder
from script.xin_project_patriarch_app.xin_static.xin_crm.xin_student import CreateStudent
from script.xin_project_patriarch_app.xin_static.xin_crm.xin_students.xin_create_studens import CrmCreateStudents
from script.xin_project_patriarch_app.xin_static.xin_educational.xin_class_handle.xin_add_class import CreateClass
from script.xin_project_patriarch_app.xin_static.xin_educational.xin_class_handle.xin_update_class import UpdateClass
from script.xin_project_patriarch_app.xin_static.xin_educational.xin_course_handle.xin_course import CreateCourse
......@@ -24,8 +24,8 @@ class TestAuthStudentsClassMessage:
def setup_class(self):
self.server = StaticGlobal.SERVER
self.studentPho = '167' + datetime.datetime.now().strftime('%S%f')
students_data = CreateStudent(server=self.server, contactInfo=self.studentPho).create_student()
self.userId = students_data['data']['list'][0]['studentId']
students_data = CrmCreateStudents(server=self.server, studentPrimPhoneNo=self.studentPho).create_student()
self.userId = students_data['data']['studentId']
self.course_id = CreateCourse(server=self.server,
productType='主线课程',
classType='极趣班',
......
import datetime
import time
import allure
import pytest
from pytest_assume.plugin import assume
from common.connect_db import OperationDb
from script.xin_project_patriarch_app.xin_patriarch_app.xin_patriach_static.xin_public_class.xin_global_static import StaticGlobal
from script.xin_project_patriarch_app.xin_static.xin_crm.xin_student import CreateStudent
from script.xin_project_patriarch_app.xin_static.xin_crm.xin_apply.xin_pay_order import PayOrder
from script.xin_project_patriarch_app.xin_static.xin_crm.xin_apply.xin_save_order import SaveOrder
from script.xin_project_patriarch_app.xin_static.xin_crm.xin_students.xin_create_studens import CrmCreateStudents
from script.xin_project_patriarch_app.xin_static.xin_educational.xin_class_handle.xin_add_class import CreateClass
from script.xin_project_patriarch_app.xin_static.xin_educational.xin_course_handle.xin_course import CreateCourse
from script.xin_project_patriarch_app.xin_static.xin_service_user.xin_employees import UpdateEmployees
from script.xin_project_patriarch_app.xin_static.xin_user.xin_patriarch_login import AuthHeaders
......@@ -15,50 +23,111 @@ class TestAuthLogin:
def setup_class(self):
self.server = StaticGlobal.SERVER
UpdateEmployees(server=self.server).update_employees()
self.studentPho = '13364004418'
CreateStudent(server=self.server, contactInfo=self.studentPho).create_student()
self.studentPho = '133' + datetime.datetime.now().strftime('%S%f')
# 新建学生
CrmCreateStudents(server=self.server, studentPrimPhoneNo=self.studentPho).create_student()
@allure.story('登录验证')
@allure.title('用户名密码正确')
@allure.story('学生未买班,登录验证')
@allure.title('学生未购买过班级,用户名密码正确')
@allure.description('用户名密码正确,登录成功')
@allure.step('输入用户名:13364004418,密码:geek1234')
def test_login01(self):
auth_data = AuthHeaders(server=self.server, username='13364004418', password='geek1234').get_auth_token()
with assume: assert auth_data.get('code') == 0
with assume: assert auth_data.get('msg') == '成功'
auth_data = AuthHeaders(server=self.server, username=self.studentPho, password='88888888').get_auth_token()
with assume: assert auth_data.get('code') == 100810000
with assume: assert auth_data.get('msg') == 'APP仅针对极客学员开放,请使用报名预留手机号获取验证码'
@allure.story('登录验证')
@allure.title('用户名正确,密码不正确')
@allure.story('学生未买班,登录验证')
@allure.title('学生未购买过班级,用户名正确,密码不正确')
@allure.description('用户名正确,密码不正确,登录失败')
@allure.step('输入用户名:13364004418,密码:123')
def test_login02(self):
auth_data = AuthHeaders(server=self.server, username='13364004418', password='123').get_auth_token()
with assume: assert auth_data.get('code') != 0
with assume: assert auth_data.get('msg') == '用户名或密码错误!'
auth_data = AuthHeaders(server=self.server, username=self.studentPho, password='123').get_auth_token()
with assume: assert auth_data.get('code') == 100810000
with assume: assert auth_data.get('msg') == '用户不存在或者密码错误,请重新输入。'
@allure.story('登录验证')
@allure.title('用户名错误,密码正确')
@allure.story('学生未买班,登录验证')
@allure.title('学生未购买过班级,用户名错误,密码正确')
@allure.description('用户名错误,密码正确,登录失败')
@allure.step('输入用户名:11111111111,密码:geek1234')
def test_login03(self):
auth_data = AuthHeaders(server=self.server, username='11111111111', password='geek1234').get_auth_token()
with assume: assert auth_data.get('code') != 0
with assume: assert '该手机号未注册' in auth_data.get('msg')
with assume: assert auth_data.get('code') == 100810000
with assume: assert auth_data.get('msg') == '用户不存在或者密码错误,请重新输入。'
@allure.story('登录验证')
@allure.story('学生未买班,登录验证')
@allure.title('用户名密码为空')
@allure.description('用户名密码为空,登录失败')
@allure.step('接口不传用户名和密码')
def test_login04(self):
auth_data = AuthHeaders(server=self.server, username=' ', password=' ').get_auth_token()
with assume: assert auth_data.get('code') != 0
with assume: assert '该手机号未注册' in auth_data.get('msg')
with assume: assert auth_data.get('code') == 100110001
with assume: assert '账号不能为空' in auth_data.get('msg')
with assume: assert '密码不能为空' in auth_data.get('msg')
@allure.story('登录验证')
@allure.story('学生未买班,登录验证')
@allure.title('用户名为中文,密码正确')
@allure.description('用户名为中文,密码正确,登录失败')
@allure.step('用户名为中文,密码正确')
def test_login05(self):
auth_data = AuthHeaders(server=self.server, username='这是中文', password='geek1234').get_auth_token()
with assume: assert auth_data.get('code') != 0
with assume: assert '该手机号未注册' in auth_data.get('msg')
with assume: assert auth_data.get('code') == 100810000
with assume: assert auth_data.get('msg') == '用户不存在或者密码错误,请重新输入。'
@allure.epic('家长APP接口自动化测试')
@allure.feature('登录模块')
class TestAuthBuyClassAndLogin:
def setup_class(self):
self.server = StaticGlobal.SERVER
self.studentPho = '133' + datetime.datetime.now().strftime('%S%f')
# 新建学生
students_data = CrmCreateStudents(server=self.server, studentPrimPhoneNo=self.studentPho).create_student()
self.userId = students_data['data']['studentId']
course_id = CreateCourse(server=self.server,
productType='主线课程',
classType='极思班',
courseType='常规班课',
year=StaticGlobal.YEAR,
term=StaticGlobal.TERM).create_course()['data']['content'][0]['courseId']
class_id = CreateClass(server=self.server, courseId=course_id).create_class()['classId']
order_id = SaveOrder(server=self.server, studentId=self.userId, amount=100, details=[{
"classId": class_id,
"num": 10,
"discountId": "",
"category": "CLASS"
}]).save_order()['data']
# 购买该班级
PayOrder(server=self.server, orderId=order_id, payInfos=[
{
"payChannel": "CASH",
"payAmount": 100
}
]).pay_order()
# 因为入班要走MQ,所以要停留
time.sleep(2)
@allure.story('学生已购买班级,登录验证')
@allure.title('学生已购买班级,用户名密码正确')
@allure.description('用户名密码正确,登录成功')
def test_login06(self):
auth_data = AuthHeaders(server=self.server, username=self.studentPho, password='88888888').get_auth_token()
with assume: assert auth_data.get('code') == 0
with assume: assert auth_data.get('msg') == '成功'
@allure.story('学生已购买班级,登录验证')
@allure.title('学生已购买班级,密码错误')
@allure.description('用户名正确,密码不正确,登录失败')
def test_login07(self):
auth_data = AuthHeaders(server=self.server, username=self.studentPho, password='12345678').get_auth_token()
with assume: assert auth_data.get('code') == 100810000
with assume: assert auth_data.get('msg') == '用户不存在或者密码错误,请重新输入。'
@allure.story('学生已购买班级,登录验证')
@allure.title('极课好学的学生,购买了班级')
@allure.description('用户名正确,密码正确,登录失败')
def test_login08(self):
# 修改学生的状态为极课好学的学生
update_sql = """
UPDATE service_identity.`user` set user.`status`='jkhx' WHERE `user`.phone = {}
""".format(self.studentPho)
OperationDb.execute_mysql(update_sql, Type=False)
auth_data = AuthHeaders(server=self.server, username=self.studentPho, password='88888888').get_auth_token()
with assume: assert auth_data.get('code') == 100810000
with assume: assert '极课好学' in auth_data.get('msg')
import datetime
import time
import allure
import jsonpath
from pytest_assume.plugin import assume
......@@ -6,7 +9,11 @@ from script.base_api import app_students_phoneNumber_mobilePhoneNumberBounding_g
from script.base_api import app_purchaseOrder_studentId_student_count_get, app_course_courseNoticeMessage_post, app_course_recentClassTime_get, examination_app_queryExamination_get
from script.base_api import app_zeGou_queryClassesIsAvailableVideo_post
from script.xin_project_patriarch_app.xin_patriarch_app.xin_patriach_static.xin_public_class.xin_global_static import StaticGlobal
from script.xin_project_patriarch_app.xin_patriarch_app.xin_patriach_static.xin_students_message.xin_query_students_message import QueryStudentsMessage
from script.xin_project_patriarch_app.xin_static.xin_crm.xin_apply.xin_pay_order import PayOrder
from script.xin_project_patriarch_app.xin_static.xin_crm.xin_apply.xin_save_order import SaveOrder
from script.xin_project_patriarch_app.xin_static.xin_crm.xin_students.xin_create_studens import CrmCreateStudents
from script.xin_project_patriarch_app.xin_static.xin_educational.xin_class_handle.xin_add_class import CreateClass
from script.xin_project_patriarch_app.xin_static.xin_educational.xin_course_handle.xin_course import CreateCourse
from script.xin_project_patriarch_app.xin_static.xin_user.xin_patriarch_login import AuthHeaders
......@@ -15,19 +22,46 @@ from script.xin_project_patriarch_app.xin_static.xin_user.xin_patriarch_login im
class TestAuthStudents:
def setup_class(self):
self.server = StaticGlobal.SERVER
self.header = AuthHeaders(server=self.server, username='13364004418', password='geek1234').get_auth_headers()
students_message = QueryStudentsMessage(server=self.server, studentPno='13364004418').query_students_message()
self.student_id = students_message.get('data')[0].get('student').get('id')
self.studentPho = '133' + datetime.datetime.now().strftime('%S%f')
# 新建学生
students_data = CrmCreateStudents(server=self.server, studentPrimPhoneNo=self.studentPho).create_student()
self.student_id = students_data['data']['studentId']
course_id = CreateCourse(server=self.server,
productType='主线课程',
classType='极思班',
courseType='常规班课',
year=StaticGlobal.YEAR,
term=StaticGlobal.TERM).create_course()['data']['content'][0]['courseId']
class_id = CreateClass(server=self.server, courseId=course_id).create_class()['classId']
order_id = SaveOrder(server=self.server, studentId=self.student_id, amount=100, details=[{
"classId": class_id,
"num": 10,
"discountId": "",
"category": "CLASS"
}]).save_order()['data']
# 购买该班级
PayOrder(server=self.server, orderId=order_id, payInfos=[
{
"payChannel": "CASH",
"payAmount": 100
}
]).pay_order()
# 因为入班要走MQ,所以要停留
time.sleep(2)
self.header = AuthHeaders(server=self.server, username=self.studentPho, password='88888888').get_auth_headers()
@allure.story('登录成功验证')
@allure.title('验证查询学生信息正确')
@allure.description('查询学生包含这个学生')
def test_students(self):
students_data = app_students_phoneNumber_mobilePhoneNumberBounding_get(phoneNumber='13364004418', header=self.header, default_assert=False)
students_data = app_students_phoneNumber_mobilePhoneNumberBounding_get(phoneNumber=self.studentPho, header=self.header, default_assert=False)
# print(students_data)
with assume: assert students_data.get('code') == 0
with assume: assert '小黄测试学生三年级' in jsonpath.jsonpath(students_data, '$..name')
for students in jsonpath.jsonpath(students_data, '$...phones'):
with assume: assert students == ['13364004418']
with assume: assert '小黄测试学生' in jsonpath.jsonpath(students_data, '$..name')
# for students in jsonpath.jsonpath(students_data, '$...phones'):
# with assume: assert students == [self.studentPho]
@allure.story('登录成功验证')
@allure.title('查询学生设备绑定关系')
......
......@@ -60,8 +60,3 @@ class courseDetails:
response_data = app_class_classId_alternative_studentId_student_get(classId=self.classId, studentId=self.studentId, header=self.headers, default_assert=False)
return response_data
if __name__ == '__main__':
server_ip = 'http://172.10.62.94'
return_data = courseDetails(server=server_ip, classId=100142250, studentId=10573504).query_course_details()
print(return_data)
from common.common_config import common_config
class StaticGlobal:
YEAR = 2021
TERM = '春'
SCHOOL = 3052
SERVER = 'http://192.168.32.31'
SERVER = 'https://yf1.jkwljy.com'
......@@ -40,8 +40,3 @@ class QueryStudentsClass:
class_data = app_course_getStudentClassDetail_get(params=self.body, header=self.headers, default_assert=False)
return class_data
if __name__ == '__main__':
server_ip = 'http://172.10.62.94'
query_data = QueryStudentsClass(server=server_ip, studentId=10573494, classId=100142234, username=13312145220).query_student_class()
print(query_data)
......@@ -22,7 +22,3 @@ class QueryStudentsMessage:
def query_students_message(self):
students_data = students_phoneNumber_mobilePhoneNumberBounding_get(phoneNumber=self.studentPno, header=self.headers, default_assert=False)
return students_data
if __name__ == '__main__':
print(QueryStudentsMessage(server='http://172.10.62.94', studentPno=13312152205).query_students_message())
import datetime
from script.base_api import student_all_items_post
from script.base_api.api_operation_web.pay import pay_post
from script.base_api.api_operation_web.order import order_saveOrder_post
from script.xin_project_patriarch_app.xin_static.xin_crm.xin_student import CreateStudent
from script.xin_project_patriarch_app.xin_static.xin_educational.xin_class_handle.xin_add_class import CreateClass
from script.xin_project_patriarch_app.xin_static.xin_educational.xin_course_handle.xin_course import CreateCourse
from script.xin_project_patriarch_app.xin_static.xin_service.xin_service import Service_get
from script.xin_project_patriarch_app.xin_static.xin_user.xin_jky_pc_login import Headers
class PlaceOrder:
def __init__(self, server,
header,
username=None,
password=None,
studentId=None):
studentId=None,
school_id=None,
classId=None):
self.server = server
# self.sava_order_url = '/api-operation-web/order/saveOrder'
# self.pay_url = '/api-operation-web/pay'
self.username = username
self.password = password
self.studentId = studentId
self.header = Headers(server=self.server, username=self.username, password=self.password).get_headers()
self.school_id = school_id
self.classId = classId
self.header = header
# self.header = Headers(server=self.server, username=self.username, password=self.password).get_headers()
self.sava_body = {
"studentId": self.studentId,
"schoolArea": 3100,
"schoolArea": self.school_id or 3100,
"details": [
# {
# "classId": 100141010,
......@@ -30,7 +40,7 @@ class PlaceOrder:
# "category": "CLASS"
# },
{
"classId": 100141011,
"classId": self.classId or 100141011,
"num": 10,
"discountId": "",
"category": "CLASS"
......@@ -44,33 +54,66 @@ class PlaceOrder:
}
def price_order(self):
# sava_data = requests.post(url=self.server + self.sava_order_url, json=self.sava_body, headers=self.header, verify=False).json()['data']
sava_data = order_saveOrder_post(header=self.header, body=self.sava_body, params='recommit-ticket=undefined', default_assert=False)['data']
pay_body = {
"orderId": str(sava_data),
"operatorId": 9384,
"operatorType": "STAFF",
"remark": "",
"payInfos": [
{
"payChannel": "CASH",
"payAmount": 100
}
]
}
pay_data = pay_post(body=pay_body, header=self.header)
return pay_data.json()
try:
# sava_data = requests.post(url=self.server + self.sava_order_url, json=self.sava_body, headers=self.header, verify=False).json()['data']
sava_data = order_saveOrder_post(header=self.header, body=self.sava_body, params='recommit-ticket=undefined', default_assert=False)['data']
pay_body = {
"orderId": str(sava_data),
"operatorId": 9384,
"operatorType": "STAFF",
"remark": "",
"payInfos": [
{
"payChannel": "CASH",
"payAmount": 100
}
]
}
pay_data = pay_post(body=pay_body, header=self.header)
return pay_data
except Exception as e:
print(e)
return {'code': -1}
if __name__ == '__main__':
server_ip = Service_get.service_content('36')
for i in range(10000):
studentName = '小黄测试学生' + str(i)
studentPho = '133' + datetime.datetime.now().strftime('%d%H%M%S')
student_id = CreateStudent(server=server_ip, studentName=studentName, publicGrade='五年级', contactInfo=studentPho).create_student()['data']['list'][0]['studentId']
print(f"{studentName}-->学生创建成功!")
place_order = PlaceOrder(server=server_ip, studentId=student_id).price_order()
schools = [{"area": 2390, "schoolArea": 3148}]
query_student = {"schoolAreaIds": [3100, 2391, 2392, 2403, 2412, 2413, 3046, 3148, 3352, 3376, 3377, 2402, 2404, 2405, 2406, 2411, 3067], "studentStatus": 1110, "year": 2021, "term": "暑", "courseType": "",
"pageNum": 1,
"pageSize": 20000}
headers = Headers(server=server_ip).get_headers()
all_student = student_all_items_post(body=query_student, header=headers).get('data').get('list')
count = 0
class_id = ''
for students in all_student:
if count % 10 == 0:
course_id = CreateCourse(server=server_ip,
classType='五四极趣班',
courseType='常规班课',
productType='主线课程',
grade='五年级',
registerGrade='五年级',
term='暑',
schools=schools).create_course()['data']['content'][0]['courseId']
class_id = CreateClass(server=server_ip, courseId=course_id, schoolArea=3148).create_class()['classId']
place_order = PlaceOrder(server=server_ip, studentId=students.get('studentId'), school_id=3140, classId=class_id, header=headers).price_order()
if place_order['code'] == 0 and place_order['msg'] == '成功':
print(f"{studentName}-->购课成功!")
print(f"{students.get('studentName')}-->购课成功!")
else:
print(f"{studentName}-->购课失败!{place_order}")
print(f"{students.get('studentName')}-->购课失败!{place_order}")
count += 1
# for j in range(10):
# studentName = '小黄测试学生' + str(i)
# studentPho = '133' + datetime.datetime.now().strftime('%d%H%M%S')
# student_id = CreateStudent(server=server_ip, studentName=studentName, publicGrade='六年级', contactInfo=studentPho, createSchoolAreaId=3148).create_student()['data']['list'][0]['studentId']
# print(f"{studentName}-->学生创建成功!")
# place_order = PlaceOrder(server=server_ip, studentId=student_id, school_id=3140, classId=class_id).price_order()
# if place_order['code'] == 0 and place_order['msg'] == '成功':
# print(f"{studentName}-->购课成功!")
# else:
# print(f"{studentName}-->购课失败!{place_order}")
......@@ -185,7 +185,3 @@ class DeleteStudent:
# delete_data = requests.delete(url=self.server + delete_url, json=self.student, headers=self.header, verify=False)
return delete_data.json()
if __name__ == '__main__':
print(CreateStudent(server=Service_get.service_content('94'), studentName='阿黄测试11').create_student())
# print(DeleteStudent(server=Service_get.service_content('94'), student=[377963]).delete_student())
"""
@encoding: utf-8
@Author: LiuHangXin
@Time: 2021/5/19
"""
"""
@encoding: utf-8
@Author: LiuHangXin
@Time: 2021/5/19
"""
import allure
import requests
from common.connect_db import OperationDb
from script.xin_project_patriarch_app.xin_static.xin_user.xin_jky_pc_login import Headers
"""
报名-新建学生
"""
class CrmCreateStudents:
def __init__(self, server, **kwargs):
self.server = server
self.username = kwargs.get('username')
self.password = kwargs.get('password')
self.url = '/api-operation-web/student/add'
self.body = {
"studentName": kwargs.get('studentName') or "小黄测试学生",
"studentSex": kwargs.get('studentSex') or "-",
"studentSource": kwargs.get('studentSource') or "营销活动",
"sourceIdFirst": kwargs.get('sourceIdFirst') or 102,
"studentPrimPhoneNo": kwargs.get('studentPrimPhoneNo') or '13364004418',
"primBelong": kwargs.get('primBelong') or "外婆",
"studentSecondaryPhoneNo": kwargs.get('studentSecondaryPhoneNo') or "",
"secondaryBelong": kwargs.get('secondaryBelong') or "",
"attendSchoolId": kwargs.get('attendSchoolId') or 13130,
"attendSchool": kwargs.get('attendSchool') or "成都市草堂小学子美分校",
"attendGrade": kwargs.get('attendGrade') or "三年级",
"attendClass": kwargs.get('attendClass') or "",
"attendTeacher": kwargs.get('attendTeacher') or "",
"birthday": kwargs.get('birthday') or "",
"introducer": kwargs.get('introducer') or "",
"introducerId": kwargs.get('introducerId') or "",
"introducerNo": kwargs.get('introducerNo') or "",
"homeProvinceId": kwargs.get('homeProvinceId') or "",
"homeCityId": kwargs.get('homeCityId') or "",
"homeDistrictId": kwargs.get('homeDistrictId') or "",
"homeCountyId": kwargs.get('homeCountyId') or "",
"homeAddress": kwargs.get('homeAddress') or "",
"city": kwargs.get('city') or 510100,
"entrancePaper": kwargs.get('entrancePaper') or "",
"score": kwargs.get('score') or "",
"schoolArea": kwargs.get('schoolArea') or 3052,
"remark": kwargs.get('remark') or "",
"primUserId": kwargs.get('primUserId') or "",
"secondUserId": kwargs.get('secondUserId') or "",
"firstUserPhone": kwargs.get('studentPrimPhoneNo') or '13364004418',
"firstUserIdentity": kwargs.get('firstUserIdentity') or "外婆",
"secondUserPhone": kwargs.get('secondUserPhone') or "",
"secondUserIdentity": kwargs.get('secondUserIdentity') or ""
}
self.header = Headers(server=self.server, username=self.username, password=self.password).get_headers()
@allure.step("极运营/报名/新建学生")
def create_student(self):
try:
student_data = requests.post(url=self.server + self.url, json=self.body, headers=self.header, verify=False).json()
# 获取学生的id
studentId = student_data.get('data').get('studentId')
# 新建学生没有密码,给学生添加密码
# 查询学生的prim_user_id
student_data_sql = """
select t1.prim_user_id
from service_profile.student t1
where t1.student_id = '{}'
""".format(studentId)
# 修改用户的密码
students = OperationDb.query_sql(student_data_sql)
# print(students[0][0])
sql_data = """
update service_identity.user_channel_info t2 set credential = '099b83907f50f1ef1e4217692b0a24e027ea2482507470b42fdaca353313ac6ccc8a1597fd4f9187a2063ab3a356095d55aa8b013f583b3811fffa89d79e1696'
where user_id = '{}'
""".format(students[0][0])
OperationDb.execute_mysql(sql_data, Type=False)
return student_data
except Exception as e:
return str(e)
import jsonpath
from script.base_api import education_classes_add_post, education_courses_query_post, education_classes_query_post
from script.xin_project_patriarch_app.xin_static.xin_educational.xin_course_handle.xin_course import CreateCourse
from script.xin_project_patriarch_app.xin_static.xin_service.xin_service import Service_get
from script.xin_project_patriarch_app.xin_static.xin_time import Time_get
from script.xin_project_patriarch_app.xin_static.xin_user.xin_jky_pc_login import Headers
......@@ -131,8 +129,3 @@ class CreateClass:
return query_class.get('data').get('list')[0]
else:
return add_class_data
if __name__ == '__main__':
course_id = CreateCourse(server=Service_get.service_content('94')).create_course()['data']['content'][0]['courseId']
print(CreateClass(server=Service_get.service_content('94'), courseId=course_id).create_class()['classId'])
......@@ -20,8 +20,3 @@ class DeleteClass:
delete_msg = education_classes_delete_post(body=self.classes, header=self.headers, default_assert=False)
return delete_msg
if __name__ == '__main__':
server_ip = 'http://172.10.62.94'
delete_data = DeleteClass(server=server_ip, classes=[100142200]).delete_class()
print(delete_data)
......@@ -161,8 +161,3 @@ class UpdateClass:
}
return education_classes_update_post(body=dict(data, **self.body), header=self.headers, default_assert=False)
if __name__ == '__main__':
server_ip = 'http://172.10.62.94'
return_data = UpdateClass(server=server_ip, classId=100142200).update_class_schedule('111')
print(return_data)
......@@ -159,7 +159,3 @@ class DeleteCourse:
def delete_course(self):
delete_data = education_courses_delete_post(body=self.course, header=self, default_assert=False, return_json=False)
return delete_data.json()
if __name__ == '__main__':
print(CreateCourse(server=Service_get.service_content('94')).create_course()['data']['content'][0]['courseId'])
......@@ -206,9 +206,3 @@ class StopOrStartCourse:
def stop_or_start_course(self):
return education_courses_startOrStop_put(body=self.course_data, header=self.headers)
if __name__ == '__main__':
server_ip = 'http://172.10.62.94'
return_data = UpdateCoursePrice(server=server_ip, courseId=10035293, coursePrice=100).update_course_price()
print(return_data)
......@@ -24,8 +24,3 @@ class UpdateEmployees:
return update_data
else:
return update_data
if __name__ == '__main__':
return_data = UpdateEmployees('http://172.10.62.94').update_employees()
print(return_data)
......@@ -147,7 +147,3 @@ class DiscountsCoupon:
self.body.pop('operator')
self.body.pop('issueType')
return requests.post(url=self.server + edit_url, json=dict(edit_data, **self.body), headers=self.header, verify=False).json()
if __name__ == '__main__':
print(DiscountsCoupon(server=Service_get.service_content('94'), remark='编辑优惠券').edit_discounts_coupon(coupon_id=11577))
......@@ -193,11 +193,3 @@ class DiscountsEvent:
"id": event_id
}
return requests.post(url=self.server + edit_url, json=dict(edit_data, **self.body), headers=self.header, verify=False).json()
if __name__ == '__main__':
"""
requests.post(url=self.server + self.url, json=dict(continue_data, **self.body), headers=self.header, verify=False).json()
"""
print(DiscountsEvent(server=Service_get.service_content('94')).edit_discount_event(event_id=10001562))
# print(DiscountsEvent(server=Service_get.service_content('94'), discountName='启用').boutique_discounts())
import requests
from script.base_api import departments_school_post
from script.xin_project_patriarch_app.xin_static.xin_service.xin_service import Service_get
from script.xin_project_patriarch_app.xin_static.xin_user.xin_jky_pc_login import Headers
......@@ -58,29 +55,3 @@ class School:
data['sectionSetting'] = 0
data.pop('sectionValue')
return data
if __name__ == '__main__':
print(School(server=Service_get.service_content('36'), body=School.param(sectionSetting=1, sectionValue=[
{"term": "秋", "upRegisterDeadline": "2021/01/27 23:59:59", "registerDeadline": "2022/2/28 23:59:59"},
{"term": "寒", "upRegisterDeadline": "2020/10/30 23:59:59", "registerDeadline": "2020/10/31 23:59:59"},
{"term": "春", "upRegisterDeadline": "2021/03/27 23:59:59", "registerDeadline": "2021/04/30 23:59:59"},
{"term": "暑", "upRegisterDeadline": "2021/01/27 23:59:59", "registerDeadline": "2021/01/30 23:59:59"},
])).school_update())
# print(School.param(sectionValue=[
# {"term": "秋", "upRegisterDeadline": "2021/01/27 23:59:59", "registerDeadline": "2021/2/28 23:59:59"},
# {"term": "寒", "upRegisterDeadline": "2020/10/30 23:59:59", "registerDeadline": "2020/10/31 23:59:59"},
# {"term": "春", "upRegisterDeadline": "2021/03/27 23:59:59", "registerDeadline": "2021/04/30 23:59:59"},
# {"term": "暑", "upRegisterDeadline": "2021/01/27 23:59:59", "registerDeadline": "2021/01/30 23:59:59"},
# ]))
"""
这是是否连报设置
"communiqueRule": {
"grade": ["零年级", "一年级"],
"platform": ["app"],
"subject": ["语文", "英语"],
"term": "秋",
"signInTime": ["2021-03-15 00:00:00", "2021-04-14 00:00:00"],
"beginDate": "2021-03-15 00:00:00", "endDate": "2021-04-14 00:00:00"
}
"""
......@@ -87,7 +87,3 @@ class Headers:
return self.get_token(AddUser=True)
except TypeError:
return self.get_token()
if __name__ == '__main__':
print(Headers(server='http://172.10.62.94').get_headers())
......@@ -13,14 +13,14 @@ class AuthHeaders:
def __init__(self, server, username, password=None):
self.server = server
self.username = username
self.password = password or 'geek1234'
self.password = password or '88888888'
self.body = {
"account": self.username,
"password": self.password,
"code": "",
"type": "customer"
}
self.url = '/service-user/app/auth'
self.url = '/api-jksxb-app/user/login/by/account'
"""
获取家长端APP的登录信息
......@@ -73,8 +73,3 @@ class AuthHeaders:
WriteYaml.write_yaml_data(r'\xin_static\xin_user\patriarch_user', content)
# print(headers)
return headers
if __name__ == '__main__':
server_ip = 'http://172.10.62.94'
AuthHeaders(server=server_ip, username='13364004418', password='geek1234').get_auth_headers()
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