Exemplo n.º 1
0
    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
Exemplo n.º 2
0
    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)
Exemplo n.º 3
0
    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()
Exemplo n.º 4
0
    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)
Exemplo n.º 5
0
    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.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
Exemplo n.º 7
0
    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()
Exemplo n.º 8
0
    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()
Exemplo n.º 9
0
    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()
Exemplo n.º 10
0
    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()
Exemplo n.º 11
0
    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.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.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'
Exemplo n.º 14
0
    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):
     
     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/'
Exemplo n.º 16
0
    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()
Exemplo n.º 18
0
    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))