1
0
mirror of https://gitlab.crans.org/mediatek/med.git synced 2024-12-26 18:22:24 +00:00
med/media/tests/test_templates.py

66 lines
2.0 KiB
Python
Raw Normal View History

2019-08-16 17:44:27 +00:00
# -*- 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
2019-08-16 18:14:52 +00:00
2019-08-16 17:44:27 +00:00
"""
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, 200)
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)