Ejemplo n.º 1
0
 def test_researchreport_list_01(self):
     """参数有tycoon_id,返回大咖主页研报"""
     timeStamp = int(time.mktime(datetime.now().timetuple()))
     data = '{"app_version":"%(version)s",' \
            '"os_type":1,' \
            '"os_version":"9",' \
            '"mac_address":"02:00:00:00:00:00",' \
            '"device_id":"802ca0fba119ab0a",' \
            '"tycoon_id":%(tycoon_id)d,' \
            '"query_type":"all",' \
            '"timestamp":%(timeStamp)d,' \
            '"app_key":"%(app_key)s"' \
            '}' % {
                'version': version,
                'tycoon_id': self.researchreport_detail["tycoon_id"],
                'timeStamp': timeStamp,
                'app_key': app_key}
     sign = get_Sign().encrypt(data, True)["sign"]
     data = data.replace('}', ',"sign":"%s"}' % sign)
     crypt_data = aes.encrypt(data, 'c_q')
     form = {'data': crypt_data, 'encode': 'v1'}
     response = requests.post(self.url, data=json.dumps(form), headers=headers)
     researchreport_all = RunMain().decrypt_to_dict(response, 'r')
     # - charge 列表为收费研报
     # - free  列表为免费研报
     title_list = []
     for free_page in ["free", "charge"]:
         if free_page in researchreport_all.keys():
             for researchreport in researchreport_all[free_page]:
                 title_list.append(researchreport["title"])
     msg = f'大咖id为{self.researchreport_detail["tycoon_id"]},大咖的研报应该包含{self.researchreport_detail["title"]}'
     self.assertIn(self.researchreport_detail["title"], title_list, msg)
Ejemplo n.º 2
0
 def get_response_tycoon_video(self, response):
     video_id_list = []
     video_all = RunMain().decrypt_to_dict(response, 'r')
     for key in video_all.keys():
         for video in video_all[key]:
             video_id_list.append(video["id"])
     return video_id_list