Compare commits
27 commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d0e6456bb4 | ||
|
|
454c9f9e8c | ||
|
|
de2ac30ee8 | ||
|
|
1783e513cc | ||
|
|
0a49c780e6 | ||
|
|
f44b8e05c0 | ||
|
|
d931f4b75a | ||
|
|
94d72aa5c2 | ||
|
|
bc186ff056 | ||
|
|
4fc78b39a4 | ||
|
|
ba3b2a835e | ||
|
|
cec51896bc | ||
|
|
e954390a09 | ||
|
|
0014b0654c | ||
|
|
d6f92e3e61 | ||
|
|
351e29f866 | ||
|
|
98cbcd0bb0 | ||
|
|
f2e4b53fd3 | ||
|
|
6370a52965 | ||
|
|
d6e9eecfcd | ||
|
|
c07b37989b | ||
|
|
de30fb34ea | ||
|
|
18aa6f184d | ||
|
|
25fa48a59e | ||
|
|
eec7965292 | ||
|
|
4a519a2892 | ||
|
|
177688ec4c |
7 changed files with 201 additions and 66 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
|
@ -1,3 +1,3 @@
|
|||
/httmock-1.2.6.tar.gz
|
||||
/httmock-1.3.0.tar.gz
|
||||
/tests.py
|
||||
/httmock-1.4.0.tar.gz
|
||||
|
|
|
|||
25
.packit.yaml
Normal file
25
.packit.yaml
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
---
|
||||
# See the documentation for more information:
|
||||
# https://packit.dev/docs/configuration/
|
||||
|
||||
upstream_project_url: https://github.com/patrys/httmock
|
||||
copy_upstream_release_description: false
|
||||
upstream_tag_include: '^\d+\.\d+\.\d+$'
|
||||
|
||||
jobs:
|
||||
- job: pull_from_upstream
|
||||
trigger: release
|
||||
dist_git_branches:
|
||||
- fedora-rawhide
|
||||
- epel10
|
||||
- job: koji_build
|
||||
trigger: commit
|
||||
allowed_committers: ['packit','all_admins']
|
||||
dist_git_branches:
|
||||
- fedora-rawhide
|
||||
- epel10
|
||||
- job: bodhi_update
|
||||
trigger: commit
|
||||
allowed_builders: ['packit','all_users']
|
||||
dist_git_branches:
|
||||
- fedora-rawhide
|
||||
19
64.diff
Normal file
19
64.diff
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
diff --git a/tox.ini b/tox.ini
|
||||
new file mode 100644
|
||||
index 0000000..e781a62
|
||||
--- /dev/null
|
||||
+++ b/tox.ini
|
||||
@@ -0,0 +1,13 @@
|
||||
+# Tox (https://tox.readthedocs.io) is a tool for running tests
|
||||
+# in multiple virtualenvs. This configuration file will run the
|
||||
+# test suite on all supported Python versions. To use it,
|
||||
+# "python -m pip install tox" and then run "tox" from this directory.
|
||||
+
|
||||
+[tox]
|
||||
+envlist = py{27, 34, 35, 36, 37, 38, 39, 310, 311, py2, py3}
|
||||
+
|
||||
+[testenv]
|
||||
+deps =
|
||||
+ pytest
|
||||
+ requests
|
||||
+commands = {envpython} -b -m pytest -W always tests.py {posargs}
|
||||
92
changelog
Normal file
92
changelog
Normal file
|
|
@ -0,0 +1,92 @@
|
|||
* Sat Jan 18 2025 Fedora Release Engineering <releng@fedoraproject.org> - 1.4.0-16
|
||||
- Rebuilt for https://fedoraproject.org/wiki/Fedora_42_Mass_Rebuild
|
||||
|
||||
* Fri Jul 19 2024 Fedora Release Engineering <releng@fedoraproject.org> - 1.4.0-15
|
||||
- Rebuilt for https://fedoraproject.org/wiki/Fedora_41_Mass_Rebuild
|
||||
|
||||
* Fri Jun 07 2024 Python Maint <python-maint@redhat.com> - 1.4.0-14
|
||||
- Rebuilt for Python 3.13
|
||||
|
||||
* Fri Jan 26 2024 Fedora Release Engineering <releng@fedoraproject.org> - 1.4.0-13
|
||||
- Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild
|
||||
|
||||
* Mon Jan 22 2024 Fedora Release Engineering <releng@fedoraproject.org> - 1.4.0-12
|
||||
- Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild
|
||||
|
||||
* Fri Jul 21 2023 Fedora Release Engineering <releng@fedoraproject.org> - 1.4.0-11
|
||||
- Rebuilt for https://fedoraproject.org/wiki/Fedora_39_Mass_Rebuild
|
||||
|
||||
* Wed Jun 14 2023 Python Maint <python-maint@redhat.com> - 1.4.0-10
|
||||
- Rebuilt for Python 3.12
|
||||
|
||||
* Fri May 05 2023 Steve Traylen <steve.traylen@cern.ch> 1.4.0-9
|
||||
- Complete migration to pyproject macros
|
||||
- Switch SPDX license field
|
||||
- Use tests.py matching released version of module (rhbz#2175195)
|
||||
|
||||
* Fri Jan 20 2023 Fedora Release Engineering <releng@fedoraproject.org> - 1.4.0-8
|
||||
- Rebuilt for https://fedoraproject.org/wiki/Fedora_38_Mass_Rebuild
|
||||
|
||||
* Fri Jul 22 2022 Fedora Release Engineering <releng@fedoraproject.org> - 1.4.0-7
|
||||
- Rebuilt for https://fedoraproject.org/wiki/Fedora_37_Mass_Rebuild
|
||||
|
||||
* Mon Jun 13 2022 Python Maint <python-maint@redhat.com> - 1.4.0-6
|
||||
- Rebuilt for Python 3.11
|
||||
|
||||
* Fri Jan 28 2022 Steve Traylen <steve.traylen@cern.ch> 1.4.0-5
|
||||
- Migrate tests to tox rhbz#2019409
|
||||
|
||||
* Fri Jan 21 2022 Fedora Release Engineering <releng@fedoraproject.org> - 1.4.0-4
|
||||
- Rebuilt for https://fedoraproject.org/wiki/Fedora_36_Mass_Rebuild
|
||||
|
||||
* Fri Jul 23 2021 Fedora Release Engineering <releng@fedoraproject.org> - 1.4.0-3
|
||||
- Rebuilt for https://fedoraproject.org/wiki/Fedora_35_Mass_Rebuild
|
||||
|
||||
* Fri Jun 04 2021 Python Maint <python-maint@redhat.com> - 1.4.0-2
|
||||
- Rebuilt for Python 3.10
|
||||
|
||||
* Mon Mar 8 2021 Steve Traylen <steve.traylen@cern.ch> - 1.4.0-1
|
||||
- Update to 1.4.0
|
||||
|
||||
* Wed Jan 27 2021 Fedora Release Engineering <releng@fedoraproject.org> - 1.3.0-5
|
||||
- Rebuilt for https://fedoraproject.org/wiki/Fedora_34_Mass_Rebuild
|
||||
|
||||
* Wed Jul 29 2020 Fedora Release Engineering <releng@fedoraproject.org> - 1.3.0-4
|
||||
- Rebuilt for https://fedoraproject.org/wiki/Fedora_33_Mass_Rebuild
|
||||
|
||||
* Tue May 26 2020 Miro Hrončok <mhroncok@redhat.com> - 1.3.0-3
|
||||
- Rebuilt for Python 3.9
|
||||
|
||||
* Thu Jan 30 2020 Fedora Release Engineering <releng@fedoraproject.org> - 1.3.0-2
|
||||
- Rebuilt for https://fedoraproject.org/wiki/Fedora_32_Mass_Rebuild
|
||||
|
||||
* Wed Nov 13 2019 Steve Traylen <steve.traylen@cern.ch> - 1.3.0-1
|
||||
- Update to 1.3.0
|
||||
|
||||
* Thu Oct 03 2019 Miro Hrončok <mhroncok@redhat.com> - 1.2.6-9
|
||||
- Rebuilt for Python 3.8.0rc1 (#1748018)
|
||||
|
||||
* Mon Aug 19 2019 Miro Hrončok <mhroncok@redhat.com> - 1.2.6-8
|
||||
- Rebuilt for Python 3.8
|
||||
|
||||
* Fri Jul 26 2019 Fedora Release Engineering <releng@fedoraproject.org> - 1.2.6-7
|
||||
- Rebuilt for https://fedoraproject.org/wiki/Fedora_31_Mass_Rebuild
|
||||
|
||||
* Sat Feb 02 2019 Fedora Release Engineering <releng@fedoraproject.org> - 1.2.6-6
|
||||
- Rebuilt for https://fedoraproject.org/wiki/Fedora_30_Mass_Rebuild
|
||||
|
||||
* Fri Jan 04 2019 Igor Gnatenko <ignatenkobrain@fedoraproject.org> - 1.2.6-5
|
||||
- Enable python dependency generator
|
||||
|
||||
* Fri Jan 04 2019 Miro Hrončok <mhroncok@redhat.com> - 1.2.6-4
|
||||
- Subpackage python2-httmock has been removed
|
||||
See https://fedoraproject.org/wiki/Changes/Mass_Python_2_Package_Removal
|
||||
|
||||
* Sat Jul 14 2018 Fedora Release Engineering <releng@fedoraproject.org> - 1.2.6-3
|
||||
- Rebuilt for https://fedoraproject.org/wiki/Fedora_29_Mass_Rebuild
|
||||
|
||||
* Tue Jun 19 2018 Miro Hrončok <mhroncok@redhat.com> - 1.2.6-2
|
||||
- Rebuilt for Python 3.7
|
||||
|
||||
* Fri May 11 2018 Steve Traylen <steve.traylen@cern.ch> - 1.2.6-1
|
||||
- Initial package.
|
||||
|
|
@ -1,85 +1,60 @@
|
|||
%{?python_enable_dependency_generator}
|
||||
# Created by pyp2rpm-3.3.0
|
||||
%global pypi_name httmock
|
||||
|
||||
Name: python-%{pypi_name}
|
||||
Version: 1.3.0
|
||||
Release: 1%{?dist}
|
||||
Name: python-httmock
|
||||
Version: 1.4.0
|
||||
Release: %autorelease
|
||||
Summary: A mocking library for requests
|
||||
|
||||
License: ASL 2.0
|
||||
License: Apache-2.0
|
||||
URL: https://github.com/patrys/httmock
|
||||
|
||||
# Switch to github at next release to avoid the extra Source1
|
||||
Source0: https://files.pythonhosted.org/packages/source/h/httmock/httmock-%{version}.tar.gz
|
||||
Source1: https://raw.githubusercontent.com/patrys/httmock/%{version}/tests.py
|
||||
|
||||
# Add a tox file.
|
||||
# https://bugzilla.redhat.com/show_bug.cgi?id=2019409
|
||||
Patch0: https://patch-diff.githubusercontent.com/raw/patrys/httmock/pull/64.diff
|
||||
BuildArch: noarch
|
||||
|
||||
%description
|
||||
%global _description %{expand:
|
||||
A mocking library for requests for Python.
|
||||
You can use it to mock third-party APIs and test libraries
|
||||
that use requests internally.
|
||||
that use requests internally}
|
||||
|
||||
%package -n python3-%{pypi_name}
|
||||
|
||||
%description %_description
|
||||
|
||||
%package -n python3-httmock
|
||||
Summary: %{summary}
|
||||
%{?python_provide:%python_provide python3-%{pypi_name}}
|
||||
BuildRequires: python3-devel
|
||||
BuildRequires: python3-setuptools
|
||||
BuildRequires: python3dist(requests) >= 1
|
||||
|
||||
%description -n python3-%{pypi_name}
|
||||
A mocking library for requests for Python.
|
||||
You can use it to mock third-party APIs and test libraries
|
||||
that use requests internally.
|
||||
|
||||
%description -n python3-httmock %_description
|
||||
|
||||
|
||||
%prep
|
||||
%autosetup -n %{pypi_name}-%{version}
|
||||
# Remove bundled egg-info
|
||||
rm -rf %{pypi_name}.egg-info
|
||||
%autosetup -p1 -n httmock-%{version}
|
||||
cp %{SOURCE1} .
|
||||
|
||||
%generate_buildrequires
|
||||
%pyproject_buildrequires -t
|
||||
|
||||
|
||||
%build
|
||||
%py3_build
|
||||
%pyproject_wheel
|
||||
|
||||
|
||||
%install
|
||||
%py3_install
|
||||
%pyproject_install
|
||||
|
||||
%pyproject_save_files httmock
|
||||
|
||||
|
||||
%check
|
||||
%{__python3} setup.py test
|
||||
%{tox}
|
||||
|
||||
%files -n python3-%{pypi_name}
|
||||
|
||||
%files -n python3-httmock -f %{pyproject_files}
|
||||
%license LICENSE
|
||||
%doc README.md
|
||||
%{python3_sitelib}/__pycache__/*
|
||||
%{python3_sitelib}/%{pypi_name}.py
|
||||
%{python3_sitelib}/%{pypi_name}-%{version}-py?.?.egg-info
|
||||
|
||||
|
||||
%changelog
|
||||
* Wed Nov 13 2019 Steve Traylen <steve.traylen@cern.ch> - 1.3.0-1
|
||||
- Update to 1.3.0
|
||||
|
||||
* Thu Oct 03 2019 Miro Hrončok <mhroncok@redhat.com> - 1.2.6-9
|
||||
- Rebuilt for Python 3.8.0rc1 (#1748018)
|
||||
|
||||
* Mon Aug 19 2019 Miro Hrončok <mhroncok@redhat.com> - 1.2.6-8
|
||||
- Rebuilt for Python 3.8
|
||||
|
||||
* Fri Jul 26 2019 Fedora Release Engineering <releng@fedoraproject.org> - 1.2.6-7
|
||||
- Rebuilt for https://fedoraproject.org/wiki/Fedora_31_Mass_Rebuild
|
||||
|
||||
* Sat Feb 02 2019 Fedora Release Engineering <releng@fedoraproject.org> - 1.2.6-6
|
||||
- Rebuilt for https://fedoraproject.org/wiki/Fedora_30_Mass_Rebuild
|
||||
|
||||
* Fri Jan 04 2019 Igor Gnatenko <ignatenkobrain@fedoraproject.org> - 1.2.6-5
|
||||
- Enable python dependency generator
|
||||
|
||||
* Fri Jan 04 2019 Miro Hrončok <mhroncok@redhat.com> - 1.2.6-4
|
||||
- Subpackage python2-httmock has been removed
|
||||
See https://fedoraproject.org/wiki/Changes/Mass_Python_2_Package_Removal
|
||||
|
||||
* Sat Jul 14 2018 Fedora Release Engineering <releng@fedoraproject.org> - 1.2.6-3
|
||||
- Rebuilt for https://fedoraproject.org/wiki/Fedora_29_Mass_Rebuild
|
||||
|
||||
* Tue Jun 19 2018 Miro Hrončok <mhroncok@redhat.com> - 1.2.6-2
|
||||
- Rebuilt for Python 3.7
|
||||
|
||||
* Fri May 11 2018 Steve Traylen <steve.traylen@cern.ch> - 1.2.6-1
|
||||
- Initial package.
|
||||
%autochangelog
|
||||
|
|
|
|||
3
sources
3
sources
|
|
@ -1,2 +1 @@
|
|||
SHA512 (tests.py) = f869c9923bdd68c8758c1937eb61a7b8e2aae1ef32dce9ca850460dfdfd8daae7c20e1e5b9c298c1ce600900cbe2c34ba9660bd0ded0dbd34e817e39a18eee72
|
||||
SHA512 (httmock-1.3.0.tar.gz) = f713ddf45675738582a3611e01a55babce2951231b34fb9ca6b1b64fcf60a3862994ff7ad4cd7a224a116c6acb1caa267978a7cb6fedd02676fa2a01f90e93aa
|
||||
SHA512 (httmock-1.4.0.tar.gz) = d8674c0bd7c667d02e100f35157f717189ddcfb14d26993a87e8823aec255d191ab6ac53da0cb4035eb37caab36f8f7c6705bf10f0d8d4de62a5aa09cddacfc4
|
||||
|
|
|
|||
31
tests.py
31
tests.py
|
|
@ -66,7 +66,8 @@ def any_mock(url, request):
|
|||
def dict_any_mock(url, request):
|
||||
return {
|
||||
'content': 'Hello from %s' % (url.netloc,),
|
||||
'status_code': 200
|
||||
'status_code': 200,
|
||||
'http_vsn': 10,
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -136,6 +137,13 @@ class MockTest(unittest.TestCase):
|
|||
self.assertEqual(r.text, u'Motörhead')
|
||||
self.assertEqual(r.content, r.text.encode('utf-8'))
|
||||
|
||||
def test_has_raw_version(self):
|
||||
with HTTMock(any_mock):
|
||||
r = requests.get('http://example.com')
|
||||
self.assertEqual(r.raw.version, 11)
|
||||
with HTTMock(dict_any_mock):
|
||||
r = requests.get('http://example.com')
|
||||
self.assertEqual(r.raw.version, 10)
|
||||
|
||||
class DecoratorTest(unittest.TestCase):
|
||||
|
||||
|
|
@ -242,6 +250,11 @@ class ResponseTest(unittest.TestCase):
|
|||
r = response(200, None, {'Content-Type': 'application/json'})
|
||||
self.assertEqual(r.headers['content-type'], 'application/json')
|
||||
|
||||
def test_response_raw_version(self):
|
||||
r = response(200, None, {'Content-Type': 'application/json'},
|
||||
http_vsn=10)
|
||||
self.assertEqual(r.raw.version, 10)
|
||||
|
||||
def test_response_cookies(self):
|
||||
@all_requests
|
||||
def response_content(url, request):
|
||||
|
|
@ -268,6 +281,18 @@ class ResponseTest(unittest.TestCase):
|
|||
self.assertTrue('foo' in session.cookies)
|
||||
self.assertEqual(session.cookies['foo'], 'bar')
|
||||
|
||||
def test_session_persistent_cookies(self):
|
||||
session = requests.Session()
|
||||
with HTTMock(lambda u, r: response(200, 'Foo', {'Set-Cookie': 'foo=bar;'}, request=r)):
|
||||
session.get('https://foo_bar')
|
||||
with HTTMock(lambda u, r: response(200, 'Baz', {'Set-Cookie': 'baz=qux;'}, request=r)):
|
||||
session.get('https://baz_qux')
|
||||
self.assertEqual(len(session.cookies), 2)
|
||||
self.assertTrue('foo' in session.cookies)
|
||||
self.assertEqual(session.cookies['foo'], 'bar')
|
||||
self.assertTrue('baz' in session.cookies)
|
||||
self.assertEqual(session.cookies['baz'], 'qux')
|
||||
|
||||
def test_python_version_encoding_differences(self):
|
||||
# Previous behavior would result in this test failing in Python3 due
|
||||
# to how requests checks for utf-8 JSON content in requests.utils with:
|
||||
|
|
@ -341,7 +366,7 @@ class RememberCalledTest(unittest.TestCase):
|
|||
results = self.several_calls(
|
||||
1, requests.get, 'http://facebook.com/')
|
||||
|
||||
self.assertEquals(facebook_mock_count.call['count'], 1)
|
||||
self.assertEqual(facebook_mock_count.call['count'], 1)
|
||||
|
||||
@with_httmock(google_mock_count, facebook_mock_count)
|
||||
def test_several_call_decorated(self):
|
||||
|
|
@ -357,7 +382,7 @@ class RememberCalledTest(unittest.TestCase):
|
|||
self.assertEqual(r.content, b'Hello from Facebook')
|
||||
|
||||
self.several_calls(1, requests.get, 'http://facebook.com/')
|
||||
self.assertEquals(facebook_mock_count.call['count'], 4)
|
||||
self.assertEqual(facebook_mock_count.call['count'], 4)
|
||||
|
||||
def test_store_several_requests(self):
|
||||
with HTTMock(google_mock_store_requests):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue