14
0
forked from pool/python-ws4py

Accepting request 693231 from home:mcalabkova:branches:devel:languages:python

- update to version 0.5.1
  * fixed runtime error: Set changed size during iteration
  * on secure, only pass the requested number of bytes to the parsers
  * Change threaded client test to test ssl socket
  * exclude certain headers when requested
  * Disable build for Python 3.4
- launch tests using multibuild
- added patch ws4py-no-cherrypy-test.patch to enable tests also on
  Python2.7 (since CherryPy does not exist for Python2)

OBS-URL: https://build.opensuse.org/request/show/693231
OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-ws4py?expand=0&rev=5
This commit is contained in:
Tomáš Chvátal
2019-04-11 13:08:15 +00:00
committed by Git OBS Bridge
parent 6d83ef074f
commit 4058aa1d21
6 changed files with 156 additions and 13 deletions

3
_multibuild Normal file
View File

@@ -0,0 +1,3 @@
<multibuild>
<package>test</package>
</multibuild>

View File

@@ -1,3 +1,16 @@
-------------------------------------------------------------------
Thu Apr 11 12:09:24 UTC 2019 - Marketa Calabkova <mcalabkova@suse.com>
- update to version 0.5.1
* fixed runtime error: Set changed size during iteration
* on secure, only pass the requested number of bytes to the parsers
* Change threaded client test to test ssl socket
* exclude certain headers when requested
* Disable build for Python 3.4
- launch tests using multibuild
- added patch ws4py-no-cherrypy-test.patch to enable tests also on
Python2.7 (since CherryPy does not exist for Python2)
-------------------------------------------------------------------
Tue Dec 4 12:56:13 UTC 2018 - Matej Cepl <mcepl@suse.com>

View File

@@ -1,7 +1,7 @@
#
# spec file for package python-ws4py
#
# Copyright (c) 2018 SUSE LINUX GmbH, Nuernberg, Germany.
# Copyright (c) 2019 SUSE LINUX GmbH, Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
@@ -17,26 +17,35 @@
%{?!python_module:%define python_module() python-%{**} python3-%{**}}
%bcond_without test
Name: python-ws4py
Version: 0.4.2
%global flavor @BUILD_FLAVOR@%{nil}
%if "%{flavor}" == "test"
%define psuffix -test
%bcond_without test
%else
%define psuffix %{nil}
%bcond_with test
%endif
Name: python-ws4py%{psuffix}
Version: 0.5.1
Release: 0
Summary: WebSocket client and server library for Python
License: BSD-2-Clause
Group: Development/Languages/Python
Url: https://github.com/Lawouach/WebSocket-for-Python
URL: https://github.com/Lawouach/WebSocket-for-Python
Source: https://files.pythonhosted.org/packages/source/w/ws4py/ws4py-%{version}.tar.gz
Patch0: ws4py-no-cherrypy-test.patch
BuildRequires: %{python_module setuptools}
BuildRequires: fdupes
BuildRequires: python-rpm-macros
BuildArch: noarch
%if %{with test}
BuildRequires: %{python_module CherryPy}
BuildRequires: %{python_module gevent}
BuildRequires: %{python_module greenlet}
BuildRequires: %{python_module mock}
BuildRequires: %{python_module pytest}
BuildRequires: %{python_module tornado}
BuildRequires: %{python_module ws4py = %{version}}
%endif
BuildArch: noarch
%python_subpackages
%description
@@ -45,21 +54,28 @@ defined in RFC 6455.
%prep
%setup -q -n ws4py-%{version}
%patch0 -p1
%build
%python_build
%install
%if !%{with test}
%python_install
%python_expand %fdupes %{buildroot}%{$python_sitelib}
%endif
%if %{with test}
%check
%python_exec setup.py test
py.test -v
python2.7 -m pytest -v
%endif
%if !%{with test}
%files %{python_files}
%defattr(-,root,root,-)
%license LICENSE
%doc README.md
%{python_sitelib}/*
%endif
%changelog

View File

@@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:7ac69ce3e6ec6917a5d678b65f0a18e244a4dc670db6414bc0271b3f4911237f
size 40849

3
ws4py-0.5.1.tar.gz Normal file
View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:29d073d7f2e006373e6a848b1d00951a1107eb81f3742952be905429dc5a5483
size 51408

View File

@@ -0,0 +1,111 @@
Index: ws4py-0.5.1/test/test_cherrypy.py
===================================================================
--- ws4py-0.5.1.orig/test/test_cherrypy.py
+++ /dev/null
@@ -1,106 +0,0 @@
-# -*- coding: utf-8 -*-
-import os
-import socket
-import time
-import unittest
-
-from mock import MagicMock, call
-
-import cherrypy
-from ws4py.server.cherrypyserver import WebSocketPlugin, WebSocketTool
-from ws4py.websocket import EchoWebSocket
-from ws4py.framing import Frame, OPCODE_TEXT, OPCODE_CLOSE
-
-class FakePoller(object):
- def __init__(self, timeout=0.1):
- self._fds = []
-
- def release(self):
- self._fds = []
-
- def register(self, fd):
- if fd not in self._fds:
- self._fds.append(fd)
-
- def unregister(self, fd):
- if fd in self._fds:
- self._fds.remove(fd)
-
- def poll(self):
- return self._fds
-
-class App(object):
- @cherrypy.expose
- def ws(self):
- assert cherrypy.request.ws_handler != None
-
-def setup_engine():
- # we don't need a HTTP server for this test
- cherrypy.server.unsubscribe()
-
- cherrypy.config.update({'log.screen': False})
-
- cherrypy.engine.websocket = WebSocketPlugin(cherrypy.engine)
- cherrypy.engine.websocket.subscribe()
-
- cherrypy.engine.websocket.manager.poller = FakePoller()
-
- cherrypy.tools.websocket = WebSocketTool()
-
- config={'/ws': {'tools.websocket.on': True,
- 'tools.websocket.handler_cls': EchoWebSocket}}
- cherrypy.tree.mount(App(), '/', config)
- cherrypy.engine.start()
-
-def teardown_engine():
- cherrypy.engine.exit()
-
-class CherryPyTest(unittest.TestCase):
- def setUp(self):
- setup_engine()
-
- def tearDown(self):
- teardown_engine()
-
- def test_plugin(self):
- manager = cherrypy.engine.websocket.manager
- self.assertEqual(len(manager), 0)
-
- s = MagicMock(spec=socket.socket)
- s.recv.return_value = Frame(opcode=OPCODE_TEXT, body=b'hello',
- fin=1, masking_key=os.urandom(4)).build()
- h = EchoWebSocket(s, [], [])
- cherrypy.engine.publish('handle-websocket', h, ('127.0.0.1', 0))
- self.assertEqual(len(manager), 1)
- self.assertTrue(h in manager)
-
- # the following call to .close() on the
- # websocket object will initiate
- # the closing handshake
- # This next line mocks the response
- # from the client to actually
- # complete the handshake.
- # The manager will then remove the websocket
- # from its pool
- s.recv.return_value = Frame(opcode=OPCODE_CLOSE, body=b"ok we're done",
- fin=1, masking_key=os.urandom(4)).build()
- h.close()
-
- # the poller runs a thread, give it time to get there
- # just wait up to 5 seconds.
- left_iteration = 50
- while left_iteration:
- left_iteration -= 1
- time.sleep(.1)
- if len(manager) == 0:
- break
-
- self.assertEqual(len(manager), 0)
-
-if __name__ == '__main__':
- suite = unittest.TestSuite()
- loader = unittest.TestLoader()
- for testcase in [CherryPyTest]:
- tests = loader.loadTestsFromTestCase(testcase)
- suite.addTests(tests)
- unittest.TextTestRunner(verbosity=2).run(suite)