From 3763eb85e78900dce0e080d83f67899605b03548cc52f510e0684cb08e5f6bf6 Mon Sep 17 00:00:00 2001 From: Matej Cepl Date: Wed, 21 Jun 2023 21:31:43 +0000 Subject: [PATCH 1/2] Accepting request 1094484 from home:DocB:branches:devel:languages:python:flask - update to version 5.3.4 * For a full changelog see https://github.com/miguelgrinberg/Flask-SocketIO/blob/main/CHANGES.md OBS-URL: https://build.opensuse.org/request/show/1094484 OBS-URL: https://build.opensuse.org/package/show/devel:languages:python:flask/python-Flask-SocketIO?expand=0&rev=4 --- Flask-SocketIO-5.1.1.tar.gz | 3 -- Flask-SocketIO-5.3.4.tar.gz | 3 ++ python-Flask-SocketIO.changes | 6 ++++ python-Flask-SocketIO.spec | 5 ++-- test_socketio.py | 55 ++++++++++++++++++++++++++++++++--- 5 files changed, 63 insertions(+), 9 deletions(-) delete mode 100644 Flask-SocketIO-5.1.1.tar.gz create mode 100644 Flask-SocketIO-5.3.4.tar.gz diff --git a/Flask-SocketIO-5.1.1.tar.gz b/Flask-SocketIO-5.1.1.tar.gz deleted file mode 100644 index 35210b7..0000000 --- a/Flask-SocketIO-5.1.1.tar.gz +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:1efdaacc7a26e94f2b197a80079b1058f6aa644a6094c0a322349e2b9c41f6b1 -size 16132 diff --git a/Flask-SocketIO-5.3.4.tar.gz b/Flask-SocketIO-5.3.4.tar.gz new file mode 100644 index 0000000..fda8ba9 --- /dev/null +++ b/Flask-SocketIO-5.3.4.tar.gz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:1cbd379c9bf68ac37bcc4750d01708922fa6365d13a5447d3f8893792879410c +size 17109 diff --git a/python-Flask-SocketIO.changes b/python-Flask-SocketIO.changes index 77bd256..8281e77 100644 --- a/python-Flask-SocketIO.changes +++ b/python-Flask-SocketIO.changes @@ -1,3 +1,9 @@ +------------------------------------------------------------------- +Wed Jun 21 19:56:26 UTC 2023 - Axel Braun + +- update to version 5.3.4 + * For a full changelog see https://github.com/miguelgrinberg/Flask-SocketIO/blob/main/CHANGES.md + ------------------------------------------------------------------- Sat Oct 23 15:18:45 UTC 2021 - Axel Braun diff --git a/python-Flask-SocketIO.spec b/python-Flask-SocketIO.spec index 561840c..c6a8fc1 100644 --- a/python-Flask-SocketIO.spec +++ b/python-Flask-SocketIO.spec @@ -1,7 +1,7 @@ # # spec file for package python-Flask-SocketIO # -# Copyright (c) 2021 SUSE LLC +# Copyright (c) 2023 SUSE LLC # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -19,7 +19,7 @@ %{?!python_module:%define python_module() python3-%{**}} %define skip_python2 1 Name: python-Flask-SocketIO -Version: 5.1.1 +Version: 5.3.4 Release: 0 License: MIT Summary: SocketIO integration for Flask applications @@ -29,6 +29,7 @@ Source: https://files.pythonhosted.org/packages/source/F/Flask-SocketIO/ Source1: https://raw.githubusercontent.com/miguelgrinberg/Flask-SocketIO/v%{version}/test_socketio.py BuildRequires: %{python_module Flask >= 0.9} BuildRequires: %{python_module python-socketio >= 5.0.2} +BuildRequires: %{python_module redis} BuildRequires: %{python_module setuptools} BuildRequires: fdupes Requires: python-Flask >= 0.9 diff --git a/test_socketio.py b/test_socketio.py index 7b0ba47..c9bd382 100644 --- a/test_socketio.py +++ b/test_socketio.py @@ -3,7 +3,7 @@ import unittest from flask import Flask, session, request, json as flask_json from flask_socketio import SocketIO, send, emit, join_room, leave_room, \ - Namespace, disconnect + Namespace, disconnect, ConnectionRefusedError app = Flask(__name__) app.config['SECRET_KEY'] = 'secret' @@ -16,11 +16,12 @@ def on_connect(auth): if auth != {'foo': 'bar'}: # pragma: no cover return False if request.args.get('fail'): - return False + raise ConnectionRefusedError('failed!') send('connected') send(json.dumps(request.args.to_dict(flat=False))) send(json.dumps({h: request.headers[h] for h in request.headers.keys() if h not in ['Host', 'Content-Type', 'Content-Length']})) + emit('dummy', to='nobody') @socketio.on('disconnect') @@ -47,7 +48,12 @@ def on_disconnect_test(): def message(message): send(message) if message == 'test session': - session['a'] = 'b' + if not socketio.manage_session and 'a' in session: + raise RuntimeError('session is being stored') + if 'a' not in session: + session['a'] = 'b' + else: + session['a'] = 'c' if message not in "test noackargs": return message @@ -345,6 +351,25 @@ class TestSocketIO(unittest.TestCase): client.disconnect('/test') self.assertEqual(disconnected, '/test') + def test_message_queue_options(self): + app = Flask(__name__) + socketio = SocketIO(app, message_queue='redis://') + self.assertFalse(socketio.server_options['client_manager'].write_only) + + app = Flask(__name__) + socketio = SocketIO(app) + socketio.init_app(app, message_queue='redis://') + self.assertFalse(socketio.server_options['client_manager'].write_only) + + app = Flask(__name__) + socketio = SocketIO(message_queue='redis://') + self.assertTrue(socketio.server_options['client_manager'].write_only) + + app = Flask(__name__) + socketio = SocketIO() + socketio.init_app(None, message_queue='redis://') + self.assertTrue(socketio.server_options['client_manager'].write_only) + def test_send(self): client = socketio.test_client(app, auth={'foo': 'bar'}) client.get_received() @@ -454,7 +479,7 @@ class TestSocketIO(unittest.TestCase): self.assertEqual(received[0]['args'][0]['a'], 'b') self.assertEqual(len(client3.get_received()), 0) - def test_session(self): + def test_managed_session(self): flask_client = app.test_client() flask_client.get('/session') client = socketio.test_client(app, flask_test_client=flask_client, @@ -468,6 +493,21 @@ class TestSocketIO(unittest.TestCase): self.assertEqual( socketio.server.environ[client.eio_sid]['saved_session'], {'a': 'b', 'foo': 'bar'}) + client.send('test session') + self.assertEqual( + socketio.server.environ[client.eio_sid]['saved_session'], + {'a': 'c', 'foo': 'bar'}) + + def test_unmanaged_session(self): + socketio.manage_session = False + flask_client = app.test_client() + flask_client.get('/session') + client = socketio.test_client(app, flask_test_client=flask_client, + auth={'foo': 'bar'}) + client.get_received() + client.send('test session') + client.send('test session') + socketio.manage_session = True def test_room(self): client1 = socketio.test_client(app, auth={'foo': 'bar'}) @@ -647,11 +687,18 @@ class TestSocketIO(unittest.TestCase): def test_server_disconnected(self): client = socketio.test_client(app, namespace='/ns') + client2 = socketio.test_client(app, namespace='/ns') client.get_received('/ns') + client2.get_received('/ns') client.emit('exit', {}, namespace='/ns') self.assertFalse(client.is_connected('/ns')) + self.assertTrue(client2.is_connected('/ns')) with self.assertRaises(RuntimeError): client.emit('hello', {}, namespace='/ns') + client2.emit('exit', {}, namespace='/ns') + self.assertFalse(client2.is_connected('/ns')) + with self.assertRaises(RuntimeError): + client2.emit('hello', {}, namespace='/ns') def test_emit_class_based(self): client = socketio.test_client(app, namespace='/ns') From 27c738c87e27719d587e4c6ad861a0fc47e700b8efc8e54d582cf399c3bf812c Mon Sep 17 00:00:00 2001 From: Matej Cepl Date: Wed, 21 Jun 2023 21:36:12 +0000 Subject: [PATCH 2/2] - Clean up SPEC file, make rpmlint happy. OBS-URL: https://build.opensuse.org/package/show/devel:languages:python:flask/python-Flask-SocketIO?expand=0&rev=5 --- python-Flask-SocketIO.changes | 5 +++++ python-Flask-SocketIO.spec | 20 ++++++++++---------- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/python-Flask-SocketIO.changes b/python-Flask-SocketIO.changes index 8281e77..5593011 100644 --- a/python-Flask-SocketIO.changes +++ b/python-Flask-SocketIO.changes @@ -1,3 +1,8 @@ +------------------------------------------------------------------- +Wed Jun 21 21:36:05 UTC 2023 - Matej Cepl + +- Clean up SPEC file, make rpmlint happy. + ------------------------------------------------------------------- Wed Jun 21 19:56:26 UTC 2023 - Axel Braun diff --git a/python-Flask-SocketIO.spec b/python-Flask-SocketIO.spec index c6a8fc1..ba2dd2a 100644 --- a/python-Flask-SocketIO.spec +++ b/python-Flask-SocketIO.spec @@ -16,25 +16,24 @@ # -%{?!python_module:%define python_module() python3-%{**}} %define skip_python2 1 Name: python-Flask-SocketIO Version: 5.3.4 Release: 0 -License: MIT Summary: SocketIO integration for Flask applications -URL: http://github.com/miguelgrinberg/Flask-SocketIO/ +License: MIT Group: Development/Languages/Python +URL: https://github.com/miguelgrinberg/Flask-SocketIO/ Source: https://files.pythonhosted.org/packages/source/F/Flask-SocketIO/Flask-SocketIO-%{version}.tar.gz Source1: https://raw.githubusercontent.com/miguelgrinberg/Flask-SocketIO/v%{version}/test_socketio.py BuildRequires: %{python_module Flask >= 0.9} +BuildRequires: %{python_module pip} BuildRequires: %{python_module python-socketio >= 5.0.2} BuildRequires: %{python_module redis} -BuildRequires: %{python_module setuptools} +BuildRequires: %{python_module wheel} BuildRequires: fdupes Requires: python-Flask >= 0.9 Requires: python-python-socketio >= 5.0.2 - BuildArch: noarch %python_subpackages @@ -43,21 +42,22 @@ Socket.IO integration for Flask applications. %prep %setup -q -n Flask-SocketIO-%{version} -cp %{S:1} . +cp %{SOURCE1} . %build -%python_build +%pyproject_wheel %install -%python_install +%pyproject_install %python_expand %fdupes %{buildroot}%{$python_sitelib} %check %pyunittest -v test_socketio.py -%files %{python_files} +%files %{python_files} %doc README.md %license LICENSE -%{python_sitelib}/* +%{python_sitelib}/flask_socketio +%{python_sitelib}/Flask_SocketIO-%{version}*-info %changelog