import pytest

from ids_list import get_ids
import path_setting
from in_common.base_request import BaseRequest
from all_backend_api.xcx_request import xcx_request

# 获取测颜值结果页小程序二维码
class TestGengmeiGetWxacodeUnlimited:
    data = BaseRequest().api_load(path_setting.XCX_GENGMEI_GET_WXACODE_UNLIMITED_DATA)
    genbgmeiGetWxacodeUmlimited_case, gengmeiGetWxacodeUmlimited_data = get_ids(data, "gengmei_get_wxacode_unlimited")

    # @pytest.mark.skip("测颜值返回二维码，目前测试环境报错，只能跑线上的-------------------")
    @pytest.mark.fail
    @pytest.mark.parametrize("param",gengmeiGetWxacodeUmlimited_data,ids=genbgmeiGetWxacodeUmlimited_case)
    def test_get_wxacode_umlinited(self,param):
        r = xcx_request().gengmei_get_wxacode_unlimited(param["page"], param["scene"])
        if r["error"] == 0:
            image_url = r["data"]["url"]
            print(image_url)

            import requests
            resp = requests.get(url=image_url, verify=False)
            print(resp.text)
            # 判断返回是否有报错信息，否则是一张图片
            assert "errcode"not in resp.text, f'测颜值返回二维码图片不可用'




