test_endpoint_evento.py 614 Bytes
import pytest
from rest_framework import status
from django.contrib.auth.models import User
from django.urls import reverse
from rest_framework.test import APIClient

from evento.tests.factories import EventoFactory


@pytest.mark.django_db
def test_evento_list():
    cliente = APIClient()
    user = User.objects.create_user(username='admin', email='admin@example.com', password='password123')
    cliente.force_authenticate(user=user)

    EventoFactory.create_batch(size=4)

    endpoint = reverse('evento-list')
    response = cliente.get(path=endpoint)

    assert response.status_code == status.HTTP_200_OK