add the ability to disable the web display of some apps
This commit is contained in:
@@ -1,8 +1,5 @@
|
||||
"""Test the race views."""
|
||||
from unittest import mock
|
||||
|
||||
from django.test import TestCase
|
||||
from django.utils.timezone import now
|
||||
|
||||
from races.models import Race, Racer, RaceUpdate
|
||||
|
||||
|
||||
46
tests/test_web_enabled_app_settings.py
Normal file
46
tests/test_web_enabled_app_settings.py
Normal file
@@ -0,0 +1,46 @@
|
||||
"""Test views and templates' adherence to WEB_ENABLED_APPS."""
|
||||
from django.conf import settings
|
||||
from django.test import TestCase
|
||||
|
||||
|
||||
class WebEnabledAppsAPITest(TestCase):
|
||||
"""Test that certain display elements and views can be enabled/disabled via settings."""
|
||||
|
||||
def setUp(self):
|
||||
"""Store the old setting so that we can restore it later."""
|
||||
self.old_sites_list = settings.WEB_ENABLED_APPS
|
||||
print("butt")
|
||||
|
||||
def tearDown(self):
|
||||
"""Restore the old setting stored earlier."""
|
||||
settings.WEB_ENABLED_APPS = self.old_sites_list
|
||||
print("butt")
|
||||
|
||||
def test_default_enabled(self):
|
||||
"""Test that the expected sites can be reached and displayed by default."""
|
||||
resp = self.client.get('/karma/')
|
||||
self.assertEqual(resp.status_code, 200)
|
||||
self.assertIn(b'<a href="/karma/">', resp.content)
|
||||
resp = self.client.get('/races/')
|
||||
self.assertEqual(resp.status_code, 200)
|
||||
self.assertIn(b'<a href="/races/">', resp.content)
|
||||
|
||||
def test_one_disabled(self):
|
||||
"""Test that we can disable one site but not all sites using this setting."""
|
||||
settings.WEB_ENABLED_APPS = ['karma']
|
||||
resp = self.client.get('/karma/')
|
||||
self.assertEqual(resp.status_code, 200)
|
||||
self.assertIn(b'<a href="/karma/">', resp.content)
|
||||
resp = self.client.get('/races/')
|
||||
self.assertEqual(resp.status_code, 403)
|
||||
self.assertNotIn(b'<a href="/races/">', resp.content)
|
||||
|
||||
def test_all_disabled(self):
|
||||
"""Test that we can disable all sites using this setting."""
|
||||
settings.WEB_ENABLED_APPS = []
|
||||
resp = self.client.get('/karma/')
|
||||
self.assertEqual(resp.status_code, 403)
|
||||
self.assertNotIn(b'<a href="/karma/">', resp.content)
|
||||
resp = self.client.get('/races/')
|
||||
self.assertEqual(resp.status_code, 403)
|
||||
self.assertNotIn(b'<a href="/races/">', resp.content)
|
||||
Reference in New Issue
Block a user