def test_cannot_retrieve_private_community_not_part_of_post_media_video( self): """ should not be able to retrieve an private_community not part of post media video """ user = make_user() community_creator = make_user() private_community = make_community( creator=community_creator, type=Community.COMMUNITY_TYPE_PRIVATE) headers = make_authentication_headers_for_user(user=user) test_video = get_test_video() with open(test_video['path'], 'rb') as file: file = File(file) post = community_creator.create_community_post( video=file, community_name=private_community.name) get_worker('high', worker_class=SimpleWorker).work(burst=True) url = self._get_url(post=post) response = self.client.get(url, **headers, format='multipart') self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)
def test_cant_retrieve_pending_connection_user_user_encircled_post_media_video( self): """ should be able to retrieve an pending_connection_user_user encircled post media video """ user = make_user() pending_connection_user_user = make_user() pending_connection_user_user.connect_with_user_with_id(user_id=user.pk) headers = make_authentication_headers_for_user(user=user) test_video = get_test_video() with open(test_video['path'], 'rb') as file: file = File(file) circle = make_circle(creator=pending_connection_user_user) post = pending_connection_user_user.create_encircled_post( video=file, circles_ids=[circle.pk]) get_worker('high', worker_class=SimpleWorker).work(burst=True) url = self._get_url(post=post) response = self.client.get(url, **headers, format='multipart') self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)
def test_can_retrieve_follower_user_post_media_video(self): """ should be able to retrieve an follower_user post media video """ user = make_user() follower_user = make_user() follower_user.follow_user(user=user) headers = make_authentication_headers_for_user(user=user) test_video = get_test_video() with open(test_video['path'], 'rb') as file: file = File(file) post = follower_user.create_public_post(video=file) get_worker('high', worker_class=SimpleWorker).work(burst=True) url = self._get_url(post=post) response = self.client.get(url, **headers, format='multipart') self.assertEqual(response.status_code, status.HTTP_200_OK) response_media = json.loads(response.content) post.refresh_from_db() post_media = post.get_media().all() self._compare_response_media_with_post_media( post_media=post_media, response_media=response_media)
def test_can_retrieve_private_community_part_of_post_media_video(self): """ should be able to retrieve an private_community part of post media video """ user = make_user() community_creator = make_user() private_community = make_community( creator=community_creator, type=Community.COMMUNITY_TYPE_PRIVATE) community_creator.invite_user_with_username_to_community_with_name( community_name=private_community.name, username=user.username) user.join_community_with_name(community_name=private_community.name) headers = make_authentication_headers_for_user(user=user) test_video = get_test_video() with open(test_video['path'], 'rb') as file: file = File(file) post = community_creator.create_community_post( video=file, community_name=private_community.name) get_worker('high', worker_class=SimpleWorker).work(burst=True) url = self._get_url(post=post) response = self.client.get(url, **headers, format='multipart') self.assertEqual(response.status_code, status.HTTP_200_OK) response_media = json.loads(response.content) post.refresh_from_db() post_media = post.get_media().all() self._compare_response_media_with_post_media( post_media=post_media, response_media=response_media)
def test_can_retrieve_connected_user_post_media_video(self): """ should be able to retrieve an connected_user post media video """ user = make_user() connected_user = make_user() circle = make_circle(creator=connected_user) connected_user.connect_with_user_with_id(user_id=user.pk, circles_ids=[circle.pk]) user.confirm_connection_with_user_with_id(user_id=connected_user.pk) headers = make_authentication_headers_for_user(user=user) test_video = get_test_video() with open(test_video['path'], 'rb') as file: file = File(file) post = connected_user.create_encircled_post( video=file, circles_ids=[circle.pk]) get_worker('high', worker_class=SimpleWorker).work(burst=True) url = self._get_url(post=post) response = self.client.get(url, **headers, format='multipart') self.assertEqual(response.status_code, status.HTTP_200_OK) response_media = json.loads(response.content) post.refresh_from_db() post_media = post.get_media().all() self._compare_response_media_with_post_media( post_media=post_media, response_media=response_media)