6
6
from dash .dependencies import Input , Output , State
7
7
from dash import Dash
8
8
from dash_flask_login import FlaskLoginAuth
9
- import sqlite3
10
- import hashlib
11
9
from flask_login import UserMixin
12
- import pprint
13
10
14
11
class FlaskLoginAuthTest (unittest .TestCase ):
15
12
# Test FlaskLoginAuth functionality
@@ -22,17 +19,17 @@ def setUp(self):
22
19
SECRET_KEY = os .urandom (12 ),
23
20
)
24
21
25
- self .app = Dash (name = 'app1' , url_base_pathname = '/app1' , server = server )
22
+ self .app = Dash (name = 'app1' , url_base_pathname = '/app1/ ' , server = server )
26
23
self .app .layout = html .Div ('Hello World!' )
27
24
28
- self .add_auth_app = Dash (name = 'add_auth_app' , url_base_pathname = '/add-auth-app' , server = server )
25
+ self .add_auth_app = Dash (name = 'add_auth_app' , url_base_pathname = '/add-auth-app/ ' , server = server )
29
26
self .add_auth_app .layout = html .Div ('Hello World!' )
30
27
31
- self .multi_app_no_auth = Dash (name = 'multi_app_no_auth' , url_base_pathname = '/app-no-auth' , server = server )
28
+ self .multi_app_no_auth = Dash (name = 'multi_app_no_auth' , url_base_pathname = '/app-no-auth/ ' , server = server )
32
29
self .multi_app_no_auth .layout = html .Div ('Hello World!' )
33
30
34
31
# Will raise an error because it doesn't have the same server
35
- self .crash_app = Dash (name = 'crash' , url_base_pathname = '/crash-app' )
32
+ self .crash_app = Dash (name = 'crash' , url_base_pathname = '/crash-app/ ' )
36
33
self .crash_app .layout = html .Div ('Goodby Cruel World!' )
37
34
38
35
self .server = server .test_client ()
@@ -56,23 +53,23 @@ def login_logout(self, username, password):
56
53
response = self .server .get ('/logout' ,)
57
54
self .assertEqual (response .status_code , 302 , 'Not logged in yet, server should redirect.' )
58
55
59
- response = self .server .get ('/app1' ,)
56
+ response = self .server .get ('/app1/ ' ,)
60
57
self .assertEqual (response .status_code , 302 , 'Not logged in yet, server should redirect.' )
61
58
62
59
self .login_user (username , password )
63
60
64
- response = self .server .get ('/app1' ,)
61
+ response = self .server .get ('/app1/ ' ,)
65
62
self .assertEqual (response .status_code , 200 , 'Logged in, should be 200 Okay' )
66
63
67
64
response = self .server .get ('/logout' ,)
68
65
self .assertEqual (response .status_code , 200 , 'Logged in, should be 200 Okay' )
69
66
70
67
# Check that logout has worked
71
- response = self .server .get ('/app1' ,)
68
+ response = self .server .get ('/app1/ ' ,)
72
69
self .assertEqual (response .status_code , 302 , 'If logged out successfully, server should redirect.' )
73
70
74
71
def test_app_no_auth (self ):
75
- response = self .server .get ('/app1' , follow_redirects = True )
72
+ response = self .server .get ('/app1/ ' , follow_redirects = True )
76
73
self .assertEqual (response .status_code , 200 )
77
74
self .assertTrue ('<title>Dash</title>' in response .data )
78
75
@@ -157,7 +154,7 @@ def test_multi_app_no_auth_second_app(self):
157
154
158
155
auth = FlaskLoginAuth (self .app , use_default_views = True )
159
156
160
- response = self .server .get ('/app-no-auth' )
157
+ response = self .server .get ('/app-no-auth/ ' )
161
158
self .assertEqual (response .status_code , 200 )
162
159
163
160
def test_multi_app_second_app_with_auth (self ):
@@ -166,17 +163,17 @@ def test_multi_app_second_app_with_auth(self):
166
163
auth .add_app (self .add_auth_app )
167
164
168
165
# Not logged in yet
169
- response = self .server .get ('/add-auth-app' )
166
+ response = self .server .get ('/add-auth-app/ ' )
170
167
self .assertEqual (response .status_code , 302 )
171
168
172
169
# Does not require login
173
- response = self .server .get ('/app-no-auth' )
170
+ response = self .server .get ('/app-no-auth/ ' )
174
171
self .assertEqual (response .status_code , 200 )
175
172
176
173
self .login_user ('admin' ,'admin' )
177
174
178
175
# Logged in
179
- response = self .server .get ('/add-auth-app' )
176
+ response = self .server .get ('/add-auth-app/ ' )
180
177
self .assertEqual (response .status_code , 200 )
181
178
182
179
0 commit comments