Пример #1
0
def test_get_create_url():
    assert Like.get_create_url() == reverse('likes:like')
Пример #2
0
import pytest
from django.urls import reverse

from accounts.models import UserAccount
from factories import RecipeFactory, UserFactory
from likes.models import Like

# add test to get info from recipe detail page
# ------------------------------------------------ Tests
pytestmark = pytest.mark.django_db
like_url = Like.get_create_url()


class TestLikeRecipeCreateView:
    class TestAuthenticatedUsers:
        def test_like_page_render(self, api_client):
            new_user = UserAccount()
            api_client.force_authenticate(new_user)

            like_page_render = api_client.get(like_url)

            assert like_page_render.status_code == 405

        def test_like_post_request(self, api_client):
            new_user = UserFactory()
            api_client.force_authenticate(new_user)
            new_recipe = RecipeFactory()
            data = {'recipe': new_recipe.id}
            response = api_client.post(like_url, data)

            assert response.status_code == 200