Toggle navigation
Toggle navigation
This project
Loading...
Sign in
Enzo Yair
/
turismo-api
Go to a project
Toggle navigation
Projects
Groups
Snippets
Help
Toggle navigation pinning
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
Enzo Yair
2024-10-02 07:54:23 -0300
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
5cb97fc934358588b6f9d76926282436bd916dfc
5cb97fc9
1 parent
47ce3e27
feature/endpoint_evento
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
40 additions
and
4 deletions
project/apps/evento/serializers.py
project/apps/evento/tests/__init__.py
project/apps/evento/tests/factories.py
project/apps/evento/tests/test_endpoint_evento.py
project/apps/organismo/tests/factories.py
project/router.py
project/apps/evento/serializers.py
View file @
5cb97fc
...
...
@@ -20,4 +20,4 @@ class EventoSerializer(serializers.ModelSerializer):
'organismo'
,
'dependencia'
,
'imagen'
,
)
)
\ No newline at end of file
...
...
project/apps/evento/tests/__init__.py
0 → 100644
View file @
5cb97fc
project/apps/evento/tests/factories.py
0 → 100644
View file @
5cb97fc
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
...
...
project/apps/evento/tests/test_endpoint_evento.py
0 → 100644
View file @
5cb97fc
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
...
...
project/apps/organismo/tests/factories.py
View file @
5cb97fc
import
factory
from
factory
import
SubFactory
,
faker
,
django
from
organismo.models
import
Organismo
,
Dependencia
...
...
project/router.py
View file @
5cb97fc
...
...
@@ -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
=
'evento
s
'
,
viewset
=
evento_api
.
EventoViewSets
)
router
.
register
(
prefix
=
'evento'
,
viewset
=
evento_api
.
EventoViewSets
)
...
...
Please
register
or
login
to post a comment