Esempio n. 1
0
 def test_login_email_integer_as_email(self):
     with self.assertRaises(
             TypeError,
             msg=
             "The login() function must take an email as its first parameter"
     ):
         login(123, "password")
Esempio n. 2
0
 def test_login_nobody(self):
     self.assertEqual(
         login('*****@*****.**', 'password1'),
         "The username that you used does not exist. Please retry.")
     self.assertEqual(
         login('*****@*****.**', 'NobodyPassword'),
         "The username that you used does not exist. Please retry.")
Esempio n. 3
0
 def test_login_email_without_at_symbol(self):
     with self.assertRaises(
             TypeError,
             msg=
             "The login() function must take an email as its first parameter"
     ):
         login("instructoruwm.edu", "password")
Esempio n. 4
0
 def test_login_ta(self):
     self.assertEqual(login('*****@*****.**', 'password1'), "Valid")
     self.assertEqual(
         login('*****@*****.**', 'password2'),
         "The password that you entered is not correct.  Please retry.")
     self.assertEqual(
         login('*****@*****.**', 'NobodyPassword'),
         "The password that you entered is not correct.  Please retry.")
Esempio n. 5
0
 def post(self, request):
     x = request.POST['uname']
     message = login(x, request.POST['psw'])
     if message == "Valid":
         u = get_user(x)
         request.session['name'] = u.email
         request.session['role'] = u.role
         request.session.set_expiry(0)
         if u.is_supervisor():
             request.session['supervisor'] = True
         else:
             request.session['supervisor'] = False
         return redirect("/course/", request)
     else:
         return render(request, "login.html", {"message": message})
Esempio n. 6
0
 def test_login_email_no_arguments(self):
     with self.assertRaises(
             TypeError, msg="The login() function must take 2 parameters"):
         login()
Esempio n. 7
0
 def test_login_email_one_argument(self):
     with self.assertRaises(
             TypeError, msg="The login() function must take 2 parameters"):
         login("*****@*****.**")
Esempio n. 8
0
 def test_login_email_too_many_arguments(self):
     with self.assertRaises(
             TypeError, msg="The login() function must take 2 parameters"):
         login(123, "password", "string")