Skip to content
This repository has been archived by the owner on Aug 15, 2019. It is now read-only.

Commit

Permalink
Add python-ws4py package
Browse files Browse the repository at this point in the history
  • Loading branch information
ganto committed Dec 17, 2016
1 parent fc97cd5 commit 86badaa
Show file tree
Hide file tree
Showing 3 changed files with 202 additions and 0 deletions.
67 changes: 67 additions & 0 deletions python-ws4py/0001-Fix-tests.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
From a7d5ce7c1e8d39c2e68eeb6ef5bab72b3981dc37 Mon Sep 17 00:00:00 2001
From: Stein Magnus Jodal <[email protected]>
Date: Thu, 5 Nov 2015 15:46:08 +0100
Subject: Fix tests

Based on upstream commits:
- b5d47f7b3497f1b713a20fe6306b7d9afdd8c408
- b2a76a33960040d7d3d27c68bf17c12f169f81c7
---
test/test_manager.py | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/test/test_manager.py b/test/test_manager.py
index 8c229b0..da57d44 100644
--- a/test/test_manager.py
+++ b/test/test_manager.py
@@ -16,10 +16,10 @@ class WSManagerTest(unittest.TestCase):
ws.sock.fileno.return_value = 1

m.add(ws)
- m.poller.register.assert_call_once_with(ws)
+ m.poller.register.assert_called_once_with(1)

m.remove(ws)
- m.poller.unregister.assert_call_once_with(ws)
+ m.poller.unregister.assert_called_once_with(1)

@patch('ws4py.manager.SelectPoller')
def test_cannot_add_websocket_more_than_once(self, MockSelectPoller):
@@ -49,7 +49,7 @@ class WSManagerTest(unittest.TestCase):
self.assertEqual(len(m), 1)
m.remove(ws)
self.assertEqual(len(m), 0)
- m.poller.unregister.assert_call_once_with(ws)
+ m.poller.unregister.assert_called_once_with(1)
m.poller.reset_mock()

m.remove(ws)
@@ -97,8 +97,9 @@ class WSManagerTest(unittest.TestCase):

m.add(ws)
m.start()
+ time.sleep(0.2)

- ws.terminate.assert_call_once_with()
+ ws.terminate.assert_called_once_with()

m.stop()

@@ -109,7 +110,7 @@ class WSManagerTest(unittest.TestCase):
ws = MagicMock()
m.add(ws)
m.close_all()
- ws.terminate.assert_call_once_with(1001, 'Server is shutting down')
+ ws.close.assert_called_once_with(code=1001, reason='Server is shutting down')

@patch('ws4py.manager.SelectPoller')
def test_broadcast(self, MockSelectPoller):
@@ -120,7 +121,7 @@ class WSManagerTest(unittest.TestCase):
m.add(ws)

m.broadcast(b'hello there')
- ws.send.assert_call_once_with(b'hello there')
+ ws.send.assert_called_once_with(b'hello there', False)

@patch('ws4py.manager.SelectPoller')
def test_broadcast_failure_must_not_break_caller(self, MockSelectPoller):
1 change: 1 addition & 0 deletions python-ws4py/WebSocket-for-Python-v0.3.4.tar.gz
134 changes: 134 additions & 0 deletions python-ws4py/python-ws4py.spec
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
%global srcname ws4py
%global gh_owner Lawouach
%global gh_name WebSocket-for-Python

%if 0%{?rhel} && 0%{?rhel} <= 7
%bcond_with python3
%else
%bcond_without python3
%endif

Name: python-%{srcname}
Version: 0.3.4
Release: 1%{?dist}
Summary: WebSocket client and server library for Python
License: BSD
URL: https://pypi.python.org/pypi/%{srcname}
Source0: https://github.com/%{gh_owner}/%{gh_name}/archive/v%{version}/%{gh_name}-v%{version}.tar.gz
Patch0: 0001-Fix-tests.patch
BuildArch: noarch

%description
%{summary}

%package -n python2-%{srcname}
Summary: WebSocket client and server library for Python 2.x
%{?python_provide:%python_provide python2-%{srcname}}
BuildRequires: python-cherrypy
BuildRequires: python2-devel
BuildRequires: python2-gevent
BuildRequires: python2-mock
BuildRequires: python2-nose
BuildRequires: python2-setuptools
BuildRequires: python2-tornado

%if 0%{?fedora}
Suggests: python-cherrypy
Suggests: python2-gevent
Suggests: python2-tornado
%endif

%description -n python2-%{srcname}
Python library providing an implementation of the
WebSocket protocol defined in RFC 6455.

Python 2 version.

%if %{with python3}
%package -n python3-%{srcname}
Summary: WebSocket client and server library for Python 3.x
%{?python_provide:%python_provide python3-%{srcname}}
BuildRequires: python3-cherrypy
BuildRequires: python3-devel
BuildRequires: python3-gevent
BuildRequires: python3-mock
BuildRequires: python3-nose
BuildRequires: python3-setuptools
BuildRequires: python3-tornado

%if 0%{?fedora}
Suggests: python3-cherrypy
Suggests: python3-gevent
Suggests: python3-tornado
%endif

%description -n python3-%{srcname}
Python library providing an implementation of the
WebSocket protocol defined in RFC 6455.

Python 3 version.
%endif

%prep
# There are some modules which are specific to Python 3. Therefore we
# must use two different build directories.
%if %{with python3}
%setup -q -T -a 0 -c -n python3-%{srcname}
pushd %{gh_name}-%{version}
# Obviously the patches also have to be applied individually
%patch0 -p1
popd
cd ..
%endif
%setup -q -T -a 0 -c -n python2-%{srcname}
pushd %{gh_name}-%{version}
%patch0 -p1
popd

%build
pushd %{gh_name}-%{version}
%{__python2} setup.py build
popd
%if %{with python3}
pushd ../python3-%{srcname}/%{gh_name}-%{version}
%{__python3} setup.py build
popd
%endif

%install
pushd %{gh_name}-%{version}
%py2_install
popd
%if %{with python3}
pushd ../python3-%{srcname}/%{gh_name}-%{version}
%py3_install
popd
%endif

%check
pushd %{gh_name}-%{version}
nosetests-2
popd
%if %{with python3}
pushd ../python3-%{srcname}/%{gh_name}-%{version}
nosetests-3
popd
%endif

%files -n python2-%{srcname}
%doc %{gh_name}-%{version}/README.md
%license %{gh_name}-%{version}/LICENSE
%{python2_sitelib}/%{srcname}-%{version}-py%{python2_version}.egg-info
%{python2_sitelib}/%{srcname}

%if %{with python3}
%files -n python3-%{srcname}
%doc %{gh_name}-%{version}/README.md
%license %{gh_name}-%{version}/LICENSE
%{python3_sitelib}/%{srcname}-%{version}-py%{python3_version}.egg-info
%{python3_sitelib}/%{srcname}
%endif

%changelog
* Sat Dec 17 2016 Reto Gantenbein <[email protected]> - 0.3.4-1
- Initial packaging

0 comments on commit 86badaa

Please sign in to comment.