##// END OF EJS Templates
Update thread bumpable status and posts only if it is yet bumpable
Update thread bumpable status and posts only if it is yet bumpable

File last commit:

r1088:9cc4c6f4 default
r1092:f09532f1 default
Show More
test_views.py
47 lines | 1.3 KiB | text/x-python | PythonLexer
import logging
from django.core.urlresolvers import reverse, NoReverseMatch
from django.test import TestCase, Client
from boards import urls
logger = logging.getLogger(__name__)
HTTP_CODE_OK = 200
EXCLUDED_VIEWS = {
'banned',
'get_thread_diff',
}
class ViewTest(TestCase):
def test_all_views(self):
"""
Try opening all views defined in ulrs.py that don't need additional
parameters
"""
client = Client()
for url in urls.urlpatterns:
try:
view_name = url.name
if view_name in EXCLUDED_VIEWS:
logger.debug('View {} is excluded.'.format(view_name))
continue
logger.debug('Testing view %s' % view_name)
try:
response = client.get(reverse(view_name))
self.assertEqual(HTTP_CODE_OK, response.status_code,
'View not opened: {}'.format(view_name))
except NoReverseMatch:
# This view just needs additional arguments
pass
except Exception as e:
self.fail('Got exception %s at %s view' % (e, view_name))
except AttributeError:
# This is normal, some views do not have names
pass