Exemplo n.º 1
0
 def test_car_register(self, test_info):
     test_info["data"] = replace_data(Handler(), test_info["data"])
     resp = visit(method=test_info["method"],
                  url=Handler.host + test_info["url"],
                  json=json.loads(test_info["data"]))
     expected = json.loads(test_info["expected"])
     self.assertTrue(expected["code"] == resp["code"])
     self.assertTrue(expected["msg"] == resp["msg"])
     logger.info("第{}条测试用例通过".format(test_info["case_id"]))
Exemplo n.º 2
0
    def test_add_item(self, test_info):
        url = Handler.host + test_info["url"]
        test_info["data"] = replace_data(Handler(), test_info["data"])
        test_info["headers"] = replace_data(Handler(), test_info["headers"])
        resp = visit(method=test_info["method"],
                     url=url,
                     json=json.loads(test_info["data"]),
                     headers=json.loads(test_info["headers"]))
        try:
            expected = json.loads(test_info["expected"])
            self.assertTrue(expected["code"] == resp["code"])
            self.assertTrue(expected["msg"] == resp["msg"])

            if resp["code"] == 0:
                sql = "select * from loan where member_id = {}".format(self.member_id)
                after_loan = self.db.query(sql, one=False)
                self.assertTrue(len(self.before_loan) + 1 == len(after_loan))
            logger.info("第{}条测试用例通过".format(test_info["case_id"]))

        except Exception as e:
            logger.error("请求不是json格式")
            raise e
Exemplo n.º 3
0
    def test_audit(self, test_info):

        test_info["headers"] = replace_data(Handler(), test_info["headers"])

        test_info["data"] = replace_data(Handler(), test_info["data"])

        resp = visit(method=test_info["method"],
                     url=Handler.host + test_info["url"],
                     json=json.loads(test_info["data"]),
                     headers=eval(test_info["headers"]))
        expected = eval(test_info["expected"])
        self.assertTrue(expected["code"] == resp["code"])
        self.assertTrue(expected["msg"] == resp["msg"])

        if resp["code"] == 0:
            # 验证数据库状态
            data = json.loads(test_info["data"])
            loan = MySqlHandlerWare().query(
                "SELECT * FROM loan WHERE id={}".format(data["loan_id"]))
            self.assertEqual(expected["status"], loan["status"])

        logger.info("第{}条测试用例通过".format(test_info["case_id"]))
Exemplo n.º 4
0
from middlerware.handler import Handler, replace_data
Exemplo n.º 5
0
from middlerware.handler import Handler, replace_data
Exemplo n.º 6
0
from middlerware.handler import Handler,replace_data