示例#1
0
 def test_post_with_comments_from_friend(self):
     test_user = Pleb(email=str(uuid1()) + '@gmail.com',
                      username=str(uuid1())[:32])
     test_user.save()
     test_post = Post(content='test',
                      object_uuid=str(uuid1()),
                      owner_username=self.pleb.username,
                      wall_owner_username=self.pleb.username)
     test_post.save()
     wall = self.pleb.wall.all()[0]
     test_post.posted_on_wall.connect(wall)
     wall.posts.connect(test_post)
     test_post.owned_by.connect(self.pleb)
     my_comment = Comment(content='test comment',
                          object_uuid=str(uuid1()),
                          owner_username=self.pleb.username)
     my_comment.save()
     my_comment.owned_by.connect(test_user)
     test_post.comments.connect(my_comment)
     request = self.factory.get('/%s' % self.pleb.username)
     request.user = self.user
     profile_page = ProfileView.as_view()
     response = profile_page(request, self.pleb.username)
     self.assertIn(response.status_code,
                   [status.HTTP_200_OK, status.HTTP_302_FOUND])
     test_user.delete()
     test_post.delete()
     my_comment.delete()
示例#2
0
 def test_multiple_posts_multiple_comments_friends(self):
     wall = self.pleb.get_wall()
     pleb_array = []
     post_array = []
     comment_array = []
     for item in range(0, 2):
         test_pleb = Pleb(email=str(uuid1())[:32],
                          username=str(uuid1())[:32])
         test_pleb.save()
         pleb_array.append(test_pleb)
         for number in range(0, 10):
             test_post = Post(content='test',
                              object_uuid=str(uuid1()),
                              owner_username=self.pleb.username,
                              wall_owner_username=self.pleb.username)
             test_post.save()
             test_post.posted_on_wall.connect(wall)
             wall.posts.connect(test_post)
             test_post.owned_by.connect(test_pleb)
             post_array.append(test_post)
             for num in range(0, 1):
                 my_comment = Comment(content='test comment',
                                      object_uuid=str(uuid1()),
                                      owner_username=self.pleb.username)
                 my_comment.save()
                 my_comment.owned_by.connect(test_pleb)
                 test_post.comments.connect(my_comment)
                 comment_array.append(my_comment)
                 my_comment = Comment(content='test comment',
                                      object_uuid=str(uuid1()),
                                      owner_username=self.pleb.username)
                 my_comment.save()
                 my_comment.owned_by.connect(self.pleb)
                 test_post.comments.connect(my_comment)
                 comment_array.append(my_comment)
     test_post = Post(content='test',
                      object_uuid=str(uuid1()),
                      owner_username=self.pleb.username,
                      wall_owner_username=self.pleb.username)
     test_post.save()
     test_post.posted_on_wall.connect(wall)
     wall.posts.connect(test_post)
     test_post.owned_by.connect(self.pleb)
     request = self.factory.get('/%s' % self.pleb.username)
     request.user = self.user
     profile_page = ProfileView.as_view()
     response = profile_page(request, self.pleb.username)
     self.assertIn(response.status_code,
                   [status.HTTP_200_OK, status.HTTP_302_FOUND])
     for item in pleb_array:
         item.delete()
     for post in post_array:
         post.delete()
     for comment in comment_array:
         comment.delete()
     test_post.delete()
示例#3
0
 def test_with_post(self):
     test_post = Post(content='test',
                      object_uuid=str(uuid1()),
                      owner_username=self.pleb.username,
                      wall_owner_username=self.pleb.username)
     test_post.save()
     wall = self.pleb.get_wall()
     test_post.posted_on_wall.connect(wall)
     wall.posts.connect(test_post)
     test_post.owned_by.connect(self.pleb)
     request = self.factory.get('/%s' % self.pleb.username)
     request.user = self.user
     profile_page = ProfileView.as_view()
     response = profile_page(request, self.pleb.username)
     self.assertIn(response.status_code,
                   [status.HTTP_200_OK, status.HTTP_302_FOUND])
     test_post.delete()