Esempio n. 1
0
class LoginTest(unittest.TestCase):
    def setUp(self):
        # print('执行开始')
        self.data = ReadTestData(file_name)
        self.hea_data = ReadTestData()
        self.http = HttpMethod()
        self.config = ReadConfig()
        self.log = MyLog()
        self.json = OperationJson()
        self.sheet = 'app_test_fenxi'
        self.row = list(range(2, 30))
        self.log.info(message="----------测试开始----------", name="test_piyue.py")

    def tearDown(self):
        # print("我要走了")
        self.log.info(message="----------测试结束----------",
                      name="test01_OrcLogin.py")

    def test_fenxi01(self):
        """获取考试班级/AnalyzeDateEntering/findExamOfAnalyzeDone"""
        self.log.info(message="test04-1",
                      name="test01_OrcLogin.py",
                      line=get_run_line())
        # 获取测试数据
        method = self.data.get_method(self.sheet, self.row[0])
        url = self.config.get_base_url() + self.data.get_url(
            self.sheet, self.row[0])
        headers = self.hea_data.get_header(self.sheet, self.row[0])
        # data = self.data.get_request_data(self.sheet, self.row[0])
        expect = self.data.get_expect_result(self.sheet, self.row[0])
        self.log.info(message="第一步: 获取请求数据")
        self.log.info(message="请求方法:%s" % method)
        self.log.info(message="请求接口:%s" % url)
        # self.log.info(message="请求数据:%s" % data)
        self.log.info(message="期望结果:%s" % expect)
        # 发送请求
        status_code, header_token, res_json = self.http.http_method(
            method=method, url=url, data=None, headers=headers)
        dict_json = json.loads(res_json)  # 把json数据转换成字典对象
        self.log.info(message="第二步:发送请求,获取返回数据:")
        self.log.info(message="%s" % res_json)
        self.log.info(message="第三步:断言")

        # 断言
        self.assertEqual(status_code, 200, msg=">>>接口请求失败")
        self.assertEqual(dict_json["code"],
                         '10000',
                         msg=">>>断言失败,实际返回结果:%s" % dict_json["code"])
        self.assertEqual(dict_json["msg"],
                         expect["msg"],
                         msg=">>>断言失败,实际返回结果:%s" % dict_json["msg"])
        self.log.info(message="断言结束")

    def test_fenxi02(self):
        """获取已分析考试列表/AnalyzeDateEntering/findExamOfTeacher"""
        self.log.info(message="test04-2",
                      name="test01_OrcLogin.py",
                      line=get_run_line())
        # 获取测试数据
        method = self.data.get_method(self.sheet, self.row[1])
        url = self.config.get_base_url() + self.data.get_url(
            self.sheet, self.row[1])
        headers = self.hea_data.get_header(self.sheet, self.row[1])
        # data = self.data.get_request_data(self.sheet, self.row[1])
        expect = self.data.get_expect_result(self.sheet, self.row[1])
        self.log.info(message="第一步: 获取请求数据")
        self.log.info(message="请求方法:%s" % method)
        self.log.info(message="请求接口:%s" % url)
        # self.log.info(message="请求数据:%s" % data)
        self.log.info(message="期望结果:%s" % expect)

        # 发送请求
        status_code, header_token, res_json = self.http.http_method(
            method=method, url=url, data=None, headers=headers)
        dict_json = json.loads(res_json)  # 把json数据转换成字典对象
        self.log.info(message="第二步:发送请求,获取返回数据:")
        self.log.info(message="%s" % res_json)
        self.log.info(message="第三步:断言")

        # 断言
        self.assertEqual(status_code, 200, msg=">>>接口请求失败")
        self.assertEqual(dict_json["code"],
                         '10000',
                         msg=">>>断言失败,实际返回结果:%s" % dict_json["code"])
        self.assertEqual(dict_json["msg"],
                         expect["msg"],
                         msg=">>>断言失败,实际返回结果:%s" % dict_json["msg"])
        self.log.info(message="断言结束")

    def test_fenxi03(self):
        """更新操作(点击某次考试)查看班级报告/ErrorQuestion/updateFirstNewStatus"""
        self.log.info(message="test04-3",
                      name="test01_OrcLogin.py",
                      line=get_run_line())
        # 获取测试数据
        method = self.data.get_method(self.sheet, self.row[2])
        url = self.config.get_base_url() + self.data.get_url(
            self.sheet, self.row[2])
        headers = self.hea_data.get_header(self.sheet, self.row[2])
        data = self.data.get_request_data(self.sheet, self.row[2])
        expect = self.data.get_expect_result(self.sheet, self.row[2])
        self.log.info(message="第一步: 获取请求数据")
        self.log.info(message="请求方法:%s" % method)
        self.log.info(message="请求接口:%s" % url)
        self.log.info(message="请求数据:%s" % data)
        self.log.info(message="期望结果:%s" % expect)

        # 发送请求
        status_code, header_token, res_json = self.http.http_method(
            method=method, url=url, data=data, headers=headers)
        dict_json = json.loads(res_json)  # 把json数据转换成字典对象
        self.log.info(message="第二步:发送请求,获取返回数据:")
        self.log.info(message="%s" % res_json)
        self.log.info(message="第三步:断言")

        # 断言
        self.assertEqual(status_code, 200, msg=">>>接口请求失败")
        self.assertEqual(dict_json["code"],
                         '10000',
                         msg=">>>断言失败,实际返回结果:%s" % dict_json["code"])
        self.assertEqual(dict_json["msg"],
                         expect["msg"],
                         msg=">>>断言失败,实际返回结果:%s" % dict_json["msg"])
        self.log.info(message="断言结束")

    def test_fenxi04(self):
        """班级报告整体情况/getAnalysis"""
        self.log.info(message="test04-4",
                      name="test01_OrcLogin.py",
                      line=get_run_line())
        # 获取测试数据
        method = self.data.get_method(self.sheet, self.row[3])
        url = self.config.get_base1_url() + self.data.get_url(
            self.sheet, self.row[3])
        headers = self.hea_data.get_header(self.sheet, self.row[3])
        data = self.data.get_request_data(self.sheet, self.row[3])
        expect = self.data.get_expect_result(self.sheet, self.row[3])
        self.log.info(message="第一步: 获取请求数据")
        self.log.info(message="请求方法:%s" % method)
        self.log.info(message="请求接口:%s" % url)
        self.log.info(message="请求数据:%s" % data)
        self.log.info(message="期望结果:%s" % expect)

        # 发送请求
        status_code, header_token, res_json = self.http.http_method(
            method=method, url=url, data=json.dumps(data), headers=headers)
        dict_json = json.loads(res_json)  # 把json数据转换成字典对象
        self.log.info(message="第二步:发送请求,获取返回数据:")
        self.log.info(message="%s" % res_json)
        self.log.info(message="第三步:断言")

        # 断言
        self.assertEqual(status_code, 200, msg=">>>接口请求失败")
        self.assertEqual(dict_json["code"],
                         '10000',
                         msg=">>>断言失败,实际返回结果:%s" % dict_json["code"])
        self.assertEqual(dict_json["msg"],
                         expect["msg"],
                         msg=">>>断言失败,实际返回结果:%s" % dict_json["msg"])
        self.log.info(message="断言结束")

    def test_fenxi05(self):
        """第一名学生历次考试成绩柱状图/getAnalysis"""
        self.log.info(message="test04-5",
                      name="test01_OrcLogin.py",
                      line=get_run_line())
        # 获取测试数据
        method = self.data.get_method(self.sheet, self.row[4])
        url = self.config.get_base1_url() + self.data.get_url(
            self.sheet, self.row[4])
        headers = self.hea_data.get_header(self.sheet, self.row[4])
        data = self.data.get_request_data(self.sheet, self.row[4])
        expect = self.data.get_expect_result(self.sheet, self.row[4])
        self.log.info(message="第一步: 获取请求数据")
        self.log.info(message="请求方法:%s" % method)
        self.log.info(message="请求接口:%s" % url)
        self.log.info(message="请求数据:%s" % data)
        self.log.info(message="期望结果:%s" % expect)

        # 发送请求
        status_code, header_token, res_json = self.http.http_method(
            method=method, url=url, data=json.dumps(data), headers=headers)
        dict_json = json.loads(res_json)  # 把json数据转换成字典对象
        self.log.info(message="第二步:发送请求,获取返回数据:")
        self.log.info(message="%s" % res_json)
        self.log.info(message="第三步:断言")

        # 断言
        self.assertEqual(status_code, 200, msg=">>>接口请求失败")
        self.assertEqual(dict_json["code"],
                         '10000',
                         msg=">>>断言失败,实际返回结果:%s" % dict_json["code"])
        self.assertEqual(dict_json["msg"],
                         expect["msg"],
                         msg=">>>断言失败,实际返回结果:%s" % dict_json["msg"])
        self.log.info(message="断言结束")

    def test_fenxi06(self):
        """进退步趋势/getAnalysis"""
        self.log.info(message="test04-6",
                      name="test01_OrcLogin.py",
                      line=get_run_line())
        # 获取测试数据
        method = self.data.get_method(self.sheet, self.row[5])
        url = self.config.get_base1_url() + self.data.get_url(
            self.sheet, self.row[5])
        headers = self.hea_data.get_header(self.sheet, self.row[5])
        data = self.data.get_request_data(self.sheet, self.row[5])
        expect = self.data.get_expect_result(self.sheet, self.row[5])
        self.log.info(message="第一步: 获取请求数据")
        self.log.info(message="请求方法:%s" % method)
        self.log.info(message="请求接口:%s" % url)
        self.log.info(message="请求数据:%s" % data)
        self.log.info(message="期望结果:%s" % expect)

        # 发送请求
        status_code, header_token, res_json = self.http.http_method(
            method=method, url=url, data=json.dumps(data), headers=headers)
        dict_json = json.loads(res_json)  # 把json数据转换成字典对象
        self.log.info(message="第二步:发送请求,获取返回数据:")
        self.log.info(message="%s" % res_json)
        self.log.info(message="第三步:断言")

        # 断言
        self.assertEqual(status_code, 200, msg=">>>接口请求失败")
        self.assertEqual(dict_json["code"],
                         '10000',
                         msg=">>>断言失败,实际返回结果:%s" % dict_json["code"])
        self.assertEqual(dict_json["msg"],
                         expect["msg"],
                         msg=">>>断言失败,实际返回结果:%s" % dict_json["msg"])
        self.log.info(message="断言结束")

    def test_fenxi07(self):
        """知识点儿情况/getAnalysis"""
        self.log.info(message="test04-7",
                      name="test01_OrcLogin.py",
                      line=get_run_line())
        # 获取测试数据
        method = self.data.get_method(self.sheet, self.row[6])
        url = self.config.get_base1_url() + self.data.get_url(
            self.sheet, self.row[6])
        headers = self.hea_data.get_header(self.sheet, self.row[6])
        data = self.data.get_request_data(self.sheet, self.row[6])
        expect = self.data.get_expect_result(self.sheet, self.row[6])
        self.log.info(message="第一步: 获取请求数据")
        self.log.info(message="请求方法:%s" % method)
        self.log.info(message="请求接口:%s" % url)
        self.log.info(message="请求数据:%s" % data)
        self.log.info(message="期望结果:%s" % expect)

        # 发送请求
        status_code, header_token, res_json = self.http.http_method(
            method=method, url=url, data=json.dumps(data), headers=headers)
        dict_json = json.loads(res_json)  # 把json数据转换成字典对象
        self.log.info(message="第二步:发送请求,获取返回数据:")
        self.log.info(message="%s" % res_json)
        self.log.info(message="第三步:断言")

        # 断言
        self.assertEqual(status_code, 200, msg=">>>接口请求失败")
        self.assertEqual(dict_json["code"],
                         '10000',
                         msg=">>>断言失败,实际返回结果:%s" % dict_json["code"])
        self.assertEqual(dict_json["msg"],
                         expect["msg"],
                         msg=">>>断言失败,实际返回结果:%s" % dict_json["msg"])
        self.log.info(message="断言结束")

    def test_fenxi08(self):
        """更新操作(点击某次考试)查看评卷课件/ErrorQuestion/updateFirstNewStatus"""
        self.log.info(message="test04-8",
                      name="test01_OrcLogin.py",
                      line=get_run_line())
        # 获取测试数据
        method = self.data.get_method(self.sheet, self.row[7])
        url = self.config.get_base_url() + self.data.get_url(
            self.sheet, self.row[7])
        headers = self.hea_data.get_header(self.sheet, self.row[7])
        data = self.data.get_request_data(self.sheet, self.row[7])
        expect = self.data.get_expect_result(self.sheet, self.row[7])
        self.log.info(message="第一步: 获取请求数据")
        self.log.info(message="请求方法:%s" % method)
        self.log.info(message="请求接口:%s" % url)
        self.log.info(message="请求数据:%s" % data)
        self.log.info(message="期望结果:%s" % expect)

        # 发送请求
        status_code, header_token, res_json = self.http.http_method(
            method=method, url=url, data=data, headers=headers)
        dict_json = json.loads(res_json)  # 把json数据转换成字典对象
        self.log.info(message="第二步:发送请求,获取返回数据:")
        self.log.info(message="%s" % res_json)
        self.log.info(message="第三步:断言")

        # 断言
        self.assertEqual(status_code, 200, msg=">>>接口请求失败")
        self.assertEqual(dict_json["code"],
                         expect["code"],
                         msg=">>>断言失败,实际返回结果:%s" % dict_json["code"])
        self.assertEqual(dict_json["msg"],
                         expect["msg"],
                         msg=">>>断言失败,实际返回结果:%s" % dict_json["msg"])
        self.log.info(message="断言结束")

    def test_fenxi09(self):
        """评卷课件情况总览/getCourseware"""
        self.log.info(message="test04-9",
                      name="test01_OrcLogin.py",
                      line=get_run_line())
        # 获取测试数据
        method = self.data.get_method(self.sheet, self.row[8])
        url = self.config.get_base1_url() + self.data.get_url(
            self.sheet, self.row[8])
        headers = self.hea_data.get_header(self.sheet, self.row[8])
        data = self.data.get_request_data(self.sheet, self.row[8])
        expect = self.data.get_expect_result(self.sheet, self.row[8])
        self.log.info(message="第一步: 获取请求数据")
        self.log.info(message="请求方法:%s" % method)
        self.log.info(message="请求接口:%s" % url)
        self.log.info(message="请求数据:%s" % data)
        self.log.info(message="期望结果:%s" % expect)

        # 发送请求
        status_code, header_token, res_json = self.http.http_method(
            method=method, url=url, data=json.dumps(data), headers=headers)
        dict_json = json.loads(res_json)  # 把json数据转换成字典对象
        self.log.info(message="第二步:发送请求,获取返回数据:")
        self.log.info(message="%s" % res_json)
        self.log.info(message="第三步:断言")

        # 断言
        self.assertEqual(status_code, 200, msg=">>>接口请求失败")
        self.assertEqual(dict_json["code"],
                         expect["code"],
                         msg=">>>断言失败,实际返回结果:%s" % dict_json["code"])
        self.assertEqual(dict_json["msg"],
                         expect["msg"],
                         msg=">>>断言失败,实际返回结果:%s" % dict_json["msg"])
        self.log.info(message="断言结束")

    def test_fenxi10(self):
        """评卷课件试卷结构//analysisExamPic/getPcQuestionAll"""
        self.log.info(message="test04-10",
                      name="test01_OrcLogin.py",
                      line=get_run_line())
        # 获取测试数据
        method = self.data.get_method(self.sheet, self.row[9])
        url = self.config.get_base_url() + self.data.get_url(
            self.sheet, self.row[9])
        headers = self.hea_data.get_header(self.sheet, self.row[9])
        data = self.data.get_request_data(self.sheet, self.row[9])
        expect = self.data.get_expect_result(self.sheet, self.row[9])
        self.log.info(message="第一步: 获取请求数据")
        self.log.info(message="请求方法:%s" % method)
        self.log.info(message="请求接口:%s" % url)
        self.log.info(message="请求数据:%s" % data)
        self.log.info(message="期望结果:%s" % expect)

        # 发送请求
        status_code, header_token, res_json = self.http.http_method(
            method=method, url=url, data=data, headers=headers)
        dict_json = json.loads(res_json)  # 把json数据转换成字典对象
        self.log.info(message="第二步:发送请求,获取返回数据:")
        self.log.info(message="%s" % res_json)
        self.log.info(message="第三步:断言")

        # 断言
        self.assertEqual(status_code, 200, msg=">>>接口请求失败")
        self.assertEqual(dict_json["code"],
                         expect["code"],
                         msg=">>>断言失败,实际返回结果:%s" % dict_json["code"])
        self.assertEqual(dict_json["msg"],
                         expect["msg"],
                         msg=">>>断言失败,实际返回结果:%s" % dict_json["msg"])
        self.log.info(message="断言结束")

    def test_fenxi11(self):
        """评卷课件试卷结构/讲评收藏的题目//analysisExamPic/getCollectionQuestion"""
        self.log.info(message="test04-11",
                      name="test01_OrcLogin.py",
                      line=get_run_line())
        # 获取测试数据
        method = self.data.get_method(self.sheet, self.row[10])
        url = self.config.get_base_url() + self.data.get_url(
            self.sheet, self.row[10])
        headers = self.hea_data.get_header(self.sheet, self.row[10])
        data = self.data.get_request_data(self.sheet, self.row[10])
        expect = self.data.get_expect_result(self.sheet, self.row[10])
        self.log.info(message="第一步: 获取请求数据")
        self.log.info(message="请求方法:%s" % method)
        self.log.info(message="请求接口:%s" % url)
        self.log.info(message="请求数据:%s" % data)
        self.log.info(message="期望结果:%s" % expect)

        # 发送请求
        status_code, header_token, res_json = self.http.http_method(
            method=method, url=url, data=data, headers=headers)
        dict_json = json.loads(res_json)  # 把json数据转换成字典对象
        self.log.info(message="第二步:发送请求,获取返回数据:")
        self.log.info(message="%s" % res_json)
        self.log.info(message="第三步:断言")

        # 断言
        self.assertEqual(status_code, 200, msg=">>>接口请求失败")
        self.assertEqual(dict_json["code"],
                         expect["code"],
                         msg=">>>断言失败,实际返回结果:%s" % dict_json["code"])
        self.assertEqual(dict_json["msg"],
                         expect["msg"],
                         msg=">>>断言失败,实际返回结果:%s" % dict_json["msg"])
        self.log.info(message="断言结束")

    def test_fenxi12(self):
        """评卷课件试卷结构/讲评收藏的题目//analysisExamPic/getCollectionQuestion"""
        self.log.info(message="test04-12",
                      name="test01_OrcLogin.py",
                      line=get_run_line())
        # 获取测试数据
        method = self.data.get_method(self.sheet, self.row[11])
        url = self.config.get_base_url() + self.data.get_url(
            self.sheet, self.row[11])
        headers = self.hea_data.get_header(self.sheet, self.row[11])
        data = self.data.get_request_data(self.sheet, self.row[11])
        expect = self.data.get_expect_result(self.sheet, self.row[11])
        self.log.info(message="第一步: 获取请求数据")
        self.log.info(message="请求方法:%s" % method)
        self.log.info(message="请求接口:%s" % url)
        self.log.info(message="请求数据:%s" % data)
        self.log.info(message="期望结果:%s" % expect)

        # 发送请求
        status_code, header_token, res_json = self.http.http_method(
            method=method, url=url, data=data, headers=headers)
        dict_json = json.loads(res_json)  # 把json数据转换成字典对象
        self.log.info(message="第二步:发送请求,获取返回数据:")
        self.log.info(message="%s" % res_json)
        self.log.info(message="第三步:断言")

        # 断言
        self.assertEqual(status_code, 200, msg=">>>接口请求失败")
        self.assertEqual(dict_json["code"],
                         expect["code"],
                         msg=">>>断言失败,实际返回结果:%s" % dict_json["code"])
        self.assertEqual(dict_json["msg"],
                         expect["msg"],
                         msg=">>>断言失败,实际返回结果:%s" % dict_json["msg"])
        self.log.info(message="断言结束")

    def test_fenxi13(self):
        """评卷课件试卷结构/讲评收藏的题目//analysisExamPic/getCollectionQuestion"""
        self.log.info(message="test04-13",
                      name="test01_OrcLogin.py",
                      line=get_run_line())
        # 获取测试数据
        method = self.data.get_method(self.sheet, self.row[12])
        url = self.config.get_base1_url() + self.data.get_url(
            self.sheet, self.row[12])
        headers = self.hea_data.get_header(self.sheet, self.row[12])
        data = self.data.get_request_data(self.sheet, self.row[12])
        expect = self.data.get_expect_result(self.sheet, self.row[12])
        self.log.info(message="第一步: 获取请求数据")
        self.log.info(message="请求方法:%s" % method)
        self.log.info(message="请求接口:%s" % url)
        self.log.info(message="请求数据:%s" % data)
        self.log.info(message="期望结果:%s" % expect)

        # 发送请求
        status_code, header_token, res_json = self.http.http_method(
            method=method, url=url, data=json.dumps(data), headers=headers)
        dict_json = json.loads(res_json)  # 把json数据转换成字典对象
        self.log.info(message="第二步:发送请求,获取返回数据:")
        self.log.info(message="%s" % res_json)
        self.log.info(message="第三步:断言")

        # 断言
        self.assertEqual(status_code, 200, msg=">>>接口请求失败")
        self.assertEqual(dict_json["code"],
                         expect["code"],
                         msg=">>>断言失败,实际返回结果:%s" % dict_json["code"])
        self.assertEqual(dict_json["msg"],
                         expect["msg"],
                         msg=">>>断言失败,实际返回结果:%s" % dict_json["msg"])
        self.log.info(message="断言结束")

    def test_fenxi14(self):
        """查看成绩单/analysisExamPic/getScoreTableList"""
        self.log.info(message="test04-14",
                      name="test01_OrcLogin.py",
                      line=get_run_line())
        # 获取测试数据
        method = self.data.get_method(self.sheet, self.row[13])
        url = self.config.get_base_url() + self.data.get_url(
            self.sheet, self.row[13])
        headers = self.hea_data.get_header(self.sheet, self.row[13])
        data = self.data.get_request_data(self.sheet, self.row[13])
        expect = self.data.get_expect_result(self.sheet, self.row[13])
        self.log.info(message="第一步: 获取请求数据")
        self.log.info(message="请求方法:%s" % method)
        self.log.info(message="请求接口:%s" % url)
        self.log.info(message="请求数据:%s" % data)
        self.log.info(message="期望结果:%s" % expect)

        # 发送请求
        status_code, header_token, res_json = self.http.http_method(
            method=method, url=url, data=data, headers=headers)
        dict_json = json.loads(res_json)  # 把json数据转换成字典对象
        self.log.info(message="第二步:发送请求,获取返回数据:")
        self.log.info(message="%s" % res_json)
        self.log.info(message="第三步:断言")

        # 断言
        self.assertEqual(status_code, 200, msg=">>>接口请求失败")
        self.assertEqual(dict_json["code"],
                         expect["code"],
                         msg=">>>断言失败,实际返回结果:%s" % dict_json["code"])
        self.assertEqual(dict_json["msg"],
                         expect["msg"],
                         msg=">>>断言失败,实际返回结果:%s" % dict_json["msg"])
        self.log.info(message="断言结束")

    def test_fenxi15(self):
        """查看学生简报/analysisExamPic/getScorePostList"""
        self.log.info(message="test04-15",
                      name="test01_OrcLogin.py",
                      line=get_run_line())
        # 获取测试数据
        method = self.data.get_method(self.sheet, self.row[14])
        url = self.config.get_base_url() + self.data.get_url(
            self.sheet, self.row[14])
        headers = self.hea_data.get_header(self.sheet, self.row[14])
        data = self.data.get_request_data(self.sheet, self.row[14])
        expect = self.data.get_expect_result(self.sheet, self.row[14])
        self.log.info(message="第一步: 获取请求数据")
        self.log.info(message="请求方法:%s" % method)
        self.log.info(message="请求接口:%s" % url)
        self.log.info(message="请求数据:%s" % data)
        self.log.info(message="期望结果:%s" % expect)

        # 发送请求
        status_code, header_token, res_json = self.http.http_method(
            method=method, url=url, data=data, headers=headers)
        dict_json = json.loads(res_json)  # 把json数据转换成字典对象
        self.log.info(message="第二步:发送请求,获取返回数据:")
        self.log.info(message="%s" % res_json)
        self.log.info(message="第三步:断言")

        # 断言
        self.assertEqual(status_code, 200, msg=">>>接口请求失败")
        self.assertEqual(dict_json["code"],
                         expect["code"],
                         msg=">>>断言失败,实际返回结果:%s" % dict_json["code"])
        self.assertEqual(dict_json["msg"],
                         expect["msg"],
                         msg=">>>断言失败,实际返回结果:%s" % dict_json["msg"])
        self.log.info(message="断言结束")

    def test_fenxi16(self):
        """查看指定学生InStudentName/examManage/InStudentName"""
        self.log.info(message="test04-16",
                      name="test01_OrcLogin.py",
                      line=get_run_line())
        # 获取测试数据
        method = self.data.get_method(self.sheet, self.row[15])
        url = self.config.get_base_url() + self.data.get_url(
            self.sheet, self.row[15])
        headers = self.hea_data.get_header(self.sheet, self.row[15])
        data = self.data.get_request_data(self.sheet, self.row[15])
        expect = self.data.get_expect_result(self.sheet, self.row[15])
        self.log.info(message="第一步: 获取请求数据")
        self.log.info(message="请求方法:%s" % method)
        self.log.info(message="请求接口:%s" % url)
        self.log.info(message="请求数据:%s" % data)
        self.log.info(message="期望结果:%s" % expect)

        # 发送请求
        status_code, header_token, res_json = self.http.http_method(
            method=method, url=url, data=data, headers=headers)
        dict_json = json.loads(res_json)  # 把json数据转换成字典对象
        self.log.info(message="第二步:发送请求,获取返回数据:")
        self.log.info(message="%s" % res_json)
        self.log.info(message="第三步:断言")

        # 断言
        self.assertEqual(status_code, 200, msg=">>>接口请求失败")
        self.assertEqual(dict_json["code"],
                         expect["code"],
                         msg=">>>断言失败,实际返回结果:%s" % dict_json["code"])
        self.assertEqual(dict_json["msg"],
                         expect["msg"],
                         msg=">>>断言失败,实际返回结果:%s" % dict_json["msg"])
        self.log.info(message="断言结束")

    def test_fenxi17(self):
        """查看指定学生getSureClass/examManage/verificationName"""
        self.log.info(message="test04-17",
                      name="test01_OrcLogin.py",
                      line=get_run_line())
        # 获取测试数据
        method = self.data.get_method(self.sheet, self.row[16])
        url = self.config.get_base_url() + self.data.get_url(
            self.sheet, self.row[16])
        headers = self.hea_data.get_header(self.sheet, self.row[16])
        data = self.data.get_request_data(self.sheet, self.row[16])
        expect = self.data.get_expect_result(self.sheet, self.row[16])
        self.log.info(message="第一步: 获取请求数据")
        self.log.info(message="请求方法:%s" % method)
        self.log.info(message="请求接口:%s" % url)
        self.log.info(message="请求数据:%s" % data)
        self.log.info(message="期望结果:%s" % expect)

        # 发送请求
        status_code, header_token, res_json = self.http.http_method(
            method=method, url=url, data=data, headers=headers)
        dict_json = json.loads(res_json)  # 把json数据转换成字典对象
        self.log.info(message="第二步:发送请求,获取返回数据:")
        self.log.info(message="%s" % res_json)
        self.log.info(message="第三步:断言")

        # 断言
        self.assertEqual(status_code, 200, msg=">>>接口请求失败")
        self.assertEqual(dict_json["code"],
                         expect["code"],
                         msg=">>>断言失败,实际返回结果:%s" % dict_json["code"])
        self.assertEqual(dict_json["msg"],
                         expect["msg"],
                         msg=">>>断言失败,实际返回结果:%s" % dict_json["msg"])
        self.log.info(message="断言结束")

    def test_fenxi18(self):
        """查看指定学生verificationName/examManage/verificationName"""
        self.log.info(message="test04-18",
                      name="test01_OrcLogin.py",
                      line=get_run_line())
        # 获取测试数据
        method = self.data.get_method(self.sheet, self.row[17])
        url = self.config.get_base_url() + self.data.get_url(
            self.sheet, self.row[17])
        headers = self.hea_data.get_header(self.sheet, self.row[17])
        data = self.data.get_request_data(self.sheet, self.row[17])
        expect = self.data.get_expect_result(self.sheet, self.row[17])
        self.log.info(message="第一步: 获取请求数据")
        self.log.info(message="请求方法:%s" % method)
        self.log.info(message="请求接口:%s" % url)
        self.log.info(message="请求数据:%s" % data)
        self.log.info(message="期望结果:%s" % expect)

        # 发送请求
        status_code, header_token, res_json = self.http.http_method(
            method=method, url=url, data=data, headers=headers)
        dict_json = json.loads(res_json)  # 把json数据转换成字典对象
        self.log.info(message="第二步:发送请求,获取返回数据:")
        self.log.info(message="%s" % res_json)
        self.log.info(message="第三步:断言")

        # 断言
        self.assertEqual(status_code, 200, msg=">>>接口请求失败")
        self.assertEqual(dict_json["code"],
                         expect["code"],
                         msg=">>>断言失败,实际返回结果:%s" % dict_json["code"])
        self.assertEqual(dict_json["msg"],
                         expect["msg"],
                         msg=">>>断言失败,实际返回结果:%s" % dict_json["msg"])
        self.log.info(message="断言结束")

    def test_fenxi19(self):
        """查看指定学生getScoreResult/examManage/getScoreResult"""
        self.log.info(message="test04-19",
                      name="test01_OrcLogin.py",
                      line=get_run_line())
        # 获取测试数据
        method = self.data.get_method(self.sheet, self.row[18])
        url = self.config.get_base_url() + self.data.get_url(
            self.sheet, self.row[18])
        headers = self.hea_data.get_header(self.sheet, self.row[18])
        data = self.data.get_request_data(self.sheet, self.row[18])
        expect = self.data.get_expect_result(self.sheet, self.row[18])
        self.log.info(message="第一步: 获取请求数据")
        self.log.info(message="请求方法:%s" % method)
        self.log.info(message="请求接口:%s" % url)
        self.log.info(message="请求数据:%s" % data)
        self.log.info(message="期望结果:%s" % expect)

        # 发送请求
        status_code, header_token, res_json = self.http.http_method(
            method=method, url=url, data=data, headers=headers)
        dict_json = json.loads(res_json)  # 把json数据转换成字典对象
        self.log.info(message="第二步:发送请求,获取返回数据:")
        self.log.info(message="%s" % res_json)
        self.log.info(message="第三步:断言")

        # 断言
        self.assertEqual(status_code, 200, msg=">>>接口请求失败")
        self.assertEqual(dict_json["code"],
                         expect["code"],
                         msg=">>>断言失败,实际返回结果:%s" % dict_json["code"])
        self.assertEqual(dict_json["msg"],
                         expect["msg"],
                         msg=">>>断言失败,实际返回结果:%s" % dict_json["msg"])
        self.log.info(message="断言结束")

    def test_fenxi20(self):
        """查看全班同学综合报告结果/examManage/publishedResults"""
        self.log.info(message="test04-20",
                      name="test01_OrcLogin.py",
                      line=get_run_line())
        # 获取测试数据
        method = self.data.get_method(self.sheet, self.row[19])
        url = self.config.get_base_url() + self.data.get_url(
            self.sheet, self.row[19])
        headers = self.hea_data.get_header(self.sheet, self.row[19])
        data = self.data.get_request_data(self.sheet, self.row[19])
        expect = self.data.get_expect_result(self.sheet, self.row[19])
        self.log.info(message="第一步: 获取请求数据")
        self.log.info(message="请求方法:%s" % method)
        self.log.info(message="请求接口:%s" % url)
        self.log.info(message="请求数据:%s" % data)
        self.log.info(message="期望结果:%s" % expect)

        # 发送请求
        status_code, header_token, res_json = self.http.http_method(
            method=method, url=url, data=data, headers=headers)
        dict_json = json.loads(res_json)  # 把json数据转换成字典对象
        self.log.info(message="第二步:发送请求,获取返回数据:")
        self.log.info(message="%s" % res_json)
        self.log.info(message="第三步:断言")

        # 断言
        self.assertEqual(status_code, 200, msg=">>>接口请求失败")
        self.assertEqual(dict_json["code"],
                         expect["code"],
                         msg=">>>断言失败,实际返回结果:%s" % dict_json["code"])
        self.assertEqual(dict_json["msg"],
                         expect["msg"],
                         msg=">>>断言失败,实际返回结果:%s" % dict_json["msg"])
        self.log.info(message="断言结束")

    def test_fenxi21(self):
        """查看全班同学综合报告分析/AnalyzeDateEntering/findExamAnalyzeId/6803"""
        self.log.info(message="test04-21",
                      name="test01_OrcLogin.py",
                      line=get_run_line())
        # 获取测试数据
        method = self.data.get_method(self.sheet, self.row[20])
        url = self.config.get_base_url() + self.data.get_url(
            self.sheet, self.row[20])
        headers = self.hea_data.get_header(self.sheet, self.row[20])
        # data = self.data.get_request_data(self.sheet, self.row[20])
        expect = self.data.get_expect_result(self.sheet, self.row[20])
        self.log.info(message="第一步: 获取请求数据")
        self.log.info(message="请求方法:%s" % method)
        self.log.info(message="请求接口:%s" % url)
        # self.log.info(message="请求数据:%s" % data)
        self.log.info(message="期望结果:%s" % expect)

        # 发送请求
        status_code, header_token, res_json = self.http.http_method(
            method=method, url=url, data=None, headers=headers)
        dict_json = json.loads(res_json)  # 把json数据转换成字典对象
        self.log.info(message="第二步:发送请求,获取返回数据:")
        self.log.info(message="%s" % res_json)
        self.log.info(message="第三步:断言")

        # 断言
        self.assertEqual(status_code, 200, msg=">>>接口请求失败")
        self.assertEqual(dict_json["code"],
                         expect["code"],
                         msg=">>>断言失败,实际返回结果:%s" % dict_json["code"])
        self.assertEqual(dict_json["msg"],
                         expect["msg"],
                         msg=">>>断言失败,实际返回结果:%s" % dict_json["msg"])
        self.log.info(message="断言结束")
Esempio n. 2
0
class LoginTest(unittest.TestCase):
    def setUp(self):
        self.data = ReadTestData(file_name)
        self.hea_data = ReadTestData()
        self.http = HttpMethod()
        self.config = ReadConfig()
        self.log = MyLog()
        self.json = OperationJson()
        self.sheet = 'app_test_case'
        self.row = list(range(2, 20))
        self.log.info(message="----------测试开始----------", name="test01_OrcLogin.py")

    def tearDown(self):
        self.log.info(message="----------测试结束----------", name="test01_OrcLogin.py")
    def test_login01(self):
        """登录成功/userManage/signIn"""
        self.log.info(message="test01-1", name="test01_OrcLogin.py", line=get_run_line())
        # 获取测试数据
        method = self.data.get_method(self.sheet, self.row[0])
        url = self.config.get_base_url() + self.data.get_url(self.sheet, self.row[0])
        headers = self.hea_data.get_header(self.sheet, self.row[0])
        data = self.data.get_request_data(self.sheet, self.row[0])
        self.log.info(message="第一步: 获取请求数据")
        self.log.info(message="请求方法:%s" % method)
        self.log.info(message="请求接口:%s" % url)
        self.log.info(message="请求数据:%s" % data)
        status_code,header_token,res_json = self.http.http_method(method=method, url=url, data=data)
        dict_json = json.loads(res_json) # 把json数据转换成字典对象
        self.log.info(message="第二步:发送请求,获取返回数据:")
        self.log.info(message="%s" % res_json)
        if dict_json["data"]:
            orc_token = header_token["Token"]  # 提取orc_token
            self.log.info(message="提取token", name="test_login01")
            self.log.info(message="%s" % orc_token, name="test_login01")
            authorization =  orc_token
            # self.json.write_data(authorization, "orc_token_header", "Authorization")  # 把orc_token写入json文件
            self.json.write_data(authorization, "login_header_token", "Token")
            self.json.write_data(authorization, "login_header_piyue", "Token")
            self.json.write_data(authorization, "login_header_fenxi", "Token")
            self.json.write_data(authorization, "fenxi", "Token")
        # 断言
        self.log.info(message="第三步:断言")
        self.assertEqual(status_code, 200, msg=">>>接口请求失败")
        self.assertEqual(dict_json["data"], "登录成功",msg=">>>断言失败,实际返回结果:%s" % dict_json)
        self.assertEqual(dict_json["msg"], "OK",
                         msg=">>>断言失败,实际返回值是:%s" % dict_json["msg"])
        self.log.info(message="断言结束")

    def test_login02(self):
        """获取用户信息/userManage/getInfo"""
        self.log.info(message="test02-1", name="test01_OrcLogin.py", line=get_run_line())
        # 获取测试数据
        method = self.data.get_method(self.sheet, self.row[1])
        url = self.config.get_base_url() + self.data.get_url(self.sheet, self.row[1])
        headers = self.hea_data.get_header(self.sheet, self.row[1])
        # data = self.data.get_request_data(self.sheet, self.row[1])
        expect = self.data.get_expect_result(self.sheet, self.row[1])
        self.log.info(message="第一步: 获取请求数据")
        self.log.info(message="请求方法:%s" % method)
        self.log.info(message="请求接口:%s" % url)
        # self.log.info(message="请求数据:%s" % data)
        self.log.info(message="期望结果:%s" % expect)

        # 发送请求
        status_code,header_token, res_json = self.http.http_method(method=method, url=url,headers=headers)
        dict_json = json.loads(res_json)  # 把json数据转换成字典对象
        self.log.info(message="第二步:发送请求,获取返回数据:")
        self.log.info(message="%s" % res_json)
        self.log.info(message="第三步:断言")
        # 断言
        self.assertEqual(status_code, 200, msg=">>>接口请求失败")
        self.assertEqual(dict_json["code"], '10000',msg=">>>断言失败,实际返回结果:%s" %dict_json["code"])
        self.assertEqual(dict_json["data"]["userName"], expect["userName"],msg=">>>断言失败,实际返回结果:%s" % dict_json["data"]["userName"])
        self.log.info(message="断言结束")

    def test_login03(self):
        """获取首页右上角信息/ErrorQuestion/getIndexBaseInfo"""
        self.log.info(message="test02-2", name="test01_OrcLogin.py", line=get_run_line())
        # 获取测试数据
        method = self.data.get_method(self.sheet, self.row[2])
        url = self.config.get_base_url() + self.data.get_url(self.sheet, self.row[2])
        headers = self.hea_data.get_header(self.sheet, self.row[2])
        # data = self.data.get_request_data(self.sheet, self.row[2])
        expect = self.data.get_expect_result(self.sheet, self.row[2])
        self.log.info(message="第一步: 获取请求数据")
        self.log.info(message="请求方法:%s" % method)
        self.log.info(message="请求接口:%s" % url)
        # self.log.info(message="请求数据:%s" % data)
        self.log.info(message="期望结果:%s" % expect)
        # 发送请求
        status_code,header_token, res_json = self.http.http_method(method=method, url=url, data=None, headers=headers)
        dict_json = json.loads(res_json)  # 把json数据转换成字典对象
        self.log.info(message="第二步:发送请求,获取返回数据:")
        self.log.info(message="%s" % res_json)
        self.log.info(message="第三步:断言")

        # 断言
        self.assertEqual(status_code, 200, msg=">>>接口请求失败")
        self.assertEqual(dict_json["code"],'10000', msg=">>>断言失败,实际返回结果:%s")
        self.assertEqual(dict_json["data"]["schoolName"], expect["schoolName"],
                         msg=">>>断言失败,实际返回结果:%s" % dict_json["data"]["schoolName"])
        self.log.info(message="断言结束")

    def test_login04(self):
        """获取考试列表/examManage/getExamlist?type=2"""
        self.log.info(message="test02-3", name="test01_OrcLogin.py", line=get_run_line())
        # 获取测试数据
        method = self.data.get_method(self.sheet, self.row[3])
        url = self.config.get_base_url() + self.data.get_url(self.sheet, self.row[3])
        headers = self.hea_data.get_header(self.sheet, self.row[3])
        # data = self.data.get_request_data(self.sheet, self.row[3])
        expect = self.data.get_expect_result(self.sheet, self.row[3])
        self.log.info(message="第一步: 获取请求数据")
        self.log.info(message="请求方法:%s" % method)
        self.log.info(message="请求接口:%s" % url)
        # self.log.info(message="请求数据:%s" % data)
        self.log.info(message="期望结果:%s" % expect)

        # 发送请求
        status_code,header_token, res_json = self.http.http_method(method=method, url=url, data=None, headers=headers)
        dict_json = json.loads(res_json)  # 把json数据转换成字典对象
        self.log.info(message="第二步:发送请求,获取返回数据:")
        self.log.info(message="%s" % res_json)
        self.log.info(message="第三步:断言")

        # 断言
        self.assertEqual(status_code, 200, msg=">>>接口请求失败")
        self.assertEqual(dict_json["code"], '10000',msg=">>>实际返回结果:%s" %dict_json["code"])
        self.assertEqual(dict_json["data"][0]["exam_name"], expect["exam_name"],
                         msg=">>>断言失败,实际返回结果:%s" % dict_json["data"][0]["exam_name"])
        self.log.info(message="断言结束")

    def test_login05(self):
        """获取电教老师获取电教老师"""
        self.log.info(message="test02-4", name="test01_OrcLogin.py", line=get_run_line())
        # 获取测试数据
        method = self.data.get_method(self.sheet, self.row[4])
        url = self.config.get_base_url() + self.data.get_url(self.sheet, self.row[4])
        headers = self.hea_data.get_header(self.sheet, self.row[4])
        # data = self.data.get_request_data(self.sheet, self.row[4])
        expect = self.data.get_expect_result(self.sheet, self.row[4])
        self.log.info(message="第一步: 获取请求数据")
        self.log.info(message="请求方法:%s" % method)
        self.log.info(message="请求接口:%s" % url)
        # self.log.info(message="请求数据:%s" % data)
        self.log.info(message="期望结果:%s" % expect)

        # 发送请求
        status_code,header_token, res_json = self.http.http_method(method=method, url=url, data=None, headers=headers)
        dict_json = json.loads(res_json)  # 把json数据转换成字典对象
        self.log.info(message="第二步:发送请求,获取返回数据:")
        self.log.info(message="%s" % res_json)
        self.log.info(message="第三步:断言")

        # 断言
        self.assertEqual(status_code, 200, msg=">>>接口请求失败")
        self.assertEqual(dict_json["code"],'10000', msg=">>>断言失败,实际返回结果:%s" % dict_json["code"])
        self.assertEqual(dict_json["data"][6]["userName"], expect["userName"],
                         msg=">>>断言失败,实际返回结果:%s" % dict_json["data"][5]["userName"])
        self.log.info(message="断言结束")
Esempio n. 3
0
class RunTest:
    def __init__(self):
        self.logger = MyLog()
        self.readconfig = ReadConfig()
        self.send_mail = SendEmail()
        # self.env = ResetEnv()
        self.is_send = self.readconfig.get_email("is_send")

        # 测试报告基本信息
        self.testers = "Roman"
        self.title = "元丁接口测试报告"
        self.description = "正式/测试环境:Develop,IP地址:%s" % self.readconfig.get_base_url(
        )
        # print(self.description)

        # 导入TestCase目录下的全部测试用例
        self.discover = unittest.defaultTestLoader.discover(test_case_path,
                                                            pattern='test*.py')

        # 导入指定测试用例列表文件
        self.case_list_file = case_list_path
        self.case_list_list = []
        # print(self.case_list_list)

        # 重置测试环境
        self.is_env = True
        # self.is_env = self.env.delete_db()

    def get_case_list(self):
        """获取需要进行运行的测试用例列表"""
        fb = open(self.case_list_file)
        for i in fb.readlines():
            data = str(i)
            if data != '' and not data.startswith('#'):
                self.case_list_list.append(data.replace('\n', ''))
        fb.close()
        # print(self.case_list_list)

    def set_test_suite(self):
        """设置添加测试套件"""
        self.get_case_list()
        test_suite = unittest.TestSuite()
        suite_module = []
        for case in self.case_list_list:
            case_name = case.split('/')[-1]
            print(case_name + '.py')
            discover = unittest.defaultTestLoader.discover(test_case_path,
                                                           pattern=case_name +
                                                           '.py')
            suite_module.append(discover)
        if len(suite_module) > 0:
            for suite in suite_module:
                for test_name in suite:
                    test_suite.addTest(test_name)
        else:
            return None
        return test_suite

    def run_test(self):
        """执行测试"""
        if self.is_env:
            try:
                test_suite = self.set_test_suite()  # 获取测试套件
                now = time.strftime("%Y-%m-%d_%H-%M-%S",
                                    time.localtime(time.time()))  # 获取当前日期时间
                public_path = os.path.dirname(os.path.abspath(sys.argv[0]))
                # filename = public_path + "/report/" + now + "_report.html"  # 保存的报告路径和名称
                filename = public_path + "/report/" + "index.html"  # 保存的报告路径和名称
                print("测试报告目录:%s" % filename)
                fp = open(filename, 'wb')
                runner = HTMLTestRunner(stream=fp,
                                        tester=self.testers,
                                        title=self.title,
                                        description=self.description)
                if test_suite is not None:
                    runner.run(test_suite)  # 执行指定添加的测试用例套件
                    # runner.run(self.discover) # 执行TestCase目录下的全部测试用例
                else:
                    self.logger.info("Have no case to test.")
            except Exception as e:
                self.logger.error(str(e))
            finally:
                self.logger.warning(
                    "---------------All Test End---------------")
                fp.close()
                # 发送电子邮件
                if self.is_send == 'yes':
                    self.send_mail.send_email()
                    self.logger.warning("测试报告已发送电子邮件!")
                elif self.is_send == 'no':
                    self.logger.warning("测试报告不发送电子邮件!")
                else:
                    self.logger.error("测试报告发送电子邮件为未知状态,请检查配置!")
        else:
            self.logger.warning("测试环境清理失败的,无法继续执行测试!!!")
Esempio n. 4
0
class LoginTest(unittest.TestCase):
    def setUp(self):
        # print('执行开始')
        self.data = ReadTestData(file_name)
        self.hea_data = ReadTestData()
        self.http = HttpMethod()
        self.config = ReadConfig()
        self.log = MyLog()
        self.json = OperationJson()
        self.sheet = 'app_test_piyue'
        self.sheet_id = 'app_test_data'
        self.row = list(range(2, 20))
        self.log.info(message="----------测试开始----------", name="test_piyue.py")

    def tearDown(self):
        # print("我要走了")
        self.log.info(message="----------测试结束----------",
                      name="test01_OrcLogin.py")

    def test_piyue01(self):
        """试卷结构获取/examManage/getPcQuestionAll?examId=6272&studentId= """
        self.log.info(message="test03-2",
                      name="test01_OrcLogin.py",
                      line=get_run_line())
        # 获取测试数据
        # print("kaishi")
        method = self.data.get_method(self.sheet, self.row[0])
        # print(method)
        url = self.config.get_base_url() + self.data.get_url(
            self.sheet, self.row[0])
        # print(url)
        headers = self.hea_data.get_header(self.sheet, self.row[0])
        # print(headers)
        data = self.data.get_request_data(self.sheet, self.row[0])
        # print(data)
        expect = self.data.get_expect_result(self.sheet, self.row[0])
        # print(expect)
        self.log.info(message="第一步: 获取请求数据")
        self.log.info(message="请求方法:%s" % method)
        self.log.info(message="请求接口:%s" % url)
        self.log.info(message="请求数据:%s" % data)
        self.log.info(message="期望结果:%s" % expect)
        # res = requests.request(method,url,data = data,headers = headers)
        # print(res.text)

        # 发送请求
        status_code, header_token, res_json = self.http.http_method(
            method=method, url=url, data=data, headers=headers)
        dict_json = json.loads(res_json)  # 把json数据转换成字典对象
        self.log.info(message="第二步:发送请求,获取返回数据:")
        self.log.info(message="%s" % res_json)
        self.log.info(message="第三步:断言")

        # 断言
        self.assertEqual(status_code, 200, msg=">>>接口请求失败")
        self.assertEqual(dict_json["code"],
                         '10000',
                         msg=">>>断言失败,实际返回结果:%s" % dict_json["code"])
        self.assertEqual(dict_json["msg"],
                         expect["msg"],
                         msg=">>>断言失败,实际返回结果:%s" % dict_json["msg"])
        self.log.info(message="断言结束")

    def test_piyue02(self):
        """获取已批阅列表/ErrorQuestion/getAnalyAndReportExamList"""
        self.log.info(message="test03-1",
                      name="test01_OrcLogin.py",
                      line=get_run_line())
        # 获取测试数据
        # print("kaishi")
        method = self.data.get_method(self.sheet, self.row[1])
        # print(method)
        url = self.config.get_base_url() + self.data.get_url(
            self.sheet, self.row[1])
        # print(url)
        headers = self.hea_data.get_header(self.sheet, self.row[1])
        # print(headers)
        data = self.data.get_request_data(self.sheet, self.row[1])
        # print(data)
        expect = self.data.get_expect_result(self.sheet, self.row[1])
        # print(expect)
        self.log.info(message="第一步: 获取请求数据")
        self.log.info(message="请求方法:%s" % method)
        self.log.info(message="请求接口:%s" % url)
        self.log.info(message="请求数据:%s" % data)
        self.log.info(message="期望结果:%s" % expect)
        # res = requests.request(method,url,data = data,headers = headers)
        # print(res.text)

        # 发送请求
        status_code, header_token, res_json = self.http.http_method(
            method=method, url=url, data=data, headers=headers)
        dict_json = json.loads(res_json)  # 把json数据转换成字典对象
        self.log.info(message="第二步:发送请求,获取返回数据:")
        self.log.info(message="%s" % res_json)
        self.log.info(message="第三步:断言")

        # 断言
        self.assertEqual(status_code, 200, msg=">>>接口请求失败")
        self.assertEqual(dict_json["code"],
                         '10000',
                         msg=">>>断言失败,实际返回结果:%s" % dict_json["code"])
        self.assertEqual(dict_json["msg"],
                         expect["msg"],
                         msg=">>>断言失败,实际返回结果:%s" % dict_json["msg"])
        self.log.info(message="断言结束")

    def test_piyue03(self):
        """获取某题整体情况/examQuestion/getUncheckedTopic/6272/27170/0"""
        self.log.info(message="test03-3",
                      name="test01_OrcLogin.py",
                      line=get_run_line())
        # 获取测试数据
        # print("kaishi")
        method = self.data.get_method(self.sheet, self.row[2])
        # print(method)
        url = self.config.get_base_url() + self.data.get_url(
            self.sheet, self.row[2])
        # print(url)
        headers = self.hea_data.get_header(self.sheet, self.row[2])
        # print(headers)
        # data = self.data.get_request_data(self.sheet, self.row[5])
        # print(data)
        expect = self.data.get_expect_result(self.sheet, self.row[2])
        # print(expect)
        self.log.info(message="第一步: 获取请求数据")
        self.log.info(message="请求方法:%s" % method)
        self.log.info(message="请求接口:%s" % url)
        # self.log.info(message="请求数据:%s" % data)
        self.log.info(message="期望结果:%s" % expect)
        # res = requests.request(method,url,data = data,headers = headers)
        # print(res.text)

        # 发送请求
        status_code, header_token, res_json = self.http.http_method(
            method=method, url=url, data=None, headers=headers)
        dict_json = json.loads(res_json)  # 把json数据转换成字典对象
        self.log.info(message="第二步:发送请求,获取返回数据:")
        self.log.info(message="%s" % res_json)
        self.log.info(message="第三步:断言")

        # 断言
        self.assertEqual(status_code, 200, msg=">>>接口请求失败")
        self.assertEqual(dict_json["code"],
                         '10000',
                         msg=">>>断言失败,实际返回结果:%s" % dict_json["code"])
        self.assertEqual(dict_json["msg"],
                         expect["msg"],
                         msg=">>>断言失败,实际返回结果:%s" % dict_json["msg"])
        self.log.info(message="断言结束")

    def test_piyue04(self):
        """获取某提批改列表/examQuestion/getStudentNamePicAll/6272/27170"""
        self.log.info(message="test03-4",
                      name="test01_OrcLogin.py",
                      line=get_run_line())
        # 获取测试数据
        # print("kaishi")
        # t_id = self.data.get_t_id(self.sheet_id,self.row[0])
        # studentId = self.data.get_studentId(self.sheet_id,self.row[0])
        method = self.data.get_method(self.sheet, self.row[3])
        # print(method)
        url = self.config.get_base_url() + self.data.get_url(
            self.sheet, self.row[3])
        # print(url)
        headers = self.hea_data.get_header(self.sheet, self.row[3])
        # print(headers)
        # data = self.data.get_request_data(self.sheet, self.row[3])
        # print(data)
        expect = self.data.get_expect_result(self.sheet, self.row[3])
        # print(expect)
        self.log.info(message="第一步: 获取请求数据")
        self.log.info(message="请求方法:%s" % method)
        self.log.info(message="请求接口:%s" % url)
        # self.log.info(message="请求数据:%s" % data)
        self.log.info(message="期望结果:%s" % expect)
        # res = requests.request(method,url,data = data,headers = headers)
        # print(res.text)

        # 发送请求
        status_code, header_token, res_json = self.http.http_method(
            method=method, url=url, data=None, headers=headers)
        dict_json = json.loads(res_json)  # 把json数据转换成字典对象
        self.log.info(message="第二步:发送请求,获取返回数据:")
        self.log.info(message="%s" % res_json)
        self.log.info(message="第三步:断言")

        # 断言
        self.assertEqual(status_code, 200, msg=">>>接口请求失败")
        # print(dict_json["code"])
        self.assertEqual(dict_json["code"],
                         expect["code"],
                         msg=">>>断言失败,实际返回结果:%s" % dict_json["code"])
        self.assertEqual(dict_json["msg"],
                         expect["msg"],
                         msg=">>>断言失败,实际返回结果:%s" % dict_json["msg"])
        id_data = dict_json["data"]
        id_list = []
        # studentId_list = []
        score_list = []
        examID_list = []
        questionId_list = []
        for k in range(len(id_data)):
            id_list.append(id_data[k]["id"])
            # studentId_list.append(id_data[k]["studentId"])
            examID_list.append(6272)
            # print(examID_list)
            questionId_list.append(27170)
            score_data = random.randint(0, 3)
            score_list.append(score_data)
        #把需要批改的题块的id和studentid取出来放到excel表格中,方便下一步进行批改
        write_excel.write_excel_data(examID_list, id_list, questionId_list,
                                     score_list)
        self.assertEqual(status_code, 200, msg=">>>接口请求失败")
        self.assertEqual(dict_json["code"],
                         '10000',
                         msg=">>>断言失败,实际返回结果:%s" % dict_json["code"])
        self.assertEqual(dict_json["msg"],
                         expect["msg"],
                         msg=">>>断言失败,实际返回结果:%s" % dict_json["msg"])
        self.log.info(message="断言结束")

    def test_piyue05(self):
        """批改学生试卷/examQuestion/updateStudentUnionExam"""
        self.log.info(message="test03-6",
                      name="test01_OrcLogin.py",
                      line=get_run_line())
        # 获取测试数据
        sheetname = "app_test_data"
        #读取excel测试数据,获取给分请求参数
        get_data = ExcelData(data_path, sheetname)
        datas = get_data.readExcel()
        method = self.data.get_method(self.sheet, self.row[5])
        url = self.config.get_base_url() + self.data.get_url(
            self.sheet, self.row[5])
        headers = self.hea_data.get_header(self.sheet, self.row[5])
        expect = self.data.get_expect_result(self.sheet, self.row[5])
        self.log.info(message="请求方法:%s" % method)
        self.log.info(message="请求头:%s" % headers)
        self.log.info(message="请求接口:%s" % url)
        self.log.info(message="期望结果:%s" % expect)
        for i in range(0, len(datas)):
            data = datas[i]
            self.log.info(message="第一步: 获取请求数据:%s" % data)
            status_code, header_token, res_json = self.http.http_method(
                method=method, url=url, data=json.dumps(data), headers=headers)
            dict_json = json.loads(res_json)  # 把json数据转换成字典对象
            self.log.info(message="第二步:发送请求,获取返回数据:")
            self.log.info(message="%s" % res_json)
            self.log.info(message="第三步:断言")
            self.assertEqual(status_code, 200, msg=">>>接口请求失败")
            # print(dict_json["code"])
            self.assertEqual(dict_json["code"],
                             expect["code"],
                             msg=">>>断言失败,实际返回结果:%s" % dict_json["code"])
            self.assertEqual(dict_json["msg"],
                             expect["msg"],
                             msg=">>>断言失败,实际返回结果:%s" % dict_json["msg"])
            self.log.info(message="断言结束")