|
1 | 1 | # -*- coding: utf-8 -*-
|
2 |
| -from flask import Flask, Blueprint, url_for, session, request |
| 2 | +from flask import Flask, url_for |
3 | 3 | from flask_login import current_user, login_user
|
4 | 4 | from flask_testing import TestCase
|
5 | 5 |
|
@@ -51,63 +51,3 @@ def test_authentication_works(self):
|
51 | 51 | self.login()
|
52 | 52 | response = self.client.get(url_for('restricted'))
|
53 | 53 | self.assertEqual(response.data.decode('utf-8'), "test_user")
|
54 |
| - |
55 |
| - def test_decorator_called_without_parameter(self): |
56 |
| - with self.assertRaises(TypeError): |
57 |
| - @self.app.route('/view') |
58 |
| - @self.mgr.disable_user_loading # note that `()` is missing |
59 |
| - def view(): |
60 |
| - return False |
61 |
| - |
62 |
| - |
63 |
| -class AppLevelUserLoadingDisabledTest(SipaLoginManagerTest): |
64 |
| - def create_app(self): |
65 |
| - app = super().create_app() |
66 |
| - |
67 |
| - @app.route('/images') |
68 |
| - @self.mgr.disable_user_loading() |
69 |
| - def show_images(): |
70 |
| - # We don't take kindly to your types around here! |
71 |
| - self.assertFalse(current_user.is_authenticated) |
72 |
| - return "Images :-)" |
73 |
| - |
74 |
| - return app |
75 |
| - |
76 |
| - def test_login_manager(self): |
77 |
| - self.login() |
78 |
| - response = self.client.get(url_for('show_images')) |
79 |
| - self.assertEqual(response.data.decode('utf-8'), "Images :-)") |
80 |
| - self.assertIn('show_images', self.mgr.ignored_endpoints) |
81 |
| - |
82 |
| - |
83 |
| -class BlueprintLevelUserLoadingDisabledTest(SipaLoginManagerTest): |
84 |
| - def create_app(self): |
85 |
| - app = super().create_app() |
86 |
| - bp = Blueprint(name='documents', import_name='documents') |
87 |
| - |
88 |
| - @bp.route('/documents') |
89 |
| - @self.mgr.disable_user_loading(bp) |
90 |
| - def show_documents(): |
91 |
| - self.assertFalse(current_user.is_authenticated) |
92 |
| - return "Documents :-)" |
93 |
| - |
94 |
| - @bp.route('/images') |
95 |
| - def show_images_as_well(): |
96 |
| - self.assertFalse(current_user.is_authenticated) |
97 |
| - return "Images :-)" |
98 |
| - self.mgr.ignore_endpoint('documents.show_images_as_well') |
99 |
| - |
100 |
| - app.register_blueprint(bp) |
101 |
| - return app |
102 |
| - |
103 |
| - def test_documents_no_user(self): |
104 |
| - self.login() |
105 |
| - response = self.client.get(url_for('documents.show_documents')) |
106 |
| - self.assertEqual(response.data.decode('utf-8'), "Documents :-)") |
107 |
| - self.assertIn('documents.show_documents', self.mgr.ignored_endpoints) |
108 |
| - |
109 |
| - def test_images_no_user(self): |
110 |
| - self.login() |
111 |
| - response = self.client.get(url_for('documents.show_images_as_well')) |
112 |
| - self.assertEqual(response.data.decode('utf-8'), "Images :-)") |
113 |
| - self.assertIn('documents.show_images_as_well', self.mgr.ignored_endpoints) |
0 commit comments