示例#1
0
import unittest
import requests
import os,sys
sys.path.append('C:\\Users\\Administrator\\Desktop\\exam_api_test\\interpace\\check_pswd')
import check_pswd
import time
import json
import FetchCorrectTask
import SaveCorrectResult
import GetCorrectStaByTeacher
result,cookies=check_pswd.check_pswd('10031108','123456')

class Task_taskRead(unittest.TestCase):
	def setUp(self):
		'''没什么用'''
		self.examId=50004699
	def test_success(self):
		GetCorrectStaByTeacher_data={
				'examId':self.examId
		}
		#获取这场考试的itemid  并将第一场传给Fetch接口
		itemIds=GetCorrectStaByTeacher.GetCorrectStaByTeacher(params=GetCorrectStaByTeacher_data,cookies=cookies)
		itemIds=iter(itemIds)
		itemId=next(itemIds)
		print(itemId)

		while True:
			taskId=FetchCorrectTask.FetchCorrectTask(examId=self.examId,itemId=itemId,cookies=cookies)#调用接口,获取返回的taskid作为save接口的参数			
			Save_data={
				'taskId':taskId,
				'score':1,
import unittest
import requests
import os, sys
sys.path.append(
    'C:\\Users\\Administrator\\Desktop\\exam_api_test\\interpace\\check_pswd')
import check_pswd
import time
import json

result, cookies = check_pswd.check_pswd('13909908976',
                                        '123456')  #模拟登陆获取登陆cookies


def Repo_Question_Save(data, cookies):
    base_url = 'http://192.168.1.10:8705/Repo/Question/Save.do'
    headers = {
        'Accept': 'application/json, text/plain, */*',
    }
    s = requests.session()
    r = s.post(base_url, headers=headers, data=data, cookies=cookies)
    result = r.json()
    return result
示例#3
0
import unittest
import requests
import os, sys
sys.path.append(
    'C:\\Users\\Administrator\\Desktop\\exam_api_test\\interpace\\check_pswd')
import check_pswd
import time
import json
import HTMLTestRunner

login_result, cookies = check_pswd.check_pswd('10016000', '123456')


def GetExamAssist(self, data):
    self.headers = {'content-type': 'application/json'}
    self.base_url = 'http://192.168.1.10:8705/GetExamByAssist.do'
    self.s = requests.Session()
    r = self.s.post(base_url, headers=self.headers, data=data)
示例#4
0
import unittest
import requests
import os, sys

sys.path.append(
    'C:\\Users\\Administrator\\Desktop\\exam_api_test\\interpace\\check_pswd')
import check_pswd
import time
import json
import GetSchool

result, cookies = check_pswd.check_pswd('10016000', '123456')  #模拟登陆获取登陆cookies


class GetSchool_Test(unittest.TestCase):
    def setUp(self):
        '''print('测试GetSchool接口中')'''

    def test_GetSchoolAssists_success(self):
        print(cookies)
        result = GetSchool.GetSchool(cookies)
        try:
            for a in result['data']['schoolAssists']:
                for key in a:
                    self.assertIn(a[key], (31, 32, 33, 10016, 1, 2, 3, 6, 7, 8,
                                           9, 10, 11, 12, 13, 14))
            print('test_GetSchoolAssists_success测试成功')
        except:
            if result['errmsg'] == '未登录':
                print('test_GetSchoolAssists_success未登录成功')
            else: