def setUp(self):
     #智能练习数据分析和智能练习明细数据
     self.url_token = login_token()  #获取登陆的token
     self.url_getInfo = 'https://shuju.zhihuotech.com/api/getInfo'  #获取地区
     self.url_getBasic = 'https://shuju.zhihuotech.com/api/system/correct_overview/record/getBasic'  #数据分析顶部数据展示
     self.url_getTrend = 'https://shuju.zhihuotech.com/api/system/correct_overview/record/getTrend'  #智能练习时间范围内数据展示
     self.url_getCurrentUserArea = 'https://shuju.zhihuotech.com/api/system/user/getCurrentUserArea'  #使用明细获取地址
     self.url_get_current_user_school = 'https://shuju.zhihuotech.com/api/system/smart_exercise_detail/get_current_user_school'  #获取学校名单
     self.url_get_log_exam_batch_detail = 'https://shuju.zhihuotech.com/api/system/smart_exercise_detail/get_log_exam_batch_detail'  #组题老师数
     self.url_get_teacher_print_detail = 'https://shuju.zhihuotech.com/api/system/smart_exercise_detail/get_teacher_print_detail'  #打印教师数
     self.url_get_teacher_report_detail = 'https://shuju.zhihuotech.com/api/system/smart_exercise_detail/get_teacher_report_detail'  #批改教师数
     self.url_get_student_report_detail = 'https://shuju.zhihuotech.com/api/system/smart_exercise_detail/get_student_report_detail'  #批改学生数
     self.url_getBase = 'https://shuju.zhihuotech.com/api/pay_business/analysis/getBase'  #首页
     self.url_pieChart = 'https://shuju.zhihuotech.com/api/system/logpayment/pieChart'  #产品包
     self.url_basic = 'https://shuju.zhihuotech.com/api/log/attained/record/basic'  #达标用户数和累计达标率
     self.url_trend = 'https://shuju.zhihuotech.com/api/log/attained/record/trend'  #付费人数
     print('开始执行用例')
    def test_trend(self):
        header = {
            'Host':
            'shuju.zhihuotech.com',
            'Connection':
            'keep-alive',
            'Accept':
            'application/json, text/plain, */*',
            'Authorization':
            'Bearer {}'.format(login_token()),
            'User-Agent':
            'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.113 Safari/537.36',
            'Sec-Fetch-Site':
            'same-origin',
            'Sec-Fetch-Mode':
            'cors',
            'Sec-Fetch-Dest':
            'empty',
            'Referer':
            'https://shuju.zhihuotech.com/business/analysis',
            'Accept-Encoding':
            'gzip, deflate, br',
            'Accept-Language':
            'zh-CN,zh;q=0.9',
            'cookie':
            'rememberMe=true; username=chendong1; password=QftoLO93wbnGrNuHS24EiZUXB+Jb77bs2VCd58EbrnC1Xwk50cd/ZTeDx5gWGhji3w8ENHLM/o8caUqtME/Z5g==; Admin-Token=eyJhbGciOiJIUzUxMiJ9.eyJsb2dpbl91c2VyX2tleSI6IjZmNTAyOThmLWQxOWItNDkzYS04ZTZkLTIyYzE3MDUxNGE2NSJ9.q1PkE_tXwbVDrmIHTIvq_y_-RAOuyIkLVZ-xgIx2yWv23emcF5GjzKcKw3oXG9rYHHMExgFVKabJI6aTIdRlWw'
        }
        params_data = {
            'timeType': '0',
            'startDate': '2020-05-04',
            'endDate': '2020-05-11'
        }
        requests.packages.urllib3.disable_warnings()  # 去除警示提示
        r = requests.get(url=self.url_trend,
                         headers=header,
                         params=params_data,
                         verify=False)
        resuit = r.json()
        print(r.text)

        self.assertEqual(resuit['code'], 200, '每日付费人数失败')
        self.assertEqual(resuit['msg'], '操作成功', '每日付费人数失败')
        self.assertTrue('2020-05-04' in r.text, '每日付费人数失败')  # 每日付费人数日期
Example #3
0
import requests
from test_api.Data_platform.test_login_token import login_token
#数据分析顶部数据展示
url = 'https://shuju.zhihuotech.com/api/system/correct_overview/record/getBasic'
header = {
    'Host':
    'shuju.zhihuotech.com',
    'Connection':
    'keep-alive',
    'Accept':
    'application/json, text/plain, */*',
    'Authorization':
    'Bearer {}'.format(login_token()),
    'User-Agent':
    'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.113 Safari/537.36',
    'Sec-Fetch-Site':
    'same-origin',
    'Sec-Fetch-Mode':
    'cors',
    'Sec-Fetch-Dest':
    'empty',
    'Referer':
    'https://shuju.zhihuotech.com/business/analysis',
    'Accept-Encoding':
    'gzip, deflate, br',
    'Accept-Language':
    'zh-CN,zh;q=0.9',
    'cookie':
    'rememberMe=true; username=chendong1; password=QftoLO93wbnGrNuHS24EiZUXB+Jb77bs2VCd58EbrnC1Xwk50cd/ZTeDx5gWGhji3w8ENHLM/o8caUqtME/Z5g==; Admin-Token=eyJhbGciOiJIUzUxMiJ9.eyJsb2dpbl91c2VyX2tleSI6IjZmNTAyOThmLWQxOWItNDkzYS04ZTZkLTIyYzE3MDUxNGE2NSJ9.q1PkE_tXwbVDrmIHTIvq_y_-RAOuyIkLVZ-xgIx2yWv23emcF5GjzKcKw3oXG9rYHHMExgFVKabJI6aTIdRlWw'
}
Example #4
0
import requests
from test_api.Data_platform.test_login_token import  login_token

#达标用户数和累计达标率
url = 'https://shuju.zhihuotech.com/api/log/attained/record/basic'
header = {
        'Host': 'shuju.zhihuotech.com',
        'Connection': 'keep-alive',
        'Accept': 'application/json, text/plain, */*',
        'Authorization': 'Bearer {}'.format(login_token()),
        'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.113 Safari/537.36',
        'Sec-Fetch-Site': 'same-origin',
        'Sec-Fetch-Mode': 'cors',
        'Sec-Fetch-Dest': 'empty',
        'Referer': 'https://shuju.zhihuotech.com/business/analysis',
        'Accept-Encoding': 'gzip, deflate, br',
        'Accept-Language':'zh-CN,zh;q=0.9',
        'cookie': 'rememberMe=true; username=chendong1; password=QftoLO93wbnGrNuHS24EiZUXB+Jb77bs2VCd58EbrnC1Xwk50cd/ZTeDx5gWGhji3w8ENHLM/o8caUqtME/Z5g==; Admin-Token=eyJhbGciOiJIUzUxMiJ9.eyJsb2dpbl91c2VyX2tleSI6IjZmNTAyOThmLWQxOWItNDkzYS04ZTZkLTIyYzE3MDUxNGE2NSJ9.q1PkE_tXwbVDrmIHTIvq_y_-RAOuyIkLVZ-xgIx2yWv23emcF5GjzKcKw3oXG9rYHHMExgFVKabJI6aTIdRlWw'
    }

requests.packages.urllib3.disable_warnings()#去除警示提示
r = requests.get(url=url,headers=header,params=None,verify=False)
print(r.url)#传递url参数
print(r.text)#想要内容
print(r.status_code)#状态码