def user_login(): if request.method == "POST": return login.post() elif request.method == "DELETE": return login.delete() else: Response("Not Supported", mimetype="text/hmtl", status=500)
def test_no_loguea_usuario_invalido(self): with patch("login.get_dict_from_fieldstorage", return_value=self.FAKE_USER): with patch("login.get_orm", return_value=self.orm): alumno = Alumno(1, "Juancho", "m", 21, sha256("OtraPassword".encode()).hexdigest()) self.orm.create(alumno) pq = PyQuery(login.post()) res = pq("div#form-success").text().lower().splitlines() self.assertListEqual( res, [], msg="No se encontró el mensaje de login exitoso")
def test_loguea_usuario_valido(self): with patch("login.get_dict_from_fieldstorage", return_value=self.FAKE_USER): with patch("login.get_orm", return_value=self.orm): alumno = Alumno( 1, "Juancho", "m", 21, sha256("UnaPasswordMuySegura".encode()).hexdigest()) self.orm.create(alumno) pq = PyQuery(login.post()) #splitear las lineas por el '\n' con "splitlines()" res = pq("div#form-success").text().lower().splitlines() self.assertEqual(res[0], "pudo ingresar correctamente")
def login_api(): if request.method == "POST": return login.post() elif request.method == "DELETE": return login.delete()
def POST(self): return login.post(session)