Commit 6d2fc240 by linguangwei

请求头添加enterpriseId,并且设置各个请求头参数为变量,在config.ini中设置

parent f777a8f2
......@@ -4,12 +4,12 @@
<option name="autoReloadType" value="SELECTIVE" />
</component>
<component name="ChangeListManager">
<list default="true" id="00f4febb-36b6-426d-bfe6-b023876a617e" name="Default Changelist" comment="添加本地文件路径区分mac/windows">
<list default="true" id="00f4febb-36b6-426d-bfe6-b023876a617e" name="Default Changelist" comment="增加了调试中的切换环境方法">
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/main.py" beforeDir="false" afterPath="$PROJECT_DIR$/main.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/config/config.ini" beforeDir="false" afterPath="$PROJECT_DIR$/config/config.ini" afterDir="false" />
<change beforePath="$PROJECT_DIR$/config/readConfig.py" beforeDir="false" afterPath="$PROJECT_DIR$/config/readConfig.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/framework/common.py" beforeDir="false" afterPath="$PROJECT_DIR$/src/framework/common.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/pageobject/basepage.py" beforeDir="false" afterPath="$PROJECT_DIR$/src/pageobject/basepage.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/pageobject/loginpage.py" beforeDir="false" afterPath="$PROJECT_DIR$/src/pageobject/loginpage.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/testcase/test_LoginPage.py" beforeDir="false" afterPath="$PROJECT_DIR$/src/testcase/test_LoginPage.py" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
......@@ -162,7 +162,7 @@
<recent name="C:\Users\Administrator\PycharmProjects\xm-uitest-live" />
</key>
</component>
<component name="RunManager" selected="Python tests.pytest for test_LoginPage.TestLoginPage.testLogin">
<component name="RunManager" selected="Python.demo">
<configuration name="demo" type="PythonConfigurationType" factoryName="Python" temporary="true" nameIsGenerated="true">
<module name="xm-uitest-live" />
<option name="INTERPRETER_OPTIONS" value="" />
......@@ -184,29 +184,23 @@
<option name="INPUT_FILE" value="" />
<method v="2" />
</configuration>
<configuration name="main" type="PythonConfigurationType" factoryName="Python" temporary="true" nameIsGenerated="true">
<configuration name="pytest for test_LoginPage.TestLoginPage" type="tests" factoryName="py.test" temporary="true" nameIsGenerated="true">
<module name="xm-uitest-live" />
<option name="INTERPRETER_OPTIONS" value="" />
<option name="PARENT_ENVS" value="true" />
<envs>
<env name="PYTHONUNBUFFERED" value="1" />
</envs>
<option name="SDK_HOME" value="" />
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/src/testcase" />
<option name="IS_MODULE_SDK" value="true" />
<option name="ADD_CONTENT_ROOTS" value="true" />
<option name="ADD_SOURCE_ROOTS" value="true" />
<EXTENSION ID="PythonCoverageRunConfigurationExtension" runner="coverage.py" />
<option name="SCRIPT_NAME" value="$PROJECT_DIR$/main.py" />
<option name="PARAMETERS" value="" />
<option name="SHOW_COMMAND_LINE" value="false" />
<option name="EMULATE_TERMINAL" value="false" />
<option name="MODULE_MODE" value="false" />
<option name="REDIRECT_INPUT" value="false" />
<option name="INPUT_FILE" value="" />
<option name="_new_keywords" value="&quot;&quot;" />
<option name="_new_parameters" value="&quot;&quot;" />
<option name="_new_additionalArguments" value="&quot;&quot;" />
<option name="_new_target" value="&quot;test_LoginPage.TestLoginPage&quot;" />
<option name="_new_targetType" value="&quot;PYTHON&quot;" />
<method v="2" />
</configuration>
<configuration name="pytest for test_LoginPage.TestLoginPage" type="tests" factoryName="py.test" temporary="true" nameIsGenerated="true">
<configuration name="pytest for test_LoginPage.TestLoginPage.testLogin" type="tests" factoryName="py.test" temporary="true" nameIsGenerated="true">
<module name="xm-uitest-live" />
<option name="INTERPRETER_OPTIONS" value="" />
<option name="PARENT_ENVS" value="true" />
......@@ -218,11 +212,11 @@
<option name="_new_keywords" value="&quot;&quot;" />
<option name="_new_parameters" value="&quot;&quot;" />
<option name="_new_additionalArguments" value="&quot;&quot;" />
<option name="_new_target" value="&quot;test_LoginPage.TestLoginPage&quot;" />
<option name="_new_target" value="&quot;test_LoginPage.TestLoginPage.testLogin&quot;" />
<option name="_new_targetType" value="&quot;PYTHON&quot;" />
<method v="2" />
</configuration>
<configuration name="pytest for test_LoginPage.TestLoginPage.testLogin" type="tests" factoryName="py.test" temporary="true" nameIsGenerated="true">
<configuration name="pytest for test_WhiteBoardPage.TestLivePage" type="tests" factoryName="py.test" temporary="true" nameIsGenerated="true">
<module name="xm-uitest-live" />
<option name="INTERPRETER_OPTIONS" value="" />
<option name="PARENT_ENVS" value="true" />
......@@ -234,11 +228,11 @@
<option name="_new_keywords" value="&quot;&quot;" />
<option name="_new_parameters" value="&quot;&quot;" />
<option name="_new_additionalArguments" value="&quot;&quot;" />
<option name="_new_target" value="&quot;test_LoginPage.TestLoginPage.testLogin&quot;" />
<option name="_new_target" value="&quot;test_WhiteBoardPage.TestLivePage&quot;" />
<option name="_new_targetType" value="&quot;PYTHON&quot;" />
<method v="2" />
</configuration>
<configuration name="pytest for test_MainPage.TestMainPage.test_2_StartLive" type="tests" factoryName="py.test" temporary="true" nameIsGenerated="true">
<configuration name="pytest for test_WhiteBoardPage.TestLivePage.testWhiteBoard" type="tests" factoryName="py.test" temporary="true" nameIsGenerated="true">
<module name="xm-uitest-live" />
<option name="INTERPRETER_OPTIONS" value="" />
<option name="PARENT_ENVS" value="true" />
......@@ -250,17 +244,17 @@
<option name="_new_keywords" value="&quot;&quot;" />
<option name="_new_parameters" value="&quot;&quot;" />
<option name="_new_additionalArguments" value="&quot;&quot;" />
<option name="_new_target" value="&quot;test_MainPage.TestMainPage.test_2_StartLive&quot;" />
<option name="_new_target" value="&quot;test_WhiteBoardPage.TestLivePage.testWhiteBoard&quot;" />
<option name="_new_targetType" value="&quot;PYTHON&quot;" />
<method v="2" />
</configuration>
<recent_temporary>
<list>
<item itemvalue="Python.demo" />
<item itemvalue="Python tests.pytest for test_WhiteBoardPage.TestLivePage.testWhiteBoard" />
<item itemvalue="Python tests.pytest for test_WhiteBoardPage.TestLivePage" />
<item itemvalue="Python tests.pytest for test_LoginPage.TestLoginPage.testLogin" />
<item itemvalue="Python tests.pytest for test_LoginPage.TestLoginPage" />
<item itemvalue="Python.demo" />
<item itemvalue="Python.main" />
<item itemvalue="Python tests.pytest for test_MainPage.TestMainPage.test_2_StartLive" />
</list>
</recent_temporary>
</component>
......@@ -451,7 +445,14 @@
<option name="project" value="LOCAL" />
<updated>1625562469198</updated>
</task>
<option name="localTasksCounter" value="25" />
<task id="LOCAL-00025" summary="增加了调试中的切换环境方法">
<created>1625640405518</created>
<option name="number" value="00025" />
<option name="presentableId" value="LOCAL-00025" />
<option name="project" value="LOCAL" />
<updated>1625640405518</updated>
</task>
<option name="localTasksCounter" value="26" />
<servers />
</component>
<component name="TestHistory">
......@@ -566,7 +567,8 @@
<MESSAGE value="判断当前系统是否为Windows或者darwin(mac)(当前只有两钟系统)" />
<MESSAGE value="review" />
<MESSAGE value="添加本地文件路径区分mac/windows" />
<option name="LAST_COMMIT_MESSAGE" value="添加本地文件路径区分mac/windows" />
<MESSAGE value="增加了调试中的切换环境方法" />
<option name="LAST_COMMIT_MESSAGE" value="增加了调试中的切换环境方法" />
</component>
<component name="editorHistoryManager">
<entry file="file://$PROJECT_DIR$/server.log" />
......
......@@ -17,6 +17,9 @@ env = prod
username = 13777867342
password = 0000
[header_require]
lgw-b = {"userId":"1394908740376522754","storeId":"1211601438838495999","storeUserId":"1394257952460828673","enterpriseId":"1398199018246803458"}
[MySql]
[chrome download]
......
import configparser
import os
import json
import platform
......@@ -31,3 +32,8 @@ def test_account():
def test_password():
return config.get("account", "password")
def test_header():
return_test = config.get("header_require", "lgw_header")
return json.loads(return_test)
......@@ -84,6 +84,11 @@ def get_token():
# 创建一个直播课,返回课程id和课程名称
def create_a_live(start_time, start_time2=None):
xmtoken = get_token()
basic_imforation = readConfig.test_header()
userId = basic_imforation['userId']
storeId =basic_imforation['storeId']
storeUserId =basic_imforation['storeUserId']
enterpriseId = basic_imforation['enterpriseId']
while xmtoken == "登录过频繁":
# 休息5s是因为可能会登录频繁
time.sleep(15)
......@@ -97,28 +102,29 @@ def create_a_live(start_time, start_time2=None):
courseName = ''.join(random.sample(string.ascii_letters + string.digits, 8))
courseName2 = ''.join(random.sample(string.ascii_letters + string.digits, 8))
url = "https://gateway.xiaomai5.com/hades/public/courseCloud/createLiveCloudCourse?storeId=1211601438838495999" \
"&token={}&storeUserId=1394257952460828673&userId=1394908740376522754".format(xmtoken)
"&token={}&storeUserId={}&userId={}".format(xmtoken, storeUserId, userId)
params = {"adminIds": [], "calendarTime": [calendarTime], "categoryId": "1386892090935164929",
"endTime": endTime, "needRecord": "YES", "startTime": startTime,
"courseName": courseName, "storeId": "1211601438838495999", "teacherId": "1394908740376522754",
"whetherVisitorsJoin": "NO", "scheduleMediaRequests": [], "operatorId": "1394908740376522754"}
"courseName": courseName, "storeId": "{}", "teacherId": "{}",
"whetherVisitorsJoin": "NO", "scheduleMediaRequests": [], "operatorId": "{}".format(storeId, userId, userId)}
data = json.dumps(params)
headers = {"Content-Type": "application/json; charset=UTF-8",
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) "
"Chrome/91.0.4472.77 Safari/537.36",
"storeId": "1211601438838495999",
"storeUserId": "1394257952460828673",
"storeId": storeId,
"storeUserId": storeUserId,
"xmtoken": xmtoken,
"userId": "1394908740376522754",
"product": "xmCloudClass"}
"userId": userId,
"product": "xmCloudClass",
"enterpriseId": enterpriseId}
r = requests.post(url=url, data=data, headers=headers)
if start_time2 is not None:
time.sleep(2)
startTime2 = now_time() + start_time2*60*1000
params2 = {"adminIds": [], "calendarTime": [calendarTime], "categoryId": "1386892090935164929",
"endTime": endTime, "needRecord": "YES", "startTime": startTime2,
"courseName": courseName2, "storeId": "1211601438838495999", "teacherId": "1394908740376522754",
"whetherVisitorsJoin": "NO", "scheduleMediaRequests": [], "operatorId": "1394908740376522754"}
"courseName": courseName2, "storeId": storeId, "teacherId": userId,
"whetherVisitorsJoin": "NO", "scheduleMediaRequests": [], "operatorId": userId}
data2 = json.dumps(params2)
r2 = requests.post(url=url, data=data2, headers=headers)
try:
......
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