예제 #1
0
 def test_bookmarked_if_user_has_not_bookmarked(self, comment, user):
     BookmarkFactory(
         user=user,
         content_object=comment,
         community=comment.community,
     )
     assert Comment.objects.bookmarked(UserFactory()).count() == 0
예제 #2
0
 def test_bookmarked_if_user_has_not_bookmarked(self, message, user):
     BookmarkFactory(
         user=user,
         content_object=message,
         community=message.community,
     )
     assert Message.objects.bookmarked(UserFactory()).count() == 0
예제 #3
0
 def test_with_has_bookmarked_if_user_has_bookmarked(self, message, user):
     BookmarkFactory(
         user=user,
         content_object=message,
         community=message.community,
     )
     message = Message.objects.with_has_bookmarked(user).get()
     assert message.has_bookmarked
예제 #4
0
 def test_with_bookmarked_timestamp_if_user_has_bookmarked(self, comment, user):
     BookmarkFactory(
         user=user,
         content_object=comment,
         community=comment.community,
     )
     comment = Comment.objects.with_bookmarked_timestamp(user).first()
     assert comment.bookmarked is not None
예제 #5
0
 def test_with_bookmarked_timestamp_if_user_has_bookmarked(self, post, user):
     BookmarkFactory(
         user=user,
         content_object=post,
         community=post.community,
     )
     post = Post.objects.with_bookmarked_timestamp(user).first()
     assert post.bookmarked is not None
예제 #6
0
 def test_with_has_bookmarked_if_user_has_bookmarked(self, comment, user):
     BookmarkFactory(
         user=user,
         content_object=comment,
         community=comment.community,
     )
     comment = Comment.objects.with_has_bookmarked(user).get()
     assert comment.has_bookmarked
예제 #7
0
 def test_with_has_bookmarked_if_user_has_bookmarked(self, post, user):
     BookmarkFactory(
         user=user,
         content_object=post,
         community=post.community,
     )
     activity = Post.objects.with_has_bookmarked(user).get()
     assert activity.has_bookmarked
예제 #8
0
 def test_with_bookmarked_timestamp_if_user_has_bookmarked(
         self, message, user):
     BookmarkFactory(
         user=user,
         content_object=message,
         community=message.community,
     )
     message = Message.objects.with_bookmarked_timestamp(user).first()
     assert message.bookmarked is not None
예제 #9
0
 def test_bookmarked_if_user_has_bookmarked(self, message, user):
     BookmarkFactory(
         user=user,
         content_object=message,
         community=message.community,
     )
     messages = Message.objects.bookmarked(user)
     assert messages.count() == 1
     assert messages.first().has_bookmarked
예제 #10
0
 def test_with_bookmarked_timestamp_if_user_has_not_bookmarked(self, comment, user):
     BookmarkFactory(
         user=user,
         content_object=comment,
         community=comment.community,
     )
     # test with *another* user
     comment = Comment.objects.with_bookmarked_timestamp(UserFactory()).first()
     assert comment.bookmarked is None
예제 #11
0
 def test_bookmarked_if_user_has_bookmarked(self, comment, user):
     BookmarkFactory(
         user=user,
         content_object=comment,
         community=comment.community,
     )
     comments = Comment.objects.bookmarked(user)
     assert comments.count() == 1
     assert comments.first().has_bookmarked
예제 #12
0
 def test_bookmarked_if_user_has_bookmarked(self, post, user):
     BookmarkFactory(
         user=user,
         content_object=post,
         community=post.community,
     )
     posts = Post.objects.bookmarked(user)
     assert posts.count() == 1
     assert posts.first().has_bookmarked
예제 #13
0
 def test_with_bookmarked_timestamp_if_user_has_not_bookmarked(
         self, message, user):
     BookmarkFactory(
         user=user,
         content_object=message,
         community=message.community,
     )
     # test with *another* user
     message = Message.objects.with_bookmarked_timestamp(
         UserFactory()).first()
     assert message.bookmarked is None
예제 #14
0
 def test_post(self, client, member):
     post = PostFactory(
         community=member.community,
         owner=MembershipFactory(community=member.community).member,
     )
     BookmarkFactory(
         user=member.member,
         content_object=post,
         community=post.community,
     )
     response = client.post(reverse("posts:remove_bookmark",
                                    args=[post.id]))
     assert response.url == post.get_absolute_url()
     assert Bookmark.objects.count() == 0
예제 #15
0
 def test_post(self, client, member):
     sender = MembershipFactory(community=member.community).member
     message = MessageFactory(community=member.community,
                              recipient=member.member,
                              sender=sender)
     BookmarkFactory(
         user=member.member,
         content_object=message,
         community=message.community,
     )
     response = client.post(
         reverse("private_messages:message_remove_bookmark",
                 args=[message.id]), )
     assert response.status_code == http.HTTPStatus.OK
     assert Bookmark.objects.count() == 0
예제 #16
0
 def test_bookmarked_if_anon_user(self, post, anonymous_user):
     BookmarkFactory(
         content_object=post,
         community=post.community,
     )
     assert Post.objects.bookmarked(anonymous_user).count() == 0