1
0
mirror of https://gitlab.crans.org/mediatek/med.git synced 2024-12-27 09:02:24 +00:00
med/media/tests/test_templates.py
Yohann D'ANELLO ac8d91ac5e Correct test
2020-02-10 05:03:53 +01:00

66 lines
2.0 KiB
Python

# -*- mode: python; coding: utf-8 -*-
# SPDX-License-Identifier: GPL-3.0-or-later
from django.test import TestCase
from django.urls import reverse
from media.models import Auteur, Media
from users.models import User
"""
Test that every page render
"""
class TemplateTests(TestCase):
def setUp(self):
self.user = User.objects.create_superuser(
username="admin",
password="adminadmin",
email="admin@example.com",
)
self.client.force_login(self.user)
# Create an author
self.dummy_author = Auteur.objects.create(name="Test author")
# Create media
self.dummy_media1 = Media.objects.create(
title="Test media",
side_identifier="T M",
)
self.dummy_media1.authors.add(self.dummy_author)
self.dummy_media2 = Media.objects.create(
title="Test media bis",
side_identifier="T M 2",
external_url="https://example.com/",
)
self.dummy_media2.authors.add(self.dummy_author)
def test_media_media_changelist(self):
response = self.client.get(reverse('admin:media_media_changelist'))
self.assertEqual(response.status_code, 200)
def test_media_media_add(self):
response = self.client.get(reverse('admin:media_media_add'))
self.assertEqual(response.status_code, 200)
def test_media_isbn_download(self):
data = {
'_continue': True,
'isbn': "0316358525",
}
response = self.client.post(reverse(
'admin:media_media_change',
args=[self.dummy_media1.id],
), data=data)
self.assertEqual(response.status_code, 302)
def test_media_emprunt_changelist(self):
response = self.client.get(reverse('admin:media_emprunt_changelist'))
self.assertEqual(response.status_code, 200)
def test_media_emprunt_add(self):
response = self.client.get(reverse('admin:media_emprunt_add'))
self.assertEqual(response.status_code, 200)