111 lines
4.0 KiB
Python
111 lines
4.0 KiB
Python
"""This module contains tests for TradeYourSportsCards related urls."""
|
|
import unittest
|
|
from flask import url_for
|
|
from . import TestBase
|
|
|
|
|
|
class TestTYSCViews(TestBase):
|
|
|
|
def test_tysc_index(self):
|
|
"""
|
|
Test that TYSC page is inaccessible without login
|
|
and redirects to login page then to TYSC page
|
|
"""
|
|
target_url = url_for('tysc.list_cards')
|
|
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_tysc_sport(self):
|
|
"""
|
|
Test that TYSC page is inaccessible without login
|
|
and redirects to login page then to TYSC page
|
|
"""
|
|
target_url = url_for('tysc.list_sports')
|
|
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_tysc_team(self):
|
|
"""
|
|
Test that TYSC page is inaccessible without login
|
|
and redirects to login page then to TYSC page
|
|
"""
|
|
target_url = url_for('tysc.list_teams')
|
|
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_tysc_player(self):
|
|
"""
|
|
Test that TYSC page is inaccessible without login
|
|
and redirects to login page then to TYSC page
|
|
"""
|
|
target_url = url_for('tysc.list_players')
|
|
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_tysc_manufacturer(self):
|
|
"""
|
|
Test that TYSC page is inaccessible without login
|
|
and redirects to login page then to TYSC page
|
|
"""
|
|
target_url = url_for('tysc.list_manufacturers')
|
|
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_tysc_card_set(self):
|
|
"""
|
|
Test that TYSC page is inaccessible without login
|
|
and redirects to login page then to TYSC page
|
|
"""
|
|
target_url = url_for('tysc.list_card_sets')
|
|
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_tysc_parallel_set(self):
|
|
"""
|
|
Test that TYSC page is inaccessible without login
|
|
and redirects to login page then to TYSC page
|
|
"""
|
|
target_url = url_for('tysc.list_parallel_sets')
|
|
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_tysc_insert_set(self):
|
|
"""
|
|
Test that TYSC page is inaccessible without login
|
|
and redirects to login page then to TYSC page
|
|
"""
|
|
target_url = url_for('tysc.list_insert_sets')
|
|
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_tysc_card(self):
|
|
"""
|
|
Test that TYSC page is inaccessible without login
|
|
and redirects to login page then to TYSC page
|
|
"""
|
|
target_url = url_for('tysc.list_cards')
|
|
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()
|