svanoort / pyresttest

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

Can't URLencode variables extracted from tests #159

Closed bernieblab closed 8 years ago

bernieblab commented 8 years ago

First off, I really like this test framework you've built. In one of my tests, I'm using extract_binds to assign data from a response to a variable to be used in subsequent tests. Unfortunately, when the data contains a space, I can't use it as part of a subsequent URL path because it isn't escaped properly. Here's a high-level example to illustrate:

- test:
   ...
   - extract_binds:
      - "person_name": {"jsonpath_mini": "person_name"}
...
- test:
   ...
   - url: {template: "/api/$person_name/info"}
   ...

Is there a workaround for this or am I doing something wrong?

svanoort commented 8 years ago

@bernieblab I'm glad you're finding it helpful! Unfortunately there isn't a way to do this yet; the way we do templates & dynamic variable use is very limiting, and hard to extend. I'm aware of the problems it poses.

There's an enhancement open in the next release for a much more powerful approach to variable use, templating, etc -- I've added a mention to that issue that offering a url-encoding feature would be highly desirable: https://github.com/svanoort/pyresttest/issues/101

svanoort commented 8 years ago

I should mention that you can define url-encoded values for variables, or define a custom extractor that does url encoding of variables.

bernieblab commented 8 years ago

Thanks for getting back to me so quickly and for the info. I'll keep an eye on #101.