diff options
| -rw-r--r-- | .gitignore | 1 | ||||
| -rw-r--r-- | python-automock.spec | 144 | ||||
| -rw-r--r-- | sources | 1 |
3 files changed, 146 insertions, 0 deletions
@@ -0,0 +1 @@ +/automock-1.2.1.tar.gz diff --git a/python-automock.spec b/python-automock.spec new file mode 100644 index 0000000..6bc4a34 --- /dev/null +++ b/python-automock.spec @@ -0,0 +1,144 @@ +%global _empty_manifest_terminate_build 0 +Name: python-automock +Version: 1.2.1 +Release: 1 +Summary: Utility to allow some functions to be 'mocked by default' when running tests. +License: Apache 2.0 +URL: https://github.com/depop/python-automock +Source0: https://mirrors.nju.edu.cn/pypi/web/packages/df/5f/0509d70838722ebd315c9a6d5381b34c3fd3d477458c7b599e851f719f03/automock-1.2.1.tar.gz +BuildArch: noarch + + +%description +|PyPI Version| |Build Status| +There are some things that need to be mocked in unit tests. +For example: API clients for other backend services - we don't want to run an +instance of the other service just for our unit tests. The other service will +have its own tests and we only want to test that our code confiorms to the API +contract of the other service. Similarly for 3rd party services - we don't want +our unit tests to connect out over the internet to talk to the 3rd party service +(even if they offer a 'sandbox' test environment) for the same reasons as above, +and because this is a recipe for flaky tests. +(There is certainly a role for integration tests which do make live calls to +other services, but the bulk of tests won't be this kind and need mocking). +Python has the excellent `mock <http://www.voidspace.org.uk/python/mock/>`_ library to help with this. +However, say you have six API clients for backend services which are used +extensively in many places in code for your mobile app backend. You're going to +end up with a big 'stack' of patch decorators on many tests, e.g.: + @mock.patch('services.users.client.get_user', return_value=MockUser(id=1)) + @mock.patch('services.products.client.get_product', return_value=MockProduct(id=1)) + @mock.patch('services.paypal.client.make_payment', return_value=PaypalResult('success')) + def test_some_web_view(self, *mocks) +Say you have thousands of unit tests, these decorators need applying to many of +them. Every time you write a new test you'll need to remember to patch things. +Enter ``automock``. +Basically we want some functions to be 'mocked by default' when running tests. +But we also need to be able to easily replace the default mocks in some cases, +where the test needs a specific return value. ``automock`` makes this easy-ish. + +%package -n python3-automock +Summary: Utility to allow some functions to be 'mocked by default' when running tests. +Provides: python-automock +BuildRequires: python3-devel +BuildRequires: python3-setuptools +BuildRequires: python3-pip +%description -n python3-automock +|PyPI Version| |Build Status| +There are some things that need to be mocked in unit tests. +For example: API clients for other backend services - we don't want to run an +instance of the other service just for our unit tests. The other service will +have its own tests and we only want to test that our code confiorms to the API +contract of the other service. Similarly for 3rd party services - we don't want +our unit tests to connect out over the internet to talk to the 3rd party service +(even if they offer a 'sandbox' test environment) for the same reasons as above, +and because this is a recipe for flaky tests. +(There is certainly a role for integration tests which do make live calls to +other services, but the bulk of tests won't be this kind and need mocking). +Python has the excellent `mock <http://www.voidspace.org.uk/python/mock/>`_ library to help with this. +However, say you have six API clients for backend services which are used +extensively in many places in code for your mobile app backend. You're going to +end up with a big 'stack' of patch decorators on many tests, e.g.: + @mock.patch('services.users.client.get_user', return_value=MockUser(id=1)) + @mock.patch('services.products.client.get_product', return_value=MockProduct(id=1)) + @mock.patch('services.paypal.client.make_payment', return_value=PaypalResult('success')) + def test_some_web_view(self, *mocks) +Say you have thousands of unit tests, these decorators need applying to many of +them. Every time you write a new test you'll need to remember to patch things. +Enter ``automock``. +Basically we want some functions to be 'mocked by default' when running tests. +But we also need to be able to easily replace the default mocks in some cases, +where the test needs a specific return value. ``automock`` makes this easy-ish. + +%package help +Summary: Development documents and examples for automock +Provides: python3-automock-doc +%description help +|PyPI Version| |Build Status| +There are some things that need to be mocked in unit tests. +For example: API clients for other backend services - we don't want to run an +instance of the other service just for our unit tests. The other service will +have its own tests and we only want to test that our code confiorms to the API +contract of the other service. Similarly for 3rd party services - we don't want +our unit tests to connect out over the internet to talk to the 3rd party service +(even if they offer a 'sandbox' test environment) for the same reasons as above, +and because this is a recipe for flaky tests. +(There is certainly a role for integration tests which do make live calls to +other services, but the bulk of tests won't be this kind and need mocking). +Python has the excellent `mock <http://www.voidspace.org.uk/python/mock/>`_ library to help with this. +However, say you have six API clients for backend services which are used +extensively in many places in code for your mobile app backend. You're going to +end up with a big 'stack' of patch decorators on many tests, e.g.: + @mock.patch('services.users.client.get_user', return_value=MockUser(id=1)) + @mock.patch('services.products.client.get_product', return_value=MockProduct(id=1)) + @mock.patch('services.paypal.client.make_payment', return_value=PaypalResult('success')) + def test_some_web_view(self, *mocks) +Say you have thousands of unit tests, these decorators need applying to many of +them. Every time you write a new test you'll need to remember to patch things. +Enter ``automock``. +Basically we want some functions to be 'mocked by default' when running tests. +But we also need to be able to easily replace the default mocks in some cases, +where the test needs a specific return value. ``automock`` makes this easy-ish. + +%prep +%autosetup -n automock-1.2.1 + +%build +%py3_build + +%install +%py3_install +install -d -m755 %{buildroot}/%{_pkgdocdir} +if [ -d doc ]; then cp -arf doc %{buildroot}/%{_pkgdocdir}; fi +if [ -d docs ]; then cp -arf docs %{buildroot}/%{_pkgdocdir}; fi +if [ -d example ]; then cp -arf example %{buildroot}/%{_pkgdocdir}; fi +if [ -d examples ]; then cp -arf examples %{buildroot}/%{_pkgdocdir}; fi +pushd %{buildroot} +if [ -d usr/lib ]; then + find usr/lib -type f -printf "/%h/%f\n" >> filelist.lst +fi +if [ -d usr/lib64 ]; then + find usr/lib64 -type f -printf "/%h/%f\n" >> filelist.lst +fi +if [ -d usr/bin ]; then + find usr/bin -type f -printf "/%h/%f\n" >> filelist.lst +fi +if [ -d usr/sbin ]; then + find usr/sbin -type f -printf "/%h/%f\n" >> filelist.lst +fi +touch doclist.lst +if [ -d usr/share/man ]; then + find usr/share/man -type f -printf "/%h/%f.gz\n" >> doclist.lst +fi +popd +mv %{buildroot}/filelist.lst . +mv %{buildroot}/doclist.lst . + +%files -n python3-automock -f filelist.lst +%dir %{python3_sitelib}/* + +%files help -f doclist.lst +%{_docdir}/* + +%changelog +* Thu May 18 2023 Python_Bot <Python_Bot@openeuler.org> - 1.2.1-1 +- Package Spec generated @@ -0,0 +1 @@ +d4a4d37d54aa117c9b027cb45b061857 automock-1.2.1.tar.gz |
