Enzo Yair

feature/endpoint_evento

... ... @@ -20,4 +20,4 @@ class EventoSerializer(serializers.ModelSerializer):
'organismo',
'dependencia',
'imagen',
)
)
\ No newline at end of file
... ...
from factory import faker, django
from datetime import date
from evento.models import Evento
class EventoFactory(django.DjangoModelFactory):
class Meta:
model = Evento
titulo = faker.Faker(provider='sentence', nb_words=50)
categoria = faker.Faker(provider='sentence', nb_words=30)
direccion = 'https://maps.app.goo.gl/CNwbHBx5zq1VDje57'
descripcion = faker.Faker(provider='sentence', nb_words=30)
fecha_inicio = date(2024, 1, 1)
hora_inicio = '10:00:00'
fecha_final = date(2024, 1, 2)
hora_fin = '11:20:47'
\ No newline at end of file
... ...
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
... ...
import factory
from factory import SubFactory, faker, django
from organismo.models import Organismo, Dependencia
... ...
... ... @@ -8,4 +8,4 @@ router = routers.DefaultRouter()
router.register(prefix='organismo', viewset=organismo_api.OrganismoViewSets)
router.register(prefix='dependencia', viewset=organismo_api.DependenciaViewSets)
router.register(prefix='eventos', viewset=evento_api.EventoViewSets)
router.register(prefix='evento', viewset=evento_api.EventoViewSets)
... ...