Esempio n. 1
0
            def test_author_should_be_added_to_user_followed_followers_list(
                    self, api_client):
                author = UserFactory()
                user_followed = UserFactory()
                api_client.force_authenticate(author)

                data = {'user_followed': user_followed.id}
                api_client.post(follow_url, data)

                assert user_followed.followers.all().get(
                    id__exact=author.id) == author
Esempio n. 2
0
            def test_when_author_unfollow_a_user_author_should_be_removed_from_the_user_followers_list(
                    self, api_client):
                author = UserFactory()
                user_followed = UserFactory()
                api_client.force_authenticate(author)

                data = {'user_followed': user_followed.id}
                api_client.post(follow_url, data)
                api_client.post(follow_url, data)
                try:
                    removed_from_followers_list = user_followed.followers.all(
                    ).get(id__exact=author.id) == author
                except:
                    removed_from_followers_list = True

                assert removed_from_followers_list == True
Esempio n. 3
0
        def test_follow_post_request_should_not_allowed(self, api_client):
            user_followed = UserFactory()

            data = {'user_followed': user_followed.id}
            response = api_client.post(follow_url, data)

            assert response.status_code == 401
Esempio n. 4
0
            def test_follow_post_request(self, api_client):
                author = UserFactory()
                user_followed = UserFactory()
                api_client.force_authenticate(author)

                data = {'user_followed': user_followed.id}
                response = api_client.post(follow_url, data)

                assert response.status_code == 200
Esempio n. 5
0
            def test_user_cant_follow_himself(self, api_client):
                author = UserFactory()
                api_client.force_authenticate(author)

                data = {'user_followed': author.id}
                api_client.post(follow_url, data)

                try:
                    author_following = author.following.all().get(
                        id__exact=author.id)
                except:
                    author_following = None

                try:
                    author_followers = author.followers.all().get(
                        id__exact=author.id)
                except:
                    author_followers = None

                assert author_following == None
                assert author_followers == None