Correct some tests

This commit is contained in:
Valentin Samir 2015-11-20 17:38:03 +01:00
parent 7beefa537f
commit 6bdff5ac86
3 changed files with 8 additions and 5 deletions

View file

@ -281,7 +281,7 @@ class LoginView(View, LogoutMixin):
)
if self.ajax:
data = {"status": "error", "detail": "confirmation needed"}
return JsonResponse(request, data)
return JsonResponse(self.request, data)
else:
return render(
self.request,
@ -291,7 +291,7 @@ class LoginView(View, LogoutMixin):
service_pattern,
renew=self.renew
)}
)
)
else:
# redirect, using method ?
list(messages.get_messages(self.request)) # clean messages before leaving django

View file

@ -128,6 +128,9 @@ class DummySession(dict):
def set_expiry(self, int):
pass
def flush(self):
self.clear()
class DummyQuerySet(set):
pass

View file

@ -18,7 +18,7 @@ def test_login_view_post_goodpass_goodlt():
request = factory.post('/login', {'username':'test', 'password':'test', 'lt':'LT-random'})
request.session = DummySession()
request.session['lt'] = 'LT-random'
request.session['lt'] = ['LT-random']
request.session["username"] = os.urandom(20)
request.session["warn"] = os.urandom(20)
@ -38,7 +38,7 @@ def test_login_view_post_badlt():
request = factory.post('/login', {'username':'test', 'password':'test', 'lt':'LT-random1'})
request.session = DummySession()
request.session['lt'] = 'LT-random2'
request.session['lt'] = ['LT-random2']
authenticated = os.urandom(20)
username = os.urandom(20)
@ -63,7 +63,7 @@ def test_login_view_post_badpass_good_lt():
request = factory.post('/login', {'username':'test', 'password':'badpassword', 'lt':'LT-random'})
request.session = DummySession()
request.session['lt'] = 'LT-random'
request.session['lt'] = ['LT-random']
login = LoginView()
login.init_post(request)