3
0
Fork 0

fix: add notfound() View method; auto-append trailing slash

the latter provides auto-redirect to `/widgets/` when user visits
`/widgets` for example
This commit is contained in:
Lance Edgar 2024-08-05 21:58:31 -05:00
parent 9a739381ae
commit 7766ca6b12
3 changed files with 17 additions and 2 deletions

View file

@ -3,7 +3,7 @@
from unittest import TestCase
from pyramid import testing
from pyramid.httpexceptions import HTTPFound, HTTPForbidden
from pyramid.httpexceptions import HTTPFound, HTTPForbidden, HTTPNotFound
from wuttjamaican.conf import WuttaConfig
from wuttaweb.views import base
@ -31,6 +31,10 @@ class TestView(TestCase):
form = self.view.make_form()
self.assertIsInstance(form, Form)
def test_notfound(self):
error = self.view.notfound()
self.assertIsInstance(error, HTTPNotFound)
def test_redirect(self):
error = self.view.redirect('/')
self.assertIsInstance(error, HTTPFound)