Ejemplo n.º 1
0
    def login_user(self, email, password):
        login_url = url_for("users.login")
        response = self.client.get(login_url)
        html = HTMLDocument.from_response(response)
        csrf_token = html.form(LoginForm).fields["csrf_token"]

        response = self.client.post(login_url,
#            follow_redirects=True,
            data={
                "csrf_token": csrf_token,
                "email": email,
                "password": password,
            },
        )

        self.assert_redirects(response, url_for("users.profile"))

        return response
Ejemplo n.º 2
0
    def register_new_user(self, username, email, password, confirm=None, accept_tos=1):
        response = self.client.get(url_for("users.register"))
        self.assert200(response)
        html = HTMLDocument.from_response(response)
        csrf_token = html.form(RegisterForm).fields["csrf_token"]

        response = self.client.post(url_for("users.register"),
            # follow_redirects=True,
            data={
                "csrf_token": csrf_token,
                "username": username,
                "email": email,
                "password": password,
                "confirm": confirm or password,
                "accept_tos": accept_tos,
            }
        )

        return response
Ejemplo n.º 3
0
 def assert_input_has_error(self, resp, input_id):
     html = HTMLDocument.from_response(resp)
     self.assertTrue("has_error" in html.xpath("//input[@id='"+input_id+"']/@class")[0])