#1 Run the tests in %check
Merged 3 years ago by churchyard. Opened 3 years ago by churchyard.
rpms/ churchyard/python-aiohttp-cors check  into  master

@@ -0,0 +1,23 @@ 

+ From e64b95848f3253157d831f4934841fceeaf9b2e3 Mon Sep 17 00:00:00 2001

+ From: =?UTF-8?q?Miro=20Hron=C4=8Dok?= <miro@hroncok.cz>

+ Date: Thu, 14 Nov 2019 12:54:47 +0100

+ Subject: [PATCH] Test instance type by isinstance, not issubclass

+ 

+ Fixes https://github.com/aio-libs/aiohttp-cors/issues/277

+ ---

+  tests/unit/test_cors_config.py | 2 +-

+  1 file changed, 1 insertion(+), 1 deletion(-)

+ 

+ diff --git a/tests/unit/test_cors_config.py b/tests/unit/test_cors_config.py

+ index 817410e..d494e20 100644

+ --- a/tests/unit/test_cors_config.py

+ +++ b/tests/unit/test_cors_config.py

+ @@ -103,7 +103,7 @@ def test_static_resource(app, cors):

+          "/file", "/", name="dynamic_named_route")

+      assert len(app.router.keys()) == 1

+      for resource in list(app.router.resources()):

+ -        if issubclass(resource, web.StaticResource):

+ +        if isinstance(resource, web.StaticResource):

+              cors.add(resource)

+      assert len(app.router.keys()) == 1

+  

@@ -0,0 +1,63 @@ 

+ From eb4f5a4bb28f8260d4edc32969e838d9abace051 Mon Sep 17 00:00:00 2001

+ From: Andrew Svetlov <andrew.svetlov@gmail.com>

+ Date: Mon, 15 Oct 2018 21:32:48 +0300

+ Subject: [PATCH] Fix tests

+ 

+ ---

+  tests/integration/test_real_browser.py | 18 ++++++++----------

+  tests/unit/test_cors_config.py         |  5 ++---

+  2 files changed, 10 insertions(+), 13 deletions(-)

+ 

+ diff --git a/tests/integration/test_real_browser.py b/tests/integration/test_real_browser.py

+ index a5c9030..5dff79a 100644

+ --- a/tests/integration/test_real_browser.py

+ +++ b/tests/integration/test_real_browser.py

+ @@ -193,22 +193,20 @@ class ResourceView(web.View, CorsViewMixin):

+  

+          # Start servers.

+          for server_name, server_descr in self.servers.items():

+ -            handler = server_descr.app.make_handler()

+ -            server = await self.loop.create_server(

+ -                handler,

+ -                sock=server_sockets[server_name])

+ -            server_descr.handler = handler

+ -            server_descr.server = server

+ +            runner = web.AppRunner(server_descr.app)

+ +            await runner.setup()

+ +            site = web.SockSite(runner, server_sockets[server_name])

+ +            await site.start()

+ +            server_descr.runner = runner

+  

+              self._logger.info("Started server '%s' at '%s'",

+                                server_name, server_descr.url)

+  

+      async def stop_servers(self):

+          for server_descr in self.servers.values():

+ -            server_descr.server.close()

+ -            await server_descr.handler.shutdown()

+ -            await server_descr.server.wait_closed()

+ -            await server_descr.app.cleanup()

+ +            runner = server_descr.runner

+ +            await runner.shutdown()

+ +            await runner.cleanup()

+  

+          self.servers = {}

+  

+ diff --git a/tests/unit/test_cors_config.py b/tests/unit/test_cors_config.py

+ index 5b8d8f3..817410e 100644

+ --- a/tests/unit/test_cors_config.py

+ +++ b/tests/unit/test_cors_config.py

+ @@ -58,11 +58,10 @@ def options_route(app):

+          "OPTIONS", "/options_path", _handler)

+  

+  

+ -def test_add_options_route(cors, options_route):

+ +def test_add_options_route(app, cors, options_route):

+      """Test configuring OPTIONS route"""

+ -

+      with pytest.raises(ValueError,

+ -                       match="/options_path already has OPTIONS handler"):

+ +                       match="already has OPTIONS handler"):

+          cors.add(options_route.resource)

+  

+  

file modified
+43 -10
@@ -2,41 +2,72 @@ 

  %global common_desc aiohttp_cors library implements Cross Origin Resource Sharing (CORS) support \

  for aiohttp asyncio-powered asynchronous HTTP server.

  

- 

- 

  Name:           python-%{srcname}

  Version:        0.7.0

- Release:        7%{?dist}

+ Release:        8%{?dist}

  Summary:        CORS (Cross Origin Resource Sharing) support for aiohttp

  

  License:        ASL 2.0

  URL:            https://github.com/aio-libs/aiohttp-cors

- Source0:        https://github.com/aio-libs/aiohttp-cors/archive/v%{version}/%{name}-%{version}.tar.gz

+ Source0:        %{url}/archive/v%{version}/%{name}-%{version}.tar.gz

+ 

+ # Fix test failure of test_add_options_route

+ Patch1:         %{url}/commit/eb4f5a4bb28f8260d4edc32969e838d9abace051.patch

+ 

+ # Fix test failure of test_static_resource

+ Patch2:         %{url}/pull/278/commits/e64b95848f3253157d831f4934841fceeaf9b2e3.patch

  

  BuildArch:      noarch

  

  %description

  %{common_desc}

  

- # This module is Python 3 only

+ 

  %package -n python3-%{srcname}

  Summary:        %{summary}

  %{?python_provide:%python_provide python3-%{srcname}}

  BuildRequires: python3-devel

  BuildRequires: python3-setuptools

- Requires: python3-aiohttp >= 1.1

  

  # For tes suite

- BuildRequires: python3-pytest-runner

+ BuildRequires: python3-pytest

+ BuildRequires: python3-pytest-aiohttp

  BuildRequires: python3-aiohttp >= 1.1

  

+ # Browser tests not possible yet

+ # BuildRequires: python3-selenium

+ #

+ # ifarch on noarch?

+ # BuildRequires: chromium

+ # BuildRequires: chromedriver

+ # Chrome failed to start: exited abnormally

+ #     (unknown error: DevToolsActivePort file doesn't exist)

+ #

+ # BuildRequires: firefox

+ # BuildRequires: geckodriver -- not available

  

  %description -n python3-%{srcname}

  %{common_desc}

  

  

  %prep

- %autosetup -n %{srcname}-%{version}

+ %autosetup -n %{srcname}-%{version} -p1

+ 

+ # remove non-essential pytest plugins

+ sed -i '/pytest-cov/d' setup.py

+ sed -i '/pytest-pylint/d' setup.py

+ 

+ # Don't treat warnings as errors, that's what upstream testing is for

+ # In 0.7.0, nothing else is in this config

+ rm pytest.ini

+ 

+ # Don't add --cov options to pytest

+ # In 0.7.0, nothing else is in this config

+ rm setup.cfg

+ # tox.ini has this repeated, but we don't need it

+ rm tox.ini

+ 

+ sed -i s/issubclass/isinstance/ tests/unit/test_cors_config.py

Oh, this is a leftover from preparing one of the patches. It is now redundant. I'll verify in a mock build and push a removal if it builds without.

  

  %build

  %py3_build
@@ -45,8 +76,7 @@ 

  %py3_install

  

  %check

- # selenium and simple are not available in the repos

- #%{__python3} setup.py test

+ %{python3} -m pytest -v --ignore tests/integration/test_real_browser.py

  

  %files -n python3-%{srcname}

  %license LICENSE
@@ -55,6 +85,9 @@ 

  %{python3_sitelib}/aiohttp_cors-*.egg-info/

  

  %changelog

+ * Thu Nov 14 2019 Miro Hrončok <mhroncok@redhat.com> - 0.7.0-8

+ - Run the tests

+ 

  * Thu Oct 03 2019 Miro Hrončok <mhroncok@redhat.com> - 0.7.0-7

  - Rebuilt for Python 3.8.0rc1 (#1748018)