diff options
author | CoprDistGit <infra@openeuler.org> | 2023-03-09 17:27:19 +0000 |
---|---|---|
committer | CoprDistGit <infra@openeuler.org> | 2023-03-09 17:27:19 +0000 |
commit | 8109b7204e0369c390958fb046783e81b0677702 (patch) | |
tree | 56b0f1a0f373a8edf7fe38cd0e1b5d7f32aebc97 | |
parent | 47d8ef363cc9bfde95322e982f1b35f489fd5778 (diff) |
automatic import of python-test_server
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | python-test_server.spec | 246 | ||||
-rw-r--r-- | sources | 1 |
3 files changed, 248 insertions, 0 deletions
@@ -0,0 +1 @@ +/test_server-0.0.42.tar.gz diff --git a/python-test_server.spec b/python-test_server.spec new file mode 100644 index 0000000..f30b9d5 --- /dev/null +++ b/python-test_server.spec @@ -0,0 +1,246 @@ +%global _empty_manifest_terminate_build 0 +Name: python-test-server +Version: 0.0.42 +Release: 1 +Summary: Server for testing HTTP clients +License: The MIT License (MIT) Copyright (c) 2015-2023, Gregory Petukhov Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +URL: https://pypi.org/project/test-server/ +Source0: https://mirrors.nju.edu.cn/pypi/web/packages/23/dd/d8e2f93c19d18351235f9540ec7d8eec7559c0160db8c8007c01595dc90e/test_server-0.0.42.tar.gz +BuildArch: noarch + + +%description +# Documentation for test_server package + +[](https://github.com/lorien/test_server/actions/workflows/test.yml) +[](https://github.com/lorien/test_server/actions/workflows/test.yml) +[](https://github.com/lorien/test_server/actions/workflows/mypy.yml) +[](https://coveralls.io/github/lorien/test_server) +[](http://user-agent.readthedocs.org) + +Simple HTTP Server for testing HTTP clients. + + +## Installation + +Run `pip install -U test_server` + + +## Usage Example + +```python +from unittest import TestCase +import unittest +from urllib.request import urlopen + +from test_server import TestServer, Response, HttpHeaderStorage + + +class UrllibTestCase(TestCase): + @classmethod + def setUpClass(cls): + cls.server = TestServer() + cls.server.start() + + @classmethod + def tearDownClass(cls): + cls.server.stop() + + def setUp(self): + self.server.reset() + + def test_get(self): + self.server.add_response( + Response( + data=b"hello", + headers={"foo": "bar"}, + ) + ) + self.server.add_response(Response(data=b"zzz")) + url = self.server.get_url() + info = urlopen(url) + self.assertEqual(b"hello", info.read()) + self.assertEqual("bar", info.headers["foo"]) + info = urlopen(url) + self.assertEqual(b"zzz", info.read()) + self.assertTrue("bar" not in info.headers) + + + unittest.main() +``` + + +%package -n python3-test-server +Summary: Server for testing HTTP clients +Provides: python-test-server +BuildRequires: python3-devel +BuildRequires: python3-setuptools +BuildRequires: python3-pip +%description -n python3-test-server +# Documentation for test_server package + +[](https://github.com/lorien/test_server/actions/workflows/test.yml) +[](https://github.com/lorien/test_server/actions/workflows/test.yml) +[](https://github.com/lorien/test_server/actions/workflows/mypy.yml) +[](https://coveralls.io/github/lorien/test_server) +[](http://user-agent.readthedocs.org) + +Simple HTTP Server for testing HTTP clients. + + +## Installation + +Run `pip install -U test_server` + + +## Usage Example + +```python +from unittest import TestCase +import unittest +from urllib.request import urlopen + +from test_server import TestServer, Response, HttpHeaderStorage + + +class UrllibTestCase(TestCase): + @classmethod + def setUpClass(cls): + cls.server = TestServer() + cls.server.start() + + @classmethod + def tearDownClass(cls): + cls.server.stop() + + def setUp(self): + self.server.reset() + + def test_get(self): + self.server.add_response( + Response( + data=b"hello", + headers={"foo": "bar"}, + ) + ) + self.server.add_response(Response(data=b"zzz")) + url = self.server.get_url() + info = urlopen(url) + self.assertEqual(b"hello", info.read()) + self.assertEqual("bar", info.headers["foo"]) + info = urlopen(url) + self.assertEqual(b"zzz", info.read()) + self.assertTrue("bar" not in info.headers) + + + unittest.main() +``` + + +%package help +Summary: Development documents and examples for test-server +Provides: python3-test-server-doc +%description help +# Documentation for test_server package + +[](https://github.com/lorien/test_server/actions/workflows/test.yml) +[](https://github.com/lorien/test_server/actions/workflows/test.yml) +[](https://github.com/lorien/test_server/actions/workflows/mypy.yml) +[](https://coveralls.io/github/lorien/test_server) +[](http://user-agent.readthedocs.org) + +Simple HTTP Server for testing HTTP clients. + + +## Installation + +Run `pip install -U test_server` + + +## Usage Example + +```python +from unittest import TestCase +import unittest +from urllib.request import urlopen + +from test_server import TestServer, Response, HttpHeaderStorage + + +class UrllibTestCase(TestCase): + @classmethod + def setUpClass(cls): + cls.server = TestServer() + cls.server.start() + + @classmethod + def tearDownClass(cls): + cls.server.stop() + + def setUp(self): + self.server.reset() + + def test_get(self): + self.server.add_response( + Response( + data=b"hello", + headers={"foo": "bar"}, + ) + ) + self.server.add_response(Response(data=b"zzz")) + url = self.server.get_url() + info = urlopen(url) + self.assertEqual(b"hello", info.read()) + self.assertEqual("bar", info.headers["foo"]) + info = urlopen(url) + self.assertEqual(b"zzz", info.read()) + self.assertTrue("bar" not in info.headers) + + + unittest.main() +``` + + +%prep +%autosetup -n test-server-0.0.42 + +%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-test-server -f filelist.lst +%dir %{python3_sitelib}/* + +%files help -f doclist.lst +%{_docdir}/* + +%changelog +* Thu Mar 09 2023 Python_Bot <Python_Bot@openeuler.org> - 0.0.42-1 +- Package Spec generated @@ -0,0 +1 @@ +8b2b76d9d4f19049e79e35f03661e20a test_server-0.0.42.tar.gz |