2024-07-12 00:17:15 -05:00
|
|
|
# -*- coding: utf-8; -*-
|
|
|
|
|
|
|
|
from unittest import TestCase
|
|
|
|
|
|
|
|
from pyramid import testing
|
2024-08-04 20:35:41 -05:00
|
|
|
from pyramid.httpexceptions import HTTPFound
|
2024-07-12 00:17:15 -05:00
|
|
|
|
|
|
|
from wuttjamaican.conf import WuttaConfig
|
|
|
|
from wuttaweb.views import base
|
2024-08-04 20:35:41 -05:00
|
|
|
from wuttaweb.forms import Form
|
2024-07-12 00:17:15 -05:00
|
|
|
|
|
|
|
|
|
|
|
class TestView(TestCase):
|
|
|
|
|
2024-08-04 20:35:41 -05:00
|
|
|
def setUp(self):
|
|
|
|
self.config = WuttaConfig()
|
|
|
|
self.app = self.config.get_app()
|
|
|
|
self.request = testing.DummyRequest(wutta_config=self.config)
|
|
|
|
self.view = base.View(self.request)
|
|
|
|
|
2024-07-12 00:17:15 -05:00
|
|
|
def test_basic(self):
|
2024-08-04 20:35:41 -05:00
|
|
|
self.assertIs(self.view.request, self.request)
|
|
|
|
self.assertIs(self.view.config, self.config)
|
|
|
|
self.assertIs(self.view.app, self.app)
|
|
|
|
|
|
|
|
def test_make_form(self):
|
|
|
|
form = self.view.make_form()
|
|
|
|
self.assertIsInstance(form, Form)
|
|
|
|
|
|
|
|
def test_redirect(self):
|
|
|
|
error = self.view.redirect('/')
|
|
|
|
self.assertIsInstance(error, HTTPFound)
|
|
|
|
self.assertEqual(error.location, '/')
|