svanoort / pyresttest

Python Rest Testing
Apache License 2.0
1.15k stars 326 forks source link

Bind output from test for use in subsequent test #140

Closed dsem closed 8 years ago

dsem commented 8 years ago

I would like to bind the output of a test to a variable that can be used in a subsequent test. I need this in order to test endpoints like /object/{id} where ID is a hash generated by MongoDB. This hash is random and changes each time the database is seeded. I don't see any way of testing this endpoint without seeding the database, searching for a specific entry, binding the ID of that entry, and then using that to test the endpoint.

dsem commented 8 years ago

Bah, I should have looked through the examples and read the documentation better. It can be done with extract_binds.

svanoort commented 8 years ago

@dsem I was just writing up an answer with that, thanks for finding it and closing it out.

There's also an option to pass in variables with the 'vars' argument from the command line. Or you can use environment variables (with generators to env_variable to map in single variables or env_string to do environment string substitution)...