def test_publish_comment_sensitive_words(self): """ 测试动态评论敏感词 :return: """ publish_dynamic_api = PublishDynamicApi(self.anchor_mobile) publish_dynamic_api.get({ 'type': 2, 'image_urls': None, 'video_url': self.video_url, 'content': self.content, 'first_frame': self.pic_url }) self.assertEqual(publish_dynamic_api.get_code(), 0) # 校验主播自己的个人主页里面是否显示该动态 get_home_page_dynamic_list_api = GetHomePageDynamicApi( self.anchor_mobile) response = get_home_page_dynamic_list_api.get( {'anchor_id': self.anchor_id}) self.assertEqual(get_home_page_dynamic_list_api.get_code(), 0) dynamic_id = json.loads( response.content)['result']['dynamic_list'][0]['id'] self.dynamic_ids.append(dynamic_id) # 审核动态 Redis().check_anchor_dynamic(dynamic_id) publish_comment_api = PublishCommentApi(self.user_mobile) publish_comment_api.get({ 'dynamic_id': dynamic_id, 'comment': '习近平', 'reply_user_id': None, 'type': 1 }) self.assertEqual(publish_comment_api.get_code(), 0) MysqlOperation(user_id=self.user_id).fix_dynamic_comment_status( status=1, dynamic_id=dynamic_id) time.sleep(0.5) # 动态详情 get_dynamic_detail_api = GetDynamicDetailApi(self.user_mobile) response = get_dynamic_detail_api.get({'dynamic_id': dynamic_id}) self.assertEqual(get_dynamic_detail_api.get_code(), 0) comment_num = json.loads( response.content)['result']['dynamic_obj']['comment_num'] self.assertEqual(comment_num, 1) get_comment_list_api = GetCommentListApi(self.user_mobile) response = get_comment_list_api.get({'dynamic_id': dynamic_id}) self.assertEqual(get_comment_list_api.get_code(), 0) comment_obj_list = json.loads( response.content)['result']['comment_obj_list'] self.assertEqual(len(comment_obj_list), 1) self.assertEqual(comment_obj_list[0]['comment'], u'***')
def flow_path(self,**kwargs): over_due_time = kwargs['over_due_time'] hint = kwargs['hint'] publish_dynamic_api = PublishDynamicApi(self.anchor_mobile) publish_dynamic_api.get({'type': 2, 'image_urls': None, 'video_url': self.video_url, 'content': self.content, 'first_frame': self.pic_url}) self.assertEqual(publish_dynamic_api.get_code(), 0) get_home_page_dynamic_list_api = GetHomePageDynamicApi(self.anchor_mobile) response = get_home_page_dynamic_list_api.get({'anchor_id': self.anchor_id}) self.assertEqual(get_home_page_dynamic_list_api.get_code(), 0) anchor_dynamic_list = json.loads(response.content)['result']['dynamic_list'] for x in anchor_dynamic_list: self.dynamic_ids.append(x['id']) self.assertEqual(len(anchor_dynamic_list),1) dynamic_id = anchor_dynamic_list[0]['id'] Redis().check_anchor_dynamic(dynamic_id) created_time = int(time.time()) - over_due_time Redis().fix_dynamic_created_time(dynamic_id=dynamic_id,created_time=created_time) time.sleep(1) get_square_dynamic_api = GetSquareDynamicApi(self.user_mobile) response = get_square_dynamic_api.get() self.assertEqual(get_square_dynamic_api.get_code(), 0) dynamic_list = json.loads(response.content)['result']['dynamic_list'] self.assertEqual(dynamic_list[0]['create_time_str'],hint) get_home_page_dynamic_list_api = GetHomePageDynamicApi(self.anchor_mobile) response = get_home_page_dynamic_list_api.get({'anchor_id': self.anchor_id}) self.assertEqual(get_home_page_dynamic_list_api.get_code(), 0) anchor_dynamic = json.loads(response.content)['result']['dynamic_list'][0] self.assertEqual(anchor_dynamic['create_time_str'],hint) get_dynamic_detail_api = GetDynamicDetailApi(self.user_mobile) response = get_dynamic_detail_api.get({'dynamic_id': dynamic_id}) self.assertEqual(get_dynamic_detail_api.get_code(), 0) self.assertEqual(json.loads(response.content)['result']['dynamic_obj']['create_time_str'],hint)
def test_dynamic_id_is_error(self): """ 测试请求接口动态ID不存在 :return: """ get_dynamic_detail_api = GetDynamicDetailApi(self.user_mobile) get_dynamic_detail_api.post({'dynamic_id': 9090999}) self.assertEqual(get_dynamic_detail_api.get_code(), 450010) self.assertEqual(get_dynamic_detail_api.get_response_message(), u'动态不存在')
def test_dynamic_id_is_null(self): """ 测试请求接口动态ID为空 :return: """ get_dynamic_detail_api = GetDynamicDetailApi(self.user_mobile) get_dynamic_detail_api.post({'dynamic_id': None}) self.assertEqual(get_dynamic_detail_api.get_code(), 450007) self.assertEqual(get_dynamic_detail_api.get_response_message(), u'动态id不能为空')
def test_dynamic_upvote(self): """ 测试动态点赞成功 :return: """ # 发布动态 publish_dynamic_api = PublishDynamicApi(self.anchor_mobile) publish_dynamic_api.get({ 'type': 2, 'image_urls': None, 'video_url': self.video_url, 'content': self.content, 'first_frame': self.pic_url }) self.assertEqual(publish_dynamic_api.get_code(), 0) # 验证个人主页中动态信息 get_home_page_dynamic_list_api = GetHomePageDynamicApi( self.anchor_mobile) response = get_home_page_dynamic_list_api.get( {'anchor_id': self.anchor_id}) self.assertEqual(get_home_page_dynamic_list_api.get_code(), 0) anchor_dynamic_list = json.loads( response.content)['result']['dynamic_list'] for x in anchor_dynamic_list: self.dynamic_ids.append(x['id']) self.assertEqual(anchor_dynamic_list[0]['upvote_num'], 0) self.assertEqual(anchor_dynamic_list[0]['is_upvote_by_me'], 0) dynamic_id = json.loads( response.content)['result']['dynamic_list'][0]['id'] Redis().check_anchor_dynamic(dynamic_id) # 验证广场页面动态信息 get_square_dynamic_api = GetSquareDynamicApi(self.user_mobile) response = get_square_dynamic_api.get() self.assertEqual(get_square_dynamic_api.get_code(), 0) dynamic_list = json.loads(response.content)['result']['dynamic_list'] self.assertEqual(dynamic_list[0]['id'], dynamic_id) self.assertEqual(dynamic_list[0]['upvote_num'], 0) self.assertEqual(dynamic_list[0]['status'], 1) self.assertEqual(dynamic_list[0]['is_upvote_by_me'], 0) # 点赞 upvote_api = UpvoteApi(self.user_mobile) upvote_api.get({'dynamic_id': dynamic_id}) self.assertEqual(upvote_api.get_code(), 0) # 校验点赞 get_home_page_dynamic_list_api = GetHomePageDynamicApi( self.anchor_mobile) response = get_home_page_dynamic_list_api.get( {'anchor_id': self.anchor_id}) self.assertEqual(get_home_page_dynamic_list_api.get_code(), 0) self.assertEqual( json.loads( response.content)['result']['dynamic_list'][0]['upvote_num'], 1) self.assertEqual( json.loads(response.content)['result']['dynamic_list'][0] ['is_upvote_by_me'], 0) self.assertEqual( json.loads( response.content)['result']['dynamic_list'][0]['status'], 1) get_square_dynamic_api = GetSquareDynamicApi(self.user_mobile) response = get_square_dynamic_api.get() self.assertEqual(get_square_dynamic_api.get_code(), 0) dynamic_list = json.loads(response.content)['result']['dynamic_list'] self.assertEqual(dynamic_list[0]['id'], dynamic_id) self.assertEqual(dynamic_list[0]['upvote_num'], 1) get_dynamic_detail_api = GetDynamicDetailApi(self.user_mobile) response = get_dynamic_detail_api.get({'dynamic_id': dynamic_id}) self.assertEqual(get_dynamic_detail_api.get_code(), 0) dynamic_obj = json.loads(response.content)['result']['dynamic_obj'] self.assertEqual(dynamic_obj['upvote_num'], 1) self.assertEqual(dynamic_obj['is_upvote_by_me'], 1)
def test_get_dynamic_details(self): """ 测试动态详情接口 :return: """ # 发动态 publish_dynamic_api = PublishDynamicApi(self.anchor_mobile) publish_dynamic_api.get({ 'type': 2, 'image_urls': None, 'video_url': self.video_url, 'content': self.content, 'first_frame': self.pic_url }) self.assertEqual(publish_dynamic_api.get_code(), 0) # 校验主播自己的个人主页里面是否显示该动态 get_home_page_dynamic_list_api = GetHomePageDynamicApi( self.anchor_mobile) response = get_home_page_dynamic_list_api.get( {'anchor_id': self.anchor_id}) self.assertEqual(get_home_page_dynamic_list_api.get_code(), 0) anchor_dynamic_list = json.loads( response.content)['result']['dynamic_list'] for x in anchor_dynamic_list: self.dynamic_ids.append(x['id']) self.assertEqual(len(anchor_dynamic_list), 1) dynamic_id = anchor_dynamic_list[0]['id'] # 审核动态 Redis().check_anchor_dynamic(dynamic_id) # 动态详细 get_dynamic_detail_api = GetDynamicDetailApi(self.user_mobile) response = get_dynamic_detail_api.get({'dynamic_id': dynamic_id}) self.assertEqual(get_dynamic_detail_api.get_code(), 0) self.assertEqual( json.loads(response.content)['result']['has_upvoted'], 0) anchor_dynamic = json.loads(response.content)['result']['dynamic_obj'] self.assertEqual(anchor_dynamic['user_id'], self.anchor_id) self.assertEqual(anchor_dynamic['image_urls'], u'') self.assertIn((self.video_url[0]), anchor_dynamic['video_url']) self.assertEqual(anchor_dynamic['upvote_num'], 0) self.assertEqual(anchor_dynamic['content'], self.content) self.assertEqual(anchor_dynamic['status'], 1) self.assertEqual(anchor_dynamic['has_followed'], 0) self.assertEqual(anchor_dynamic['show_red_point'], 0) self.assertEqual(anchor_dynamic['reason'], u'') self.assertIsNotNone(anchor_dynamic['first_frame']) self.assertEqual(anchor_dynamic['is_upvote_by_me'], 0) self.assertEqual(anchor_dynamic['create_time_str'], u'刚刚') self.assertEqual(anchor_dynamic['type'], 2) self.assertIsNotNone(anchor_dynamic['small_head_url']) self.assertEqual(anchor_dynamic['room_id'], int(self.room_id)) self.assertIsNotNone(anchor_dynamic['first_frame']) share_list = anchor_dynamic['share_list'] self.assertIsNotNone(share_list['share_title']) self.assertIsNotNone(share_list['share_content']) self.assertEqual( share_list['share_url'], u'https://yl.t.dwtv.tv/h5share/dynamic/dynamic_id/#####')