blob: 58118ae00f28df9b0df05eedc33b22fa5073b011 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
import os
from tests import SiteTest, manager
class MixinTests(SiteTest):
""" Test cases for mixins """
def test_handler_5xx(self):
""" Check error view returns error message """
from werkzeug.exceptions import InternalServerError
from pysite.views.error_handlers import http_5xx
error_view = http_5xx.Error500View()
error_message = error_view.get(InternalServerError)
self.assertEqual(error_message[1], 500)
def test_route_view_runtime_error(self):
""" Check that wrong values for route view setup raises runtime error """
from pysite.base_route import RouteView
rv = RouteView()
with self.assertRaises(RuntimeError):
rv.setup(manager, 'sdfsdf')
def test_oauth_property(self):
""" Make sure the oauth property works"""
from flask import Blueprint
from pysite.route_manager import RouteView
from pysite.oauth import OauthBackend
class TestRoute(RouteView):
name = "test"
path = "/test"
tr = TestRoute()
tr.setup(manager, Blueprint("test", "test_name"))
self.assertIsInstance(tr.oauth, OauthBackend)
def test_user_data_property(self):
""" Make sure the user_data property works"""
from flask import Blueprint
from pysite.route_manager import RouteView
class TestRoute(RouteView):
name = "test"
path = "/test"
tr = TestRoute()
tr.setup(manager, Blueprint("test", "test_name"))
self.assertIsNone(tr.user_data)
def test_logged_in_property(self):
""" Make sure the user_data property works"""
from flask import Blueprint
from pysite.route_manager import RouteView
class TestRoute(RouteView):
name = "test"
path = "/test"
tr = TestRoute()
tr.setup(manager, Blueprint("test", "test_name"))
self.assertFalse(tr.logged_in)
|