示例#1
0
	def get_betrecord_list(self):
		'''获取本月电子注单列表'''
		route = data[162]["route"]
		url = "".join(base.get_url(route))
		Method = data[162]["method"]
		params = eval(data[162]["params"])
		# 获取当前日期
		date = datetime.datetime.now()
		year = date.year
		month = date.month
		today = datetime.date.today() # 今日
		# 开始日期
		start = datetime.date(year, month, 1)
		# 结束日期
		if month == 12:
			end = datetime.date(year + 1, 1, 1) - datetime.timedelta(days=1)
		else:
			end = datetime.date(year, month + 1, 1) - datetime.timedelta(days=1)

		params["time_start"] = start
		params["time_end"] = today
		headers = {"Authorization": self.token}
		kwargs = {"params": params, "headers": headers}
		resp = base.get_response(url, Method, **kwargs)
		return resp
示例#2
0
    def test_CQ9_bet_details_daily(self):

        route = data[141]["route"]
        url = "".join(base.get_url(route))
        Method = data[141]["method"]
        params = eval(data[141]["params"])
        res = get_this_week_list.BetRecord().get_betrecord_list().json(
        )["data"]["list"]
        for d in res:
            date = d["date"]["date"]
            params["date"] = date
            headers = {"Authorization": get_token.GetRes().get_res()}
            kwargs = {"params": params, "headers": headers}
            resp = base.get_response(url, Method, **kwargs)
            self.log.info("----------test is start----------")
            self.log.info("请求的接口地址为: %s" % resp.url)
            self.log.info("请求的参数为: %s" % kwargs)
            self.log.info("响应内容为: %s" % resp.json())
            self.log.info("响应状态码为: %s" % resp.status_code)
            self.assertEqual(data[141]["expect"],
                             resp.json()["message"],
                             msg="失败原因为%s != %s" %
                             (data[141]["expect"], resp.json()["message"]))
            self.log.info("----------test is pass----------")
            self.log.info("----------test is end----------")
示例#3
0
    def get_res(self, threshold=120):
        '''获取token响应'''
        while True:
            route = data[0]["route"]
            url = "".join(base.get_url(route))
            Method = data[0]["method"]
            json_data = eval(data[0]["data"])

            # ------获取验证码------
            code_url = cof.get_codeurl()
            while True:
                res = requests.get(code_url).json()["data"]
                captcha_image_text = res["captcha_image_text"].split(',')[
                    1]  # 获取图片
                image_data = base64.b64decode(captcha_image_text)
                img_path = os.path.dirname(
                    os.path.dirname(__file__)) + "/code.jpeg"
                with open(img_path, 'wb') as f:
                    f.write(image_data)
                table = []
                for i in range(256):
                    if i < threshold:
                        table.append(0)
                    else:
                        table.append(1)
                im = Image.open(img_path)
                # 图片的处理过程
                im = im.convert('L')
                binaryImage = im.point(table, '1')
                im1 = binaryImage.convert('L')
                im2 = PIL.ImageOps.invert(im1)
                im3 = im2.convert('1')
                im4 = im3.convert('L')
                # 将图片中字符裁剪保留
                box = (10, -5, 135, 50)
                region = im4.crop(box)
                # 将图片字符放大
                out = region.resize((200, 60))
                code = pytesseract.image_to_string(out)  # 验证码
                if len(code) != 4 or random.choice(
                        string.ascii_letters +
                        '/\{}[]?<>,.!@#$%^&*() +=-_') in code:
                    print("验证码获取错误%s,正在重新获取..." % code)
                    time.sleep(1)
                    continue
                else:
                    break
            captcha_key = res["captcha_key"]
            json_data["code"] = code  # 验证码
            json_data["captcha_key"] = captcha_key
            kwargs = {"json": json_data}
            try:
                res = base.get_response(url, Method, **kwargs).json()["data"]
            except Exception as e:
                continue
            else:
                return res["token"]
示例#4
0
 def get_res(self):
     '''获取token响应'''
     route = data[0]["route"]
     url = "".join(base.get_url(route))
     Method = data[0]["method"]
     headers = eval(data[0]["header"])
     kwargs = {"headers": headers}
     res = base.get_response(url, Method, **kwargs)
     return res
示例#5
0
 def get_key(self):
     '''获取key,用到后面游戏跳转'''
     route = data[0]["route"]
     url = "".join(base.get_url(route))
     Method = "get"
     headers = {"x-token":eval(get_res.GetRes().get_res().text)['data']['token']}
     params = eval(data[0]["params"])
     kwargs = {"params": params,"headers":headers}
     res = base.get_response(url, Method, **kwargs)
     return res
示例#6
0
 def get_gameid(self):
     '''获取providers信息'''
     route = data[1]["route"]
     url = "".join(base.get_url(route))
     Method = data[1]["method"]
     headers = {
         "x-token": eval(get_res.GetRes().get_res().text)['data']['token']
     }
     kwargs = {"headers": headers}
     resp = base.get_response(url, Method, **kwargs)
     return resp
示例#7
0
	def get_betrecord_list(self):
		'''获取本周视讯注单列表'''
		route = data[84]["route"]
		url = "".join(base.get_url(route))
		Method = data[84]["method"]
		params = eval(data[84]["params"])
		today = datetime.date.today()
		params["time_start"] = today - datetime.timedelta(days=today.weekday())  # 周一,开始时间
		params["time_end"] = today  # 今天,结束时间
		headers = {"Authorization": self.token}
		kwargs = {"params": params, "headers": headers}
		resp = base.get_response(url, Method, **kwargs)
		return resp
示例#8
0
    def get_gameurl(self):
        '''获取游戏大厅url,进行跳转'''
        res = get_res.GetRes().get_res().text  # 调用get_res模块,获取包含token的响应
        token = eval(res)["data"]["token"]  # 获取token
        route = data[2]["route"]
        url = "".join(base.get_url(route))
        Method = data[2]["method"]
        params = {"key":eval(get_key.GetKey().get_key().text)["data"]["key"]}
        headers = {"x-token":token}
        kwargs = {"params": params, "headers": headers}
        resp = base.get_response(url,Method,**kwargs)

        return resp
示例#9
0
	def test_login(self):
		route = data[0]["route"]
		url = "".join(base.get_url(route))
		Method = data[0]["method"]
		headers = {"Authorization":self.token}
		kwargs = {"headers": headers}
		resp = base.get_response(url, Method, **kwargs)
		self.log.info("----------test is start----------")
		self.log.info("请求的接口地址为: %s" % url)
		self.log.info("请求的参数为: %s" % kwargs)
		self.log.info("响应内容为: %s" % resp.text)
		self.log.info("响应状态码为: %s" % resp.status_code)
		self.assertIn(data[0]["expect"], resp.text, msg="失败原因为%s not in %s" % (data[0]["expect"], resp.text))
		self.log.info("----------test is pass----------")
		self.log.info("----------test is end----------")
示例#10
0
 def test_play_game(self):
     '''获取游戏大厅url,进行跳转'''
     route = data[4]["route"]
     url = "".join(base.get_url(route))
     params = {"key":eval(get_key.GetKey().get_key().text)["data"]["key"]}
     headers = {"x-token":self.token}
     kwargs = {"params": params, "headers": headers}
     resp = get_gameurl.GameUrl().get_gameurl()
     self.log.info("----------test is start----------")
     self.log.info("请求的接口地址为: %s" % url)
     self.log.info("请求的参数为: %s" % kwargs)
     self.log.info("响应内容为: %s" % resp.text)
     self.log.info("响应状态码为: %s" % resp.status_code)
     self.assertIn(data[4]["expect"], resp.text, msg="失败原因为%s not in %s" % (data[4]["expect"], resp.text))
     self.log.info("----------test is pass----------")
     self.log.info("----------test is end----------")
示例#11
0
 def test_getactivitylist(self):
     route = data[29]["route"]
     url = "".join(base.get_url(route))
     Method = data[29]["method"]
     params = eval(data[29]["params"])
     headers = {"Authorization": self.token}
     kwargs = {"params": params, "headers": headers}
     resp = base.get_response(url, Method, **kwargs)
     self.log.info("----------test is start----------")
     self.log.info("请求的接口地址为: %s" % url)
     self.log.info("请求的参数为: %s" % kwargs)
     self.log.info("响应内容为: %s" % resp.text)
     self.log.info("响应状态码为: %s" % resp.status_code)
     self.assertEqual(data[29]["expect"],
                      resp.json()["message"],
                      msg="失败原因为%s not in %s" %
                      (data[29]["expect"], resp.json()["message"]))
     self.log.info("----------test is pass----------")
     self.log.info("----------test is end----------")
 def test_in_balance(self):
     '''测试会员转账(in)'''
     route = data[6]["route"]
     url = "".join(base.get_url(route))
     Method = data[6]["method"]
     headers = {
         "x-token": self.token
     }
     json = eval(data[6]["data"])
     kwargs = {"json":json,"headers":headers}
     resp = base.get_response(url,Method,**kwargs)
     self.log.info("----------test is start----------")
     self.log.info("请求的接口为: %s" % url)
     self.log.info("请求的参数为: %s" % kwargs)
     self.log.info("响应内容为: %s" % resp.text)
     self.log.info("响应状态码为: %s" % resp.status_code)
     self.assertIn(data[6]["expect"], resp.text, msg="失败原因为%s not in %s" % (data[6]["expect"], resp.text))
     self.log.info("----------test is pass----------")
     self.log.info("----------test is end----------")
示例#13
0
 def test_get_balance(self):
     '''测试查询会员余额'''
     route = data[8]["route"]
     params = data[8]["params"]
     url = "".join(base.get_url(route)) + "?" + str(params)  # 把会员名拼接到url中进行请求
     Method = data[8]["method"]
     headers = {
         "x-token": self.token
     }
     kwargs = {"headers": headers}
     resp = base.get_response(url, Method, **kwargs)
     self.log.info("----------test is start----------")
     self.log.info("请求的接口地址为: %s" % url)
     self.log.info("请求的参数为: %s" % kwargs)
     self.log.info("响应内容为: %s" % resp.text)
     self.log.info("响应状态码为: %s" % resp.status_code)
     self.assertIn(data[8]["expect"], resp.text, msg="失败原因为%s not in %s" % (data[8]["expect"], resp.text))
     self.log.info("----------test is pass----------")
     self.log.info("----------test is end----------")
示例#14
0
 def get_betrecord_list(self):
     '''获取上月视讯注单列表'''
     route = data[123]["route"]
     url = "".join(base.get_url(route))
     Method = data[123]["method"]
     params = eval(data[123]["params"])
     date = datetime.datetime.now()
     year = date.year
     month = date.month
     if month == 1:
         start = datetime.date(year - 1, 12, 1)
     else:
         start = datetime.date(year, month - 1, 1)
     end = datetime.date(year, month, 1) - datetime.timedelta(days=1)
     params["time_start"] = start
     params["time_end"] = end
     headers = {"Authorization": self.token}
     kwargs = {"params": params, "headers": headers}
     resp = base.get_response(url, Method, **kwargs)
     return resp
示例#15
0
 def test_login_data_error(self, threshold=120):
     route = data[1]["route"]
     url = "".join(base.get_url(route))
     Method = data[1]["method"]
     json_data = eval(data[1]["data"])
     # ------获取验证码------
     code_url = cof.get_codeurl()
     while True:
         res = requests.get(code_url).json()["data"]
         captcha_image_text = res["captcha_image_text"].split(',')[
             1]  # 获取图片
         image_data = base64.b64decode(captcha_image_text)
         img_path = os.path.dirname(
             os.path.dirname(__file__)) + "/code.jpeg"
         with open(img_path, 'wb') as f:
             f.write(image_data)
         table = []
         for i in range(256):
             if i < threshold:
                 table.append(0)
             else:
                 table.append(1)
         im = Image.open(img_path)
         # 图片的处理过程
         im = im.convert('L')
         binaryImage = im.point(table, '1')
         im1 = binaryImage.convert('L')
         im2 = PIL.ImageOps.invert(im1)
         im3 = im2.convert('1')
         im4 = im3.convert('L')
         # 将图片中字符裁剪保留
         box = (10, -5, 135, 50)
         region = im4.crop(box)
         # 将图片字符放大
         out = region.resize((200, 60))
         code = pytesseract.image_to_string(out)  # 验证码
         if len(code) != 4 or random.choice(
                 string.ascii_letters +
                 '/\{}[]?<>,.!@#$%^&*() +=-_') in code:
             print("验证码获取错误%s,正在重新获取..." % code)
             time.sleep(1)
             continue
         else:
             break
     captcha_key = res["captcha_key"]
     json_data["code"] = code  # 验证码
     json_data["captcha_key"] = captcha_key
     kwargs = {"json": json_data}
     resp = base.get_response(url, Method, **kwargs)
     self.log.info("----------test is start----------")
     self.log.info("请求的接口地址为: %s" % url)
     self.log.info("请求的参数为: %s" % kwargs)
     self.log.info("响应内容为: %s" % resp.text)
     self.log.info("响应状态码为: %s" % resp.status_code)
     self.assertIn(
         resp.json()["message"].replace("'\'", "'\\'"),
         data[1]["expect"],
         msg="失败原因为%s not in %s" %
         (resp.json()["message"].replace("'\'", "'\\'"), data[1]["expect"]))
     self.log.info("----------test is pass----------")
     self.log.info("----------test is end----------")
示例#16
0
 def setUp(self):
     interface_path = 'get'
     self.url = base.get_url(interface_path)
     logger.info("接口地址:{a}".format(a=self.url))