From 07789a23e9c513dba87b020fae2989a57955e8a6 Mon Sep 17 00:00:00 2001 From: Andrei Zeliankou Date: Sun, 6 Dec 2020 16:01:59 +0000 Subject: Tests: options moved to the separate class. This change is necessary to separate the logic and prevent possible circular dependency. --- test/test_asgi_websockets.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'test/test_asgi_websockets.py') diff --git a/test/test_asgi_websockets.py b/test/test_asgi_websockets.py index 54984526..766e53ed 100644 --- a/test/test_asgi_websockets.py +++ b/test/test_asgi_websockets.py @@ -4,10 +4,10 @@ from distutils.version import LooseVersion import pytest -from conftest import option from conftest import skip_alert from unit.applications.lang.python import TestApplicationPython from unit.applications.websockets import TestApplicationWebsocket +from unit.option import option class TestASGIWebsockets(TestApplicationPython): -- cgit From b2e767819f04153944d525ef8d97d2f3a7a9af74 Mon Sep 17 00:00:00 2001 From: Andrei Zeliankou Date: Tue, 8 Dec 2020 14:37:33 +0000 Subject: Tests: skip_alert() converted to the fixture. --- test/test_asgi_websockets.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'test/test_asgi_websockets.py') diff --git a/test/test_asgi_websockets.py b/test/test_asgi_websockets.py index 766e53ed..76cd8e80 100644 --- a/test/test_asgi_websockets.py +++ b/test/test_asgi_websockets.py @@ -4,7 +4,6 @@ from distutils.version import LooseVersion import pytest -from conftest import skip_alert from unit.applications.lang.python import TestApplicationPython from unit.applications.websockets import TestApplicationWebsocket from unit.option import option @@ -17,7 +16,8 @@ class TestASGIWebsockets(TestApplicationPython): ws = TestApplicationWebsocket() - def setup_method(self): + @pytest.fixture(autouse=True) + def setup_method_fixture(self, request, skip_alert): assert 'success' in self.conf( {'http': {'websocket': {'keepalive_interval': 0}}}, 'settings' ), 'clear keepalive_interval' -- cgit From 6dc9c47ccd26b23b61b7522803a667c2e515e260 Mon Sep 17 00:00:00 2001 From: Andrei Zeliankou Date: Wed, 13 Jan 2021 06:22:43 +0000 Subject: Tests: style. --- test/test_asgi_websockets.py | 1 - 1 file changed, 1 deletion(-) (limited to 'test/test_asgi_websockets.py') diff --git a/test/test_asgi_websockets.py b/test/test_asgi_websockets.py index 76cd8e80..7c9ec555 100644 --- a/test/test_asgi_websockets.py +++ b/test/test_asgi_websockets.py @@ -3,7 +3,6 @@ import time from distutils.version import LooseVersion import pytest - from unit.applications.lang.python import TestApplicationPython from unit.applications.websockets import TestApplicationWebsocket from unit.option import option -- cgit From e4e444b82701de0c984a72eb9c2657f72d7171ae Mon Sep 17 00:00:00 2001 From: Max Romanov Date: Thu, 28 Jan 2021 17:13:52 +0300 Subject: Router: fixing crash after WebSocket processing. After WebSocket processing, the application port was released with incorrect reason ("got request"), unnecessarily decrementing the active request counter. The assertion was triggered only on application removal; a test was added for this case. --- test/test_asgi_websockets.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'test/test_asgi_websockets.py') diff --git a/test/test_asgi_websockets.py b/test/test_asgi_websockets.py index 7c9ec555..6121fcc5 100644 --- a/test/test_asgi_websockets.py +++ b/test/test_asgi_websockets.py @@ -63,6 +63,9 @@ class TestASGIWebsockets(TestApplicationPython): key ), 'key' + # remove "mirror" application + self.load('websockets/subprotocol') + def test_asgi_websockets_subprotocol(self): self.load('websockets/subprotocol') @@ -92,6 +95,27 @@ class TestASGIWebsockets(TestApplicationPython): sock.close() + def test_asgi_websockets_mirror_app_change(self): + self.load('websockets/mirror') + + message = 'blah' + + _, sock, _ = self.ws.upgrade() + + self.ws.frame_write(sock, self.ws.OP_TEXT, message) + frame = self.ws.frame_read(sock) + + assert message == frame['data'].decode('utf-8'), 'mirror' + + self.load('websockets/subprotocol') + + self.ws.frame_write(sock, self.ws.OP_TEXT, message) + frame = self.ws.frame_read(sock) + + assert message == frame['data'].decode('utf-8'), 'mirror 2' + + sock.close() + def test_asgi_websockets_no_mask(self): self.load('websockets/mirror') -- cgit