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

65 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
2021-10-23 16:31:03 +00:00
from media.models import Author, Comic
2019-08-16 17:44:27 +00:00
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
2021-10-23 16:31:03 +00:00
self.dummy_author = Author.objects.create(name="Test author")
2019-08-16 17:44:27 +00:00
# Create media
2021-10-23 16:31:03 +00:00
self.dummy_bd1 = Comic.objects.create(
2019-08-16 17:44:27 +00:00
title="Test media",
side_identifier="T M",
)
2020-05-22 19:08:44 +00:00
self.dummy_bd1.authors.add(self.dummy_author)
2021-10-23 16:31:03 +00:00
self.dummy_bd2 = Comic.objects.create(
2019-08-16 17:44:27 +00:00
title="Test media bis",
side_identifier="T M 2",
external_url="https://example.com/",
)
2020-05-22 19:08:44 +00:00
self.dummy_bd2.authors.add(self.dummy_author)
2019-08-16 17:44:27 +00:00
2021-10-23 16:33:51 +00:00
def test_comic_bd_changelist(self):
response = self.client.get(reverse('admin:media_comic_changelist'))
2019-08-16 17:44:27 +00:00
self.assertEqual(response.status_code, 200)
2021-10-23 16:33:51 +00:00
def test_comic_bd_add(self):
response = self.client.get(reverse('admin:media_comic_add'))
2019-08-16 17:44:27 +00:00
self.assertEqual(response.status_code, 200)
2021-10-23 16:33:51 +00:00
def test_comic_isbn_download(self):
2019-08-16 17:44:27 +00:00
data = {
2020-05-12 13:09:06 +00:00
'_isbn': True,
2019-08-16 17:44:27 +00:00
'isbn': "0316358525",
}
response = self.client.post(reverse(
2021-10-23 16:33:51 +00:00
'admin:media_comic_change',
2020-05-22 19:08:44 +00:00
args=[self.dummy_bd1.id],
2019-08-16 17:44:27 +00:00
), data=data)
2020-02-10 04:03:53 +00:00
self.assertEqual(response.status_code, 302)
2019-08-16 17:44:27 +00:00
2021-11-14 13:26:41 +00:00
def test_comic_borrow_changelist(self):
response = self.client.get(reverse('admin:media_borrow_changelist'))
2019-08-16 17:44:27 +00:00
self.assertEqual(response.status_code, 200)
2021-11-14 13:26:41 +00:00
def test_comic_borrow_add(self):
response = self.client.get(reverse('admin:media_borrow_add'))
2019-08-16 17:44:27 +00:00
self.assertEqual(response.status_code, 200)