2024-09-03 09:26:21 +02:00
#
# spec file
#
# Copyright (c) 2024 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.
# Please submit bugfixes or comments via https://bugs.opensuse.org/
#
%global flavor @BUILD_FLAVOR@%{nil}
%if "%{flavor}" == "test"
%define psuffix -test
%bcond_without test
%else
%define psuffix %{nil}
%bcond_with test
%endif
%{?sle15_python_module_pythons}
Name : python-mocket%{psuffix}
Version : 3.12.9
Release : 0
Summary : Python socket mock framework
License : BSD-3-Clause
URL : https://github.com/mindflayer/python-mocket
Source0 : https://files.pythonhosted.org/packages/source/m/mocket/mocket-%{version} .tar.gz
BuildRequires : %{python_module hatchling}
BuildRequires : %{python_module pip}
BuildRequires : %{python_module setuptools}
BuildRequires : %{python_module wheel}
BuildRequires : fdupes
BuildRequires : python-rpm-macros
Requires : python-decorator >= 4
Requires : python-h11
Requires : python-python-magic >= 0.4.5
Requires : python-urllib3 >= 1.25.3
Suggests : python-pook >= 0.2.1
Suggests : python-xxhash
BuildArch : noarch
%if %{with test}
BuildRequires : %{python_module aiohttp}
BuildRequires : %{python_module asgiref}
BuildRequires : %{python_module fastapi}
BuildRequires : %{python_module gevent}
BuildRequires : %{python_module httptools}
BuildRequires : %{python_module mocket = %{version} }
BuildRequires : %{python_module pook >= 0.2.1}
BuildRequires : %{python_module psutil}
BuildRequires : %{python_module pytest-asyncio}
BuildRequires : %{python_module pytest}
BuildRequires : %{python_module redis}
BuildRequires : %{python_module requests}
BuildRequires : %{python_module sure}
BuildRequires : %{python_module xxhash}
BuildRequires : ca-certificates-mozilla
BuildRequires : redis
%endif
%python_subpackages
%description
Socket Mock Framework - for all kinds of socket animals, web-clients
included, with gevent/asyncio/SSL support.
%prep
%autosetup -p1 -n mocket-%{version}
2024-09-03 09:38:40 +02:00
sed -i 's/--cov[^ ]*//g' pyproject.toml
2024-09-03 09:26:21 +02:00
%build
%if !%{with test}
export LANG=en_US.UTF-8
%pyproject_wheel
%endif
%install
%if !%{with test}
export LANG=en_US.UTF-8
%pyproject_install
%python_expand %fdupes %{buildroot} %{$python_sitelib}
%endif
%check
%if %{with test}
export LANG=en_US.UTF-8
export SKIP_TRUE_HTTP=1
%if 0%{?suse_version} < 1550
# Ignore tests which are not supported on Python 3.6
pytest_python3_ignore=" - - i g n o r e t e s t s / t e s t s 3 7 - - i g n o r e t e s t s / t e s t s 3 8 "
%endif
%{_sbindir} /redis-server --version | grep ' v=7\.' && redis7args=" - - e n a b l e - d e b u g - c o m m a n d y e s - - e n a b l e - m o d u l e - c o m m a n d y e s "
%{_sbindir} /redis-server --port 6379 --save " " $redis7args &
victims=" $ ! "
trap " k i l l $ v i c t i m s | | t r u e " EXIT
sleep 2
# Checks the ability to record a real request and response. Not available inside obs.
donttest=" t e s t _ a s y n c i o _ r e c o r d _ r e p l a y o r t e s t _ t r u e s e n d a l l _ w i t h _ d u m p _ f r o m _ r e c o r d i n g o r t e s t _ n o _ d a n g l i n g _ f d s "
# The reference recording has different headers in this case
%if %{pkg_vcmp python311-httpx < 0.23}
donttest=" $ d o n t t e s t o r t e s t _ t r u e s e n d a l l _ w i t h _ d u m p _ f r o m _ r e c o r d i n g "
%endif
# these fail after the python 3.11 patches
2024-09-03 09:38:40 +02:00
#donttest="$donttest or test_http_session or test_https_session or test_httprettish_session or test_truesendall or test_wrongpath_truesendall or test_real_request_session or test_multiple_socket_connections or test_intermittent_strict_mode or test_strict_mode_exceptions or test_err or test_get or test_hm or test_incr or test_lrange or test_select_db or test_set or test_shutdown or test_hgetall or test_raise_exception"
%pytest -rfEs -k " n o t ( $ d o n t t e s t ) " ${pytest_$python_ignore} tests
2024-09-03 09:26:21 +02:00
%endif
%if !%{with test}
%files %{python_files}
%doc README.rst
%license LICENSE
%{python_sitelib} /mocket
%{python_sitelib} /mocket-%{version} .dist-info
%endif
%changelog