Files
kontor/flask/tests/test_library_view.py
T
2025-01-08 22:31:20 +01:00

45 lines
1.5 KiB
Python

"""This module contains tests for Comic related urls."""
import unittest
from flask import url_for
from . import TestBase
class TestLibraryViews(TestBase):
def test_library_index(self):
"""
Test that comics page is inaccessible without login
and redirects to login page then to comics page
"""
target_url = url_for('library.list_books')
redirect_url = url_for('auth.login', next=target_url)
response = self.client.get(target_url)
self.assertEqual(response.status_code, 302)
self.assertRedirects(response, redirect_url)
def test_library_author(self):
"""
Test that comics page is inaccessible without login
and redirects to login page then to comics page
"""
target_url = url_for('library.list_authors')
redirect_url = url_for('auth.login', next=target_url)
response = self.client.get(target_url)
self.assertEqual(response.status_code, 302)
self.assertRedirects(response, redirect_url)
def test_library_publisher(self):
"""
Test that comics page is inaccessible without login
and redirects to login page then to comics page
"""
target_url = url_for('library.list_publishers')
redirect_url = url_for('auth.login', next=target_url)
response = self.client.get(target_url)
self.assertEqual(response.status_code, 302)
self.assertRedirects(response, redirect_url)
if __name__ == '__main__':
unittest.main()