Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inform users about unsuccessful POST requests #585

Closed
NullPiotrException opened this issue May 11, 2017 · 3 comments
Closed

Inform users about unsuccessful POST requests #585

NullPiotrException opened this issue May 11, 2017 · 3 comments

Comments

@NullPiotrException
Copy link

I wrote this login function that I run only in on_start:

def login(self):
    self.client.post("/login", {"name":"admin", "password":"qwerty"})

And in http://localhost:8089 I can see multiple successful POST requests for /login. But when I enter incorrect password I still see all POST requests as valid ones (I don't see any error in console and in #fails column).

@NullPiotrException NullPiotrException changed the title Inform usage about unsuccessful POST Inform users about unsuccessful POST May 11, 2017
@NullPiotrException NullPiotrException changed the title Inform users about unsuccessful POST Inform users about unsuccessful POST requests May 11, 2017
@Nesters
Copy link

Nesters commented May 14, 2017

Read the official documentation on "Manually controlling if a request should be considered successful or a failure".

Your request is not a failure because it returns 200 OK and content letting you know the password was incorrect.
For most part, you need to perform manual checks on the response content and categorize them as "Success" or "Failure" by yourself.

@WilliamSkyWalker
Copy link

Locust is a loading test tool. If a request does return 200, it means the request has return and in your case, a correct return.
Agree with @Nesters . Have fun.

@NullPiotrException
Copy link
Author

NullPiotrException commented May 19, 2017

You're right. My bad.
Before I close this issue, does any of you have an idea what I'm doing wrong with this code:

def login(self):
    with self.client.post("/login", {"email":"admin", "password":"incorrect_password"}, catch_response=True) as response:
        print(response.content)
        if "These credentials do not match our records." in response.content:
            response.failure("Wrong credentials.")

email and password are IDs of two input fields. I'd expect the print output to contain "These credentials do not match our records." but it's like the post request haven't been sent since there is no such error and user is not logged in.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants