def test_dynamic_report_reason_is_null(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) dynamic_report_api = DynamicReportApi(self.user_mobile) dynamic_report_api.get({'dynamic_id': dynamic_id, 'reason': None}) self.assertEqual(dynamic_report_api.get_code(), 450008) self.assertEqual(dynamic_report_api.get_response_message(), u'举报原因不能为空')
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 test_publish_dynamic_video(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) anchor_dynamic = json.loads( response.content)['result']['dynamic_list'][0] 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/#####')
def test_publish_comment_word_number_restriction(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': '一二' * 75 + '。', 'reply_user_id': None, 'type': 1 }) self.assertEqual(publish_comment_api.get_code(), 450019) self.assertEqual(publish_comment_api.get_response_message(), u'超过限制的字输入无效') publish_comment_api = PublishCommentApi(self.user_mobile) publish_comment_api.get({ 'dynamic_id': dynamic_id, 'comment': 'ab' * 75 + '.', 'reply_user_id': None, 'type': 1 }) self.assertEqual(publish_comment_api.get_code(), 450019) self.assertEqual(publish_comment_api.get_response_message(), u'超过限制的字输入无效')
def test_publish_dynamic_video_url_is_null(self): """ 测试请求接口视频为空 :return: """ publish_dynamic_api = PublishDynamicApi(self.anchor_mobile) publish_dynamic_api.get({ 'type': 2, 'image_urls': None, 'video_url': None, 'content': None, 'first_frame': None }) self.assertEqual(publish_dynamic_api.get_code(), 450005) self.assertEqual(publish_dynamic_api.get_response_message(), u'请上传动态中的视频')
def test_publish_dynamic_type_error(self): """ 测试请求接口动态类型错误 :return: """ publish_dynamic_api = PublishDynamicApi(self.anchor_mobile) publish_dynamic_api.get({ 'type': 55, 'image_urls': None, 'video_url': self.video_url, 'content': None, 'first_frame': None }) self.assertEqual(publish_dynamic_api.get_code(), 450001) self.assertEqual(publish_dynamic_api.get_response_message(), u'上传文件类型不能为空')
def test_dynamic_report(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) dynamic_report_api = DynamicReportApi(self.user_mobile) dynamic_report_api.get({ 'dynamic_id': dynamic_id, 'reason': self.reason }) self.assertEqual(dynamic_report_api.get_code(), 0) time.sleep(5) db_reason = MysqlOperation( user_id=self.user_id, anchor_id=self.anchor_id).get_user_dynamic_report_reason() self.assertEqual(db_reason, self.reason)
def test_publish_comment_not_bind_mobile(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.no_bind_mobile_user) publish_comment_api.get({ 'dynamic_id': dynamic_id, 'comment': '测试动态评论接口', 'reply_user_id': None, 'type': 1 }) self.assertEqual(publish_comment_api.get_code(), 450020) self.assertEqual(publish_comment_api.get_response_message(), 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_publish_comment_type_error(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': 333 }) self.assertEqual(publish_comment_api.get_code(), 450014) self.assertEqual(publish_comment_api.get_response_message(), u'评论类型不正确')
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_remove_comment(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_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_num = json.loads(response.content)['result']['comment_num'] self.assertEqual(comment_num, 1) comment_obj_list = json.loads( response.content)['result']['comment_obj_list'] self.assertEqual(len(comment_obj_list), 1) comment_id = comment_obj_list[0]['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]['comment_num'], 1) remove_comment_api = RemoveCommentApi(self.user_mobile_two) remove_comment_api.get({'comment_id': comment_id}) self.assertEqual(remove_comment_api.get_code(), 450012) self.assertEqual(remove_comment_api.get_response_message(), u'没有删除权限') remove_comment_api = RemoveCommentApi(self.user_mobile) remove_comment_api.get({'comment_id': comment_id}) self.assertEqual(remove_comment_api.get_code(), 0) 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_num = json.loads(response.content)['result']['comment_num'] self.assertEqual(comment_num, 0) comment_obj_list = json.loads( response.content)['result']['comment_obj_list'] self.assertEqual(len(comment_obj_list), 0) 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]['comment_num'], 0)
def test_publish_comment_reply(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) publish_comment_api = PublishCommentApi(self.user_mobile_two) publish_comment_api.get({ 'dynamic_id': dynamic_id, 'comment': '测试回复评论', 'reply_user_id': self.user_id, 'type': 2 }) self.assertEqual(publish_comment_api.get_code(), 0) MysqlOperation(user_id=self.user_id_two).fix_dynamic_comment_status( status=1, dynamic_id=dynamic_id) time.sleep(0.5) 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_num = json.loads(response.content)['result']['comment_num'] self.assertEqual(comment_num, 2) comment_obj_list = json.loads( response.content)['result']['comment_obj_list'] self.assertEqual(len(comment_obj_list), 2) for x in comment_obj_list: self.assertEqual(int(x['dynamic_id']), int(dynamic_id)) self.assertEqual(x['status'], u'1') self.assertEqual(x['create_time_str'], u'刚刚') self.assertEqual(comment_obj_list[0]['user_id'], (self.user_id_two)) self.assertEqual(comment_obj_list[0]['comment'], u'测试回复评论') self.assertEqual(comment_obj_list[0]['reply_user_id'], (self.user_id)) self.assertEqual(comment_obj_list[0]['type'], u'2') self.assertEqual(comment_obj_list[0]['user_nickname'], (MysqlOperation( user_id=self.user_id_two).get_user_details()['nickname'])) self.assertEqual( comment_obj_list[0]['reply_user_nickname'], (MysqlOperation( user_id=self.user_id).get_user_details()['nickname'])) self.assertEqual(comment_obj_list[1]['user_id'], (self.user_id)) self.assertEqual(comment_obj_list[1]['comment'], u'测试动态评论接口') self.assertEqual(comment_obj_list[1]['type'], u'1') self.assertEqual(comment_obj_list[1]['user_nickname'], (MysqlOperation( user_id=self.user_id).get_user_details()['nickname'])) self.assertEqual(comment_obj_list[1]['create_time_str'], u'刚刚') comment_id = comment_obj_list[0]['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]['comment_num'], 2) 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) comment_num = json.loads( response.content)['result']['dynamic_list'][0]['comment_num'] self.assertEqual(comment_num, 2) 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_num = json.loads(response.content)['result']['comment_num'] self.assertEqual(comment_num, 2) comment_obj_list = json.loads( response.content)['result']['comment_obj_list'] self.assertEqual(len(comment_obj_list), 2) remove_comment_api = RemoveCommentApi(self.user_mobile_two) remove_comment_api.get({'comment_id': comment_id}) self.assertEqual(remove_comment_api.get_code(), 0) 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_num = json.loads(response.content)['result']['comment_num'] self.assertEqual(comment_num, 1) comment_obj_list = json.loads( response.content)['result']['comment_obj_list'] self.assertEqual(len(comment_obj_list), 1) 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) comment_num = json.loads( response.content)['result']['dynamic_list'][0]['comment_num'] self.assertEqual(comment_num, 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]['comment_num'], 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/#####')