Add books
This commit is contained in:
@ -1,3 +0,0 @@
|
||||
# Las funciones deben empezar por "test_"
|
||||
def test_titulo():
|
||||
assert "canción de hielo y fuego" != "juego de tronos"
|
@ -1,9 +0,0 @@
|
||||
import json
|
||||
from django.urls import reverse
|
||||
|
||||
def test_ping(client):
|
||||
url = reverse("ping")
|
||||
response = client.get(url)
|
||||
content = json.loads(response.content)
|
||||
assert response.status_code == 200
|
||||
assert content["ping"] == "pong!"
|
30
tests/libros/test_views.py
Normal file
30
tests/libros/test_views.py
Normal file
@ -0,0 +1,30 @@
|
||||
# tests/libros/test_views.py
|
||||
|
||||
import pytest
|
||||
from app.libros.models import Libros
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_add_movie(client):
|
||||
# Given
|
||||
libros = Libros.objects.all()
|
||||
assert len(libros) == 0
|
||||
|
||||
# When
|
||||
resp = client.post(
|
||||
"/api/libros/",
|
||||
{
|
||||
"title": "El fin de la eternidad",
|
||||
"genre": "Ciencia Ficción",
|
||||
"author": "Isaac Asimov",
|
||||
"year": "1955",
|
||||
},
|
||||
content_type="application/json"
|
||||
)
|
||||
|
||||
# Then
|
||||
assert resp.status_code == 201
|
||||
assert resp.data["title"] == "El fin de la eternidad"
|
||||
|
||||
libros = Libros.objects.all()
|
||||
assert len(libros) == 1
|
Reference in New Issue
Block a user