diff --git a/0005-Expose-httpretty.latest_requests.patch b/0005-Expose-httpretty.latest_requests.patch new file mode 100644 index 0000000000000000000000000000000000000000..4df4c0dd50b90128808e16ba0055c86e81ebd813 --- /dev/null +++ b/0005-Expose-httpretty.latest_requests.patch @@ -0,0 +1,104 @@ +From c8db315b445e36e920bba5dc7105527f8d8ee030 Mon Sep 17 00:00:00 2001 +From: Bekt +Date: Mon, 31 Oct 2016 17:42:06 -0500 +Subject: [PATCH] Expose httpretty.latest_requests + +--- + README.md | 15 +++++++++++++++ + README.rst | 18 ++++++++++++++++++ + httpretty/__init__.py | 5 +++++ + tests/unit/test_main.py | 7 +++++++ + 4 files changed, 45 insertions(+) + +diff --git a/README.md b/README.md +index 2a713bd..1e0501a 100644 +--- a/README.md ++++ b/README.md +@@ -442,6 +442,21 @@ urllib2.urlopen('http://www.google.com') + urllib2.urlopen.when.called_with('http://www.reddit.com').should.have.raised(httpretty.errors.UnmockedError) + ``` + ++## checking multiple responses ++```python ++@httpretty.activate ++def test_post_bodies(): ++ url = 'http://httpbin.org/post' ++ httpretty.register_uri(httpretty.POST, url, status=200) ++ httpretty.register_uri(httpretty.POST, url, status=400) ++ ++ requests.post(url, data={'foo': 'bar'}) ++ requests.post(url, data={'zoo': 'zoo'}) ++ ++ assert 'foo=bar' in httpretty.latest_requests()[0].body ++ assert 'zoo=bar' in httpretty.latest_requests()[1].body ++``` ++ + # Motivation + + When building systems that access external resources such as RESTful +diff --git a/README.rst b/README.rst +index 8a40249..5c05024 100644 +--- a/README.rst ++++ b/README.rst +@@ -469,6 +469,24 @@ raising an error if an unregistered endpoint is requested + urllib2.urlopen('http://www.google.com') + urllib2.urlopen.when.called_with('http://www.reddit.com').should.have.raised(httpretty.errors.UnmockedError) + ++checking multiple responses ++--------------------------- ++ ++.. code:: python ++ ++ @httpretty.activate ++ def test_post_bodies(): ++ url = 'http://httpbin.org/post' ++ httpretty.register_uri(httpretty.POST, url, status=200) ++ httpretty.register_uri(httpretty.POST, url, status=400) ++ ++ requests.post(url, data={'foo': 'bar'}) ++ requests.post(url, data={'zoo': 'zoo'}) ++ ++ assert 'foo=bar' in httpretty.latest_requests()[0].body ++ assert 'zoo=bar' in httpretty.latest_requests()[1].body ++ ++ + Motivation + ========== + +diff --git a/httpretty/__init__.py b/httpretty/__init__.py +index 24d45a8..886dec7 100644 +--- a/httpretty/__init__.py ++++ b/httpretty/__init__.py +@@ -56,6 +56,11 @@ def last_request(): + return httpretty.last_request + + ++def latest_requests(): ++ """returns the history of made requests""" ++ return httpretty.latest_requests ++ ++ + def has_request(): + """returns a boolean indicating whether any request has been made""" + return not isinstance(httpretty.last_request.headers, EmptyRequestHeaders) +diff --git a/tests/unit/test_main.py b/tests/unit/test_main.py +index 6ce49d8..a6ddb70 100644 +--- a/tests/unit/test_main.py ++++ b/tests/unit/test_main.py +@@ -13,6 +13,13 @@ def test_last_request(original): + httpretty.last_request().should.equal(original.last_request) + + ++@patch('httpretty.httpretty') ++def test_last_request(original): ++ ("httpretty.latest_requests() should return httpretty.core.latest_requests") ++ ++ httpretty.latest_requests().should.equal(original.latest_requests) ++ ++ + def test_has_request(): + ("httpretty.has_request() correctly detects " + "whether or not a request has been made") +-- +2.39.0.windows.2 + diff --git a/python-httpretty.spec b/python-httpretty.spec index aba02e5408326feadd741fa4218077e927178659..5159c8feedd8d1dae143fb38b43604a7407fdf05 100644 --- a/python-httpretty.spec +++ b/python-httpretty.spec @@ -1,6 +1,6 @@ Name: python-httpretty Version: 0.9.5 -Release: 8 +Release: 9 Summary: HTTP Client mocking tool for Python License: MIT URL: https://pypi.org/project/httpretty/ @@ -13,6 +13,7 @@ Patch0004: Mock-time-to-make-date-based-tests-reliable.patch Patch0005: 0002-fix-query-param-matching.patch Patch0006: 0003-Support-old-Python-2.7-releases-341.patch Patch0007: 0004-lint.patch +Patch0008: 0005-Expose-httpretty.latest_requests.patch BuildRequires: python2-devel python2-setuptools python2-httplib2 python2-mock python2-nose BuildRequires: python2-requests python2-sure python2-urllib3 python2-tornado python-unittest2 @@ -72,6 +73,9 @@ LANG=en_US.UTF-8 %{__python3} -m nose2 -v %{python3_sitelib}/httpretty-%{version}-py3.?.egg-info %changelog +* Fri Jan 05 2024 zhangliangpengkun - 0.9.5-9 +- Expose httpretty.latest_requests + * Thu Dec 28 2023 zhangliangpengkun - 0.9.5-8 - lint