def setUp(self): self.user = create_user() self.sub = create_sub(self.user) #create a bunch of posts some with similiar communities #for the response to actually return the expected filtered #objects self.post1 = create_post(self.sub) self.post1.communities.add('undertaker', 'wwe', 'wrestling') self.post2 = create_post(self.sub) self.post2.communities.add('undertaker', 'cm punk', 'testing') self.post3 = create_post(self.sub) self.post3.communities.add('undertaker', 'keyfabe', 'testing') self.post4 = create_post(self.sub) self.post4.communities.add('america', '4 of july') self.post5 = create_post(self.sub) self.post5.communities.add('navy', 'military') self.client = APIClient() self.path = '/api/v1/posts/search/{0}/'.format('undertaker wwe') self.serializer = PostSerializer
def setUp(self): self.user = create_user() self.sub = create_sub(self.user) self.post = create_post(self.sub) self.commentfeed = CommentFeed.objects.create(post=self.post) self.first_comment = create_original_comment(self.post, self.sub) self.expected_data1 = { 'uuid': self.first_comment.get_uuid_as_string, 'liked': None, 'reported': None, 'date': self.first_comment.get_date_posted, 'parent_comment': self.first_comment.get_parent_comment, 'owner': self.first_comment.get_owner_info, 'has_parent': False, 'is_original': True, 'text': self.first_comment.text, 'likes': self.first_comment.likes, 'reports': self.first_comment.reports, 'id': self.first_comment.id } self.expected_data2 = self.expected_data1.copy() self.expected_data2['liked'] = False self.expected_data2['reported'] = False self.serializer = OriginalCommentSerializer
def setUp(self): self.user = create_user() self.sub = create_sub(self.user) self.post = create_post(self.sub) self.first_comment = create_original_comment(self.post, self.sub) self.commentfeed = CommentFeed.objects.first() self.child_comment = Comment.objects.create( text="text", owner=self.sub, commentfeed=self.commentfeed, is_original=False) self.child_comment2 = Comment.objects.create( text="this is the second child comment", owner=self.sub, commentfeed=self.commentfeed, is_original=False, has_parent=True, parent_comment=self.child_comment) Comment.objects.create(text="this is the text", commentfeed=self.commentfeed, parent_comment=self.child_comment, owner=self.sub, is_original=False, has_parent=True) self.serializer = ChildCommentSerializer
def setUp(self): self.user = create_user() self.sub = create_sub(self.user) self.post = create_post(self.sub) self.path = '/api/v1/users/report-post/{0}/'.format(str( self.post.uuid)) self.client = APIClient()
def setUp(self): self.user = create_user() self.sub = create_sub(self.user) self.post = create_post(self.sub) self.path = '/api/v1/posts/delete-post/%s/' % (str(self.post.uuid)) self.client = APIClient()
def setUp(self): self.user = create_user() self.sub = create_sub(self.user) self.community = Tag.objects.create(name='test') self.sub.communities.add(self.community.slug) self.path = '/api/v1/users/unsubscribe/%s/' %(self.community.slug) self.client = APIClient()
def setUp(self): self.user = create_user() self.sub = create_sub(self.user) self.community = Tag.objects.create(name='first community') self.client = APIClient() self.path = '/api/v1/users/subscribe/%s/' % (self.community.slug)
def setUp(self): self.user = create_user() self.sub = create_sub(self.user) self.post = create_post(self.sub) self.comment = create_original_comment(self.post, self.sub) self.path = '/api/v1/users/like-comment/{0}/'.format( str(self.comment.uuid)) self.client = APIClient()
def setUp(self): self.user = create_user() self.sub = create_sub(self.user) self.path = '/api/v1/posts/?page=1' self.client = APIClient() for n in range(0, 50): create_post(self.sub)
def setUp(self): self.user = create_user() self.sub = create_sub(self.user) for n in range(0, 21): create_post(self.sub) self.path = '/api/v1/users/sub-posts/%s/?page=2' % (str(self.sub.uuid)) self.client = APIClient()
def setUp(self): self.user = create_user() self.sub = create_sub(self.user) #every community created with create_post has a community called test #by default self.path = '/api/v1/posts/most-popular/{0}/?page=2'.format('test') self.client = APIClient() for n in range(0, 50): create_post(self.sub)
def setUp(self): self.user = create_user() self.sub = create_sub(self.user) self.post = create_post(self.sub) self.original_comment = create_original_comment(self.post, self.sub) self.client = APIClient() self.path = '/api/v1/posts/edit-original-comment/%s/' % (str( self.original_comment.uuid)) self.data = json.dumps({'text': 'this is the updated text'}) self.data_type = 'application/json'
def setUp(self): self.user = create_user() self.sub = create_sub(self.user) self.post = create_post(self.sub) self.path = '/api/v1/posts/get-post/%s/' % (str(self.post.uuid)) self.fake_uuid = uuid4() self.path2 = "/api/v1/posts/get-post/%s/" % (str(self.fake_uuid)) self.client = APIClient()
def setUp(self): self.user = create_user() self.sub = create_sub(self.user) self.post = create_post(self.sub) self.client = APIClient() self.path = '/api/v1/posts/make-original-comment/' self.serializer = OriginalCommentSerializer self.data = json.dumps({ 'post_uuid': str(self.post.uuid), 'owner_uuid': str(self.sub.uuid), 'text': 'this is the comment' }) self.data_type = 'application/json'
def setUp(self): self.user = create_user() self.sub = create_sub(self.user) self.post = create_post(self.sub) self.original_comment = create_original_comment(self.post, self.sub) self.client = APIClient() self.data = json.dumps({ 'commentfeed_uuid': str(self.original_comment.commentfeed.uuid), 'owner_uuid': str(self.sub.uuid), 'text': 'this is a child comment' }) self.data_type = 'application/json' self.path = '/api/v1/posts/make-child-comment/'
def setUp(self): self.user = create_user() self.sub = create_sub(self.user) self.post = create_post(self.sub) for n in range(0, 11): create_original_comment(self.post, self.sub) commentfeed = CommentFeed.objects.first() for n in range(0, 11): create_child_comment(commentfeed, self.sub) self.client = APIClient() self.path = '/api/v1/users/sub-comments/%s/?page=1' % (str( self.sub.uuid))
def setUp(self): #first create a user a sub and a couple of posts self.user = create_user() self.sub = create_sub(self.user) self.slug = 'test' for n in range(0, 4): create_post(self.sub) for post in Post.objects.all(): post.communities.add('test') self.path = '/api/v1/posts/posts-by-community/%s/' % (self.slug) self.client = APIClient() self.serializer = PostSerializer self.paginator = PageNumberPagination()
def setUp(self): self.user = create_user() self.sub = create_sub(self.user) self.post = create_post(self.sub) self.path = '/api/v1/posts/edit-post/%s/' % (str(self.post.uuid)) self.client = APIClient() self.data = json.dumps({ 'title': 'edited title', 'text': 'edited text', }) self.bad_data = json.dumps({ 'title': 'new tle', }) self.invalid_data_response = { 'message': 'sorry there was an error with the data provided' } self.data_type = 'application/json'
def setUp(self): self.user = create_user() self.sub = create_sub(self.user) self.post = create_post(self.sub) self.original_comment = create_original_comment(self.post, self.sub) self.child_comment = Comment.objects.create( owner=self.sub, commentfeed=self.original_comment.commentfeed, text='this is the comment to edit', has_parent=False, is_original=False, parent_comment=None) self.path = '/api/v1/posts/edit-child-comment/%s/' % (str( self.child_comment.uuid)) self.data = json.dumps({'text': 'this is the edited comment'}) self.data_type = 'application/json' self.client = APIClient()
def setUp(self): self.user = create_user() self.sub = create_sub(self.user) self.post = create_post(self.sub) self.original_comment = create_original_comment(self.post, self.sub) self.commentfeed = CommentFeed.objects.first() self.child_comment = Comment.objects.create( owner=self.sub, text='child comment', commentfeed=self.commentfeed, is_original=False) self.original_comment_serializer = OriginalCommentSerializer self.child_serializer = ChildCommentSerializer self.client = APIClient() self.path = '/api/v1/posts/get-comment/%s/' % (str( self.original_comment.uuid)) self.path2 = '/api/v1/posts/get-comment/%s/' % (str( self.child_comment.uuid))
def test_error_response_from_permission(self): '''test if we are granted permission if a''' '''user other than post.owner tries to edit the post''' #first we have to create a new user and a new sub #sub because PostView make a query to get the sub belonging #to that new user, there should always be a sub per user new_user = User.objects.create_user(username='******', password='******', email='*****@*****.**') new_sub = create_sub(new_user) #now authenticate that new user self.client.force_authenticate(user=new_user) #make call response = self.client.put(path=self.path, data=self.data, content_type=self.data_type) self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN)
def setUp(self): self.user = create_user() self.sub = create_sub(self.user) self.path = '/api/v1/posts/make-post/' self.client = APIClient() self.data = json.dumps({ 'title': 'this is a new post', 'text': 'this is a new post', 'add_communities': ['test', 'first post'], }) self.invalid_data_response = { 'message': 'sorry there was an error with the data provided' } self.data_type = 'application/json' self.invalid_data = json.dumps({ 'tite': 'this is the title', 'text': 'this is the text', 'communities': ['test'], })
def setUp(self): self.user = create_user() self.sub = create_sub(self.user) self.path = '/api/v1/users/profile-info/' self.client = APIClient()