Hello community, here is the log from the commit of package python-mocket for openSUSE:Factory checked in at 2020-08-12 10:30:57 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/python-mocket (Old) and /work/SRC/openSUSE:Factory/.python-mocket.new.3399 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-mocket" Wed Aug 12 10:30:57 2020 rev:5 rq:825737 version:3.8.7 Changes: -------- --- /work/SRC/openSUSE:Factory/python-mocket/python-mocket.changes 2020-08-10 14:59:40.512053615 +0200 +++ /work/SRC/openSUSE:Factory/.python-mocket.new.3399/python-mocket.changes 2020-08-12 10:36:44.508298543 +0200 @@ -1,0 +2,12 @@ +Tue Aug 11 07:17:16 UTC 2020 - Benjamin Greiner <[email protected]> + +- Update to version 3.8.7 + * This version ships the change to support the libmagic wrapper + distributed with file's command. + +------------------------------------------------------------------- +Tue Aug 11 07:08:04 UTC 2020 - Tomáš Chvátal <[email protected]> + +- Switch to multibuild as we create cycle with python-pook otherwise + +------------------------------------------------------------------- Old: ---- mocket-3.8.6.tar.gz New: ---- _multibuild mocket-3.8.7.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ python-mocket.spec ++++++ --- /var/tmp/diff_new_pack.fSbZpf/_old 2020-08-12 10:36:45.964299266 +0200 +++ /var/tmp/diff_new_pack.fSbZpf/_new 2020-08-12 10:36:45.968299268 +0200 @@ -17,12 +17,19 @@ %{?!python_module:%define python_module() python-%{**} python3-%{**}} -Name: python-mocket -Version: 3.8.6 +%global flavor @BUILD_FLAVOR@%{nil} +%if "%{flavor}" == "test" +%define psuffix -test +%bcond_without test +%else +%define psuffix %{nil} +%bcond_with test +%endif +Name: python-mocket%{psuffix} +Version: 3.8.7 Release: 0 Summary: Python socket mock framework License: BSD-3-Clause -Group: Development/Languages/Python URL: https://github.com/mindflayer/python-mocket Source0: https://files.pythonhosted.org/packages/source/m/mocket/mocket-%{version}.tar.gz BuildRequires: %{python_module setuptools} @@ -38,7 +45,7 @@ Suggests: python-requests Suggests: python-xxhash BuildArch: noarch -# SECTION test requirements +%if %{with test} BuildRequires: %{python_module PySocks} BuildRequires: %{python_module cryptography} BuildRequires: %{python_module decorator} @@ -57,7 +64,7 @@ BuildRequires: ca-certificates-mozilla BuildRequires: python3-aiohttp BuildRequires: python3-async_timeout -# /SECTION +%endif %python_subpackages %description @@ -66,35 +73,37 @@ %prep %setup -q -n mocket-%{version} -rm -f setup.cfg pytest.ini tox.ini -sed -i '/pipenv/d' setup.py +sed -i '/cov/ d' setup.cfg +sed -i '/pipenv/ d' setup.py sed -i 's/==/>=/' requirements.txt -touch conftest.py %build +%if !%{with test} export LANG=en_US.UTF-8 %python_build +%endif %install +%if !%{with test} export LANG=en_US.UTF-8 %python_install %python_expand %fdupes %{buildroot}%{$python_sitelib} +%endif %check +%if %{with test} export LANG=en_US.UTF-8 -export PYTHONPATH=${PWD} export SKIP_TRUE_HTTP=1 -%{python_expand # -if [ $python = python2 ]; then - $python -m pytest tests/main mocket -vv -k 'not RedisTestCase' -else - $python -m pytest tests/main mocket tests/tests35/ -vv -k 'not RedisTestCase' -fi -} +%define pytest_ignore_python2 --ignore tests/tests35 --ignore tests/tests38 +%pytest -k 'not RedisTestCase' %{?pytest_ignore%{$python_version}} +%endif +%if !%{with test} %files %{python_files} %doc README.rst %license LICENSE -%{python_sitelib}/* +%{python_sitelib}/mocket +%{python_sitelib}/mocket-%{version}-py*.egg-info +%endif %changelog ++++++ _multibuild ++++++ <multibuild> <package>test</package> </multibuild> ++++++ mocket-3.8.6.tar.gz -> mocket-3.8.7.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/mocket-3.8.6/PKG-INFO new/mocket-3.8.7/PKG-INFO --- old/mocket-3.8.6/PKG-INFO 2020-06-18 20:32:40.840286000 +0200 +++ new/mocket-3.8.7/PKG-INFO 2020-07-27 19:01:18.508651700 +0200 @@ -1,6 +1,6 @@ Metadata-Version: 2.1 Name: mocket -Version: 3.8.6 +Version: 3.8.7 Summary: Socket Mock Framework - for all kinds of socket animals, web-clients included - with gevent/asyncio/SSL support Home-page: https://github.com/mindflayer/python-mocket Author: Giorgio Salluzzo @@ -34,7 +34,12 @@ Support it ========== - *Star* the project on GitHub, Buy Me a Coffee or, even better, contribute with patches or documentation. + *Star* the project on GitHub, *Buy Me a Coffee* clicking the button below or, even better, contribute with patches or documentation. + + Thanks to `@felixonmars`_ Mocket is available in the `Arch Linux repository`_. + + .. _`@felixonmars`: https://github.com/felixonmars + .. _`Arch Linux repository`: https://www.archlinux.org/packages/community/any/python-mocket/ .. image:: https://www.buymeacoffee.com/assets/img/custom_images/orange_img.png :target: https://www.buymeacoffee.com/mULbInw5z @@ -90,13 +95,13 @@ .. code-block:: python import json - + from mocket import mocketize from mocket.mockhttp import Entry import requests import pytest - - + + @pytest.fixture def response(): return { @@ -104,39 +109,39 @@ "string": "asd", "boolean": False, } - - + + @mocketize # use its decorator def test_json(response): url_to_mock = 'https://testme.org/json' - + Entry.single_register( Entry.GET, url_to_mock, body=json.dumps(response), headers={'content-type': 'application/json'} ) - + mocked_response = requests.get(url_to_mock).json() - + assert response == mocked_response # OR use its context manager from mocket import Mocketizer - + def test_json_with_context_manager(response): url_to_mock = 'https://testme.org/json' - + Entry.single_register( Entry.GET, url_to_mock, body=json.dumps(response), headers={'content-type': 'application/json'} ) - + with Mocketizer(): mocked_response = requests.get(url_to_mock).json() - + assert response == mocked_response Let's fire our example test:: @@ -191,7 +196,7 @@ ==================================== Using *Mocket* with asyncio based clients:: - $ pip install aiohttp + $ pip install aiohttp Example: @@ -220,6 +225,31 @@ loop = asyncio.get_event_loop() loop.run_until_complete(main(loop)) + # or again with a unittest.IsolatedAsyncioTestCase + from mocket.async_mocket import async_mocketize + + class AioHttpEntryTestCase(IsolatedAsyncioTestCase): + @async_mocketize + async def test_http_session(self): + url = 'http://httpbin.org/ip' + body = "asd" * 100 + Entry.single_register(Entry.GET, url, body=body, status=404) + Entry.single_register(Entry.POST, url, body=body * 2, status=201) + + async with aiohttp.ClientSession() as session: + with async_timeout.timeout(3): + async with session.get(url) as get_response: + assert get_response.status == 404 + assert await get_response.text() == body + + with async_timeout.timeout(3): + async with session.post(url, data=body * 6) as post_response: + assert post_response.status == 201 + assert await post_response.text() == body * 2 + assert Mocket.last_request().method == 'POST' + assert Mocket.last_request().body == body * 6 + + Works well with others ======================= Using *Mocket* as pook_ engine:: @@ -281,6 +311,7 @@ Classifier: Topic :: Software Development Classifier: Topic :: Software Development :: Testing Classifier: License :: OSI Approved :: BSD License +Description-Content-Type: text/x-rst Provides-Extra: dev Provides-Extra: pook Provides-Extra: speedups diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/mocket-3.8.6/README.rst new/mocket-3.8.7/README.rst --- old/mocket-3.8.6/README.rst 2020-02-20 11:00:16.000000000 +0100 +++ new/mocket-3.8.7/README.rst 2020-07-27 18:58:39.000000000 +0200 @@ -26,7 +26,12 @@ Support it ========== -*Star* the project on GitHub, Buy Me a Coffee or, even better, contribute with patches or documentation. +*Star* the project on GitHub, *Buy Me a Coffee* clicking the button below or, even better, contribute with patches or documentation. + +Thanks to `@felixonmars`_ Mocket is available in the `Arch Linux repository`_. + +.. _`@felixonmars`: https://github.com/felixonmars +.. _`Arch Linux repository`: https://www.archlinux.org/packages/community/any/python-mocket/ .. image:: https://www.buymeacoffee.com/assets/img/custom_images/orange_img.png :target: https://www.buymeacoffee.com/mULbInw5z @@ -82,13 +87,13 @@ .. code-block:: python import json - + from mocket import mocketize from mocket.mockhttp import Entry import requests import pytest - - + + @pytest.fixture def response(): return { @@ -96,39 +101,39 @@ "string": "asd", "boolean": False, } - - + + @mocketize # use its decorator def test_json(response): url_to_mock = 'https://testme.org/json' - + Entry.single_register( Entry.GET, url_to_mock, body=json.dumps(response), headers={'content-type': 'application/json'} ) - + mocked_response = requests.get(url_to_mock).json() - + assert response == mocked_response # OR use its context manager from mocket import Mocketizer - + def test_json_with_context_manager(response): url_to_mock = 'https://testme.org/json' - + Entry.single_register( Entry.GET, url_to_mock, body=json.dumps(response), headers={'content-type': 'application/json'} ) - + with Mocketizer(): mocked_response = requests.get(url_to_mock).json() - + assert response == mocked_response Let's fire our example test:: @@ -183,7 +188,7 @@ ==================================== Using *Mocket* with asyncio based clients:: - $ pip install aiohttp + $ pip install aiohttp Example: @@ -212,6 +217,31 @@ loop = asyncio.get_event_loop() loop.run_until_complete(main(loop)) + # or again with a unittest.IsolatedAsyncioTestCase + from mocket.async_mocket import async_mocketize + + class AioHttpEntryTestCase(IsolatedAsyncioTestCase): + @async_mocketize + async def test_http_session(self): + url = 'http://httpbin.org/ip' + body = "asd" * 100 + Entry.single_register(Entry.GET, url, body=body, status=404) + Entry.single_register(Entry.POST, url, body=body * 2, status=201) + + async with aiohttp.ClientSession() as session: + with async_timeout.timeout(3): + async with session.get(url) as get_response: + assert get_response.status == 404 + assert await get_response.text() == body + + with async_timeout.timeout(3): + async with session.post(url, data=body * 6) as post_response: + assert post_response.status == 201 + assert await post_response.text() == body * 2 + assert Mocket.last_request().method == 'POST' + assert Mocket.last_request().body == body * 6 + + Works well with others ======================= Using *Mocket* as pook_ engine:: diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/mocket-3.8.6/mocket/__init__.py new/mocket-3.8.7/mocket/__init__.py --- old/mocket-3.8.6/mocket/__init__.py 2020-06-18 19:12:28.000000000 +0200 +++ new/mocket-3.8.7/mocket/__init__.py 2020-07-27 18:44:00.000000000 +0200 @@ -7,4 +7,4 @@ __all__ = ("mocketize", "Mocket", "MocketEntry", "Mocketizer") -__version__ = "3.8.6" +__version__ = "3.8.7" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/mocket-3.8.6/mocket/compat.py new/mocket-3.8.7/mocket/compat.py --- old/mocket-3.8.6/mocket/compat.py 2020-02-20 11:00:16.000000000 +0100 +++ new/mocket-3.8.7/mocket/compat.py 2020-07-27 18:30:55.000000000 +0200 @@ -61,3 +61,15 @@ else: s = decode_from_bytes(s) return shlex.split(s) + + +def do_the_magic(lib_magic, body): + if hasattr(lib_magic, "from_buffer"): + # PyPI python-magic + return lib_magic.from_buffer(body, mime=True) + else: + # file's builtin python wrapper + # used by https://www.archlinux.org/packages/community/any/python-mocket/ + _magic = lib_magic.open(lib_magic.MAGIC_MIME_TYPE) + _magic.load() + return _magic.buffer(body) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/mocket-3.8.6/mocket/mockhttp.py new/mocket-3.8.7/mocket/mockhttp.py --- old/mocket-3.8.6/mocket/mockhttp.py 2020-05-05 12:09:51.000000000 +0200 +++ new/mocket-3.8.7/mocket/mockhttp.py 2020-07-27 18:30:19.000000000 +0200 @@ -7,6 +7,7 @@ from .compat import ( BaseHTTPRequestHandler, decode_from_bytes, + do_the_magic, encode_to_bytes, parse_qs, unquote_utf8, @@ -87,9 +88,7 @@ if not self.is_file_object: self.headers["Content-Type"] = "text/plain; charset=utf-8" elif self.magic: - self.headers["Content-Type"] = decode_from_bytes( - magic.from_buffer(self.body, mime=True) - ) + self.headers["Content-Type"] = do_the_magic(self.magic, self.body) def set_extra_headers(self, headers): for k, v in headers.items(): diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/mocket-3.8.6/mocket.egg-info/PKG-INFO new/mocket-3.8.7/mocket.egg-info/PKG-INFO --- old/mocket-3.8.6/mocket.egg-info/PKG-INFO 2020-06-18 20:32:40.000000000 +0200 +++ new/mocket-3.8.7/mocket.egg-info/PKG-INFO 2020-07-27 19:01:18.000000000 +0200 @@ -1,6 +1,6 @@ Metadata-Version: 2.1 Name: mocket -Version: 3.8.6 +Version: 3.8.7 Summary: Socket Mock Framework - for all kinds of socket animals, web-clients included - with gevent/asyncio/SSL support Home-page: https://github.com/mindflayer/python-mocket Author: Giorgio Salluzzo @@ -34,7 +34,12 @@ Support it ========== - *Star* the project on GitHub, Buy Me a Coffee or, even better, contribute with patches or documentation. + *Star* the project on GitHub, *Buy Me a Coffee* clicking the button below or, even better, contribute with patches or documentation. + + Thanks to `@felixonmars`_ Mocket is available in the `Arch Linux repository`_. + + .. _`@felixonmars`: https://github.com/felixonmars + .. _`Arch Linux repository`: https://www.archlinux.org/packages/community/any/python-mocket/ .. image:: https://www.buymeacoffee.com/assets/img/custom_images/orange_img.png :target: https://www.buymeacoffee.com/mULbInw5z @@ -90,13 +95,13 @@ .. code-block:: python import json - + from mocket import mocketize from mocket.mockhttp import Entry import requests import pytest - - + + @pytest.fixture def response(): return { @@ -104,39 +109,39 @@ "string": "asd", "boolean": False, } - - + + @mocketize # use its decorator def test_json(response): url_to_mock = 'https://testme.org/json' - + Entry.single_register( Entry.GET, url_to_mock, body=json.dumps(response), headers={'content-type': 'application/json'} ) - + mocked_response = requests.get(url_to_mock).json() - + assert response == mocked_response # OR use its context manager from mocket import Mocketizer - + def test_json_with_context_manager(response): url_to_mock = 'https://testme.org/json' - + Entry.single_register( Entry.GET, url_to_mock, body=json.dumps(response), headers={'content-type': 'application/json'} ) - + with Mocketizer(): mocked_response = requests.get(url_to_mock).json() - + assert response == mocked_response Let's fire our example test:: @@ -191,7 +196,7 @@ ==================================== Using *Mocket* with asyncio based clients:: - $ pip install aiohttp + $ pip install aiohttp Example: @@ -220,6 +225,31 @@ loop = asyncio.get_event_loop() loop.run_until_complete(main(loop)) + # or again with a unittest.IsolatedAsyncioTestCase + from mocket.async_mocket import async_mocketize + + class AioHttpEntryTestCase(IsolatedAsyncioTestCase): + @async_mocketize + async def test_http_session(self): + url = 'http://httpbin.org/ip' + body = "asd" * 100 + Entry.single_register(Entry.GET, url, body=body, status=404) + Entry.single_register(Entry.POST, url, body=body * 2, status=201) + + async with aiohttp.ClientSession() as session: + with async_timeout.timeout(3): + async with session.get(url) as get_response: + assert get_response.status == 404 + assert await get_response.text() == body + + with async_timeout.timeout(3): + async with session.post(url, data=body * 6) as post_response: + assert post_response.status == 201 + assert await post_response.text() == body * 2 + assert Mocket.last_request().method == 'POST' + assert Mocket.last_request().body == body * 6 + + Works well with others ======================= Using *Mocket* as pook_ engine:: @@ -281,6 +311,7 @@ Classifier: Topic :: Software Development Classifier: Topic :: Software Development :: Testing Classifier: License :: OSI Approved :: BSD License +Description-Content-Type: text/x-rst Provides-Extra: dev Provides-Extra: pook Provides-Extra: speedups diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/mocket-3.8.6/mocket.egg-info/requires.txt new/mocket-3.8.7/mocket.egg-info/requires.txt --- old/mocket-3.8.6/mocket.egg-info/requires.txt 2020-06-18 20:32:40.000000000 +0200 +++ new/mocket-3.8.7/mocket.egg-info/requires.txt 2020-07-27 19:01:18.000000000 +0200 @@ -1,7 +1,7 @@ decorator==4.4.2 python-magic==0.4.18 six==1.15.0 -urllib3==1.25.9 +urllib3==1.25.10 [dev] diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/mocket-3.8.6/requirements.txt new/mocket-3.8.7/requirements.txt --- old/mocket-3.8.6/requirements.txt 2020-06-18 20:32:28.000000000 +0200 +++ new/mocket-3.8.7/requirements.txt 2020-07-27 19:01:14.000000000 +0200 @@ -1,4 +1,5 @@ +-i https://pypi.python.org/simple decorator==4.4.2 python-magic==0.4.18 six==1.15.0 -urllib3==1.25.9 +urllib3==1.25.10 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/mocket-3.8.6/setup.py new/mocket-3.8.7/setup.py --- old/mocket-3.8.6/setup.py 2020-06-18 19:53:00.000000000 +0200 +++ new/mocket-3.8.7/setup.py 2020-07-27 16:57:54.000000000 +0200 @@ -37,6 +37,7 @@ description="Socket Mock Framework - for all kinds of socket animals, web-clients included - \ with gevent/asyncio/SSL support", long_description=io.open("README.rst", encoding="utf-8").read(), + long_description_content_type="text/x-rst", packages=find_packages(exclude=exclude_packages), install_requires=install_requires, setup_requires=["pipenv"],
