diff options
| author | Alexis Métaireau <alexis@notmyidea.org> | 2013-09-23 13:03:51 +0200 |
|---|---|---|
| committer | Alexis Métaireau <alexis@notmyidea.org> | 2013-09-23 13:03:51 +0200 |
| commit | 0ac0bb493c366cbf390fe194be48b350f3226d75 (patch) | |
| tree | 42ea2b4a24638b598ff2309a07c4e693b8509238 /tests | |
| parent | 9d03c1cf5b08cb13bbf4db69115895d1316aa632 (diff) | |
| download | httpretty-0ac0bb493c366cbf390fe194be48b350f3226d75.tar.gz | |
Add a way to match the querystrings.
If you want to register one URI with multiple querystrings, you can pass the "match_querystring" attribute to register_uri.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/functional/test_requests.py | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/functional/test_requests.py b/tests/functional/test_requests.py index 930ec28..dfd7c42 100644 --- a/tests/functional/test_requests.py +++ b/tests/functional/test_requests.py @@ -520,6 +520,28 @@ def test_httpretty_provides_easy_access_to_querystrings_with_regexes(): @httprettified +def test_httpretty_allows_to_chose_if_querystring_should_be_matched(): + "HTTPretty should provide a way to not match regexes that have a different querystring" + + HTTPretty.register_uri( + HTTPretty.GET, + re.compile("https://example.org/(?P<endpoint>\w+)/$"), + body="Nudge, nudge, wink, wink. Know what I mean?", + match_querystring=True + ) + + response = requests.get('https://example.org/what/') + expect(response.text).to.equal('Nudge, nudge, wink, wink. Know what I mean?') + try: + requests.get('https://example.org/what/?flying=coconuts') + raised = False + except requests.ConnectionError: + raised = True + + assert raised is True + + +@httprettified def test_httpretty_should_allow_multiple_methods_for_the_same_uri(): "HTTPretty should allow registering multiple methods for the same uri" |
