Miguel Grinberg
4 months ago
Failed to extract signature
5 changed files with
55 additions and
3 deletions
-
tests/async/test_pubsub_manager.py
-
tests/async/test_redis_manager.py
-
tests/common/test_pubsub_manager.py
-
tests/common/test_redis_manager.py
-
tox.ini
|
|
@ -5,8 +5,10 @@ from unittest import mock |
|
|
|
|
|
|
|
|
import pytest |
|
|
import pytest |
|
|
|
|
|
|
|
|
|
|
|
from engineio.packet import Packet as EIOPacket |
|
|
from socketio import async_manager |
|
|
from socketio import async_manager |
|
|
from socketio import async_pubsub_manager |
|
|
from socketio import async_pubsub_manager |
|
|
|
|
|
from socketio import async_server |
|
|
from socketio import packet |
|
|
from socketio import packet |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -846,3 +848,14 @@ class TestAsyncPubSubManager: |
|
|
self.pm._handle_emit.assert_awaited_with( |
|
|
self.pm._handle_emit.assert_awaited_with( |
|
|
{'method': 'emit', 'value': 'bar', 'host_id': 'x'} |
|
|
{'method': 'emit', 'value': 'bar', 'host_id': 'x'} |
|
|
) |
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
def test_custom_json(self): |
|
|
|
|
|
saved_json = packet.Packet.json |
|
|
|
|
|
|
|
|
|
|
|
cm = async_pubsub_manager.AsyncPubSubManager(json='foo') |
|
|
|
|
|
assert cm.json == 'foo' |
|
|
|
|
|
async_server.AsyncServer(json='bar', client_manager=cm) |
|
|
|
|
|
assert cm.json == 'bar' |
|
|
|
|
|
|
|
|
|
|
|
packet.Packet.json = saved_json |
|
|
|
|
|
EIOPacket.json = saved_json |
|
|
|
|
|
@ -2,8 +2,10 @@ import pytest |
|
|
import redis |
|
|
import redis |
|
|
import valkey |
|
|
import valkey |
|
|
|
|
|
|
|
|
from socketio import async_redis_manager |
|
|
from engineio.packet import Packet as EIOPacket |
|
|
|
|
|
from socketio import async_redis_manager, AsyncServer |
|
|
from socketio.async_redis_manager import AsyncRedisManager |
|
|
from socketio.async_redis_manager import AsyncRedisManager |
|
|
|
|
|
from socketio.packet import Packet |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class TestAsyncRedisManager: |
|
|
class TestAsyncRedisManager: |
|
|
@ -109,3 +111,14 @@ class TestAsyncRedisManager: |
|
|
assert isinstance(c.redis, valkey.asyncio.Valkey) |
|
|
assert isinstance(c.redis, valkey.asyncio.Valkey) |
|
|
|
|
|
|
|
|
async_redis_manager.aioredis = saved_redis |
|
|
async_redis_manager.aioredis = saved_redis |
|
|
|
|
|
|
|
|
|
|
|
def test_custom_json(self): |
|
|
|
|
|
saved_json = Packet.json |
|
|
|
|
|
|
|
|
|
|
|
cm = AsyncRedisManager('redis://', json='foo') |
|
|
|
|
|
assert cm.json == 'foo' |
|
|
|
|
|
AsyncServer(json='bar', client_manager=cm) |
|
|
|
|
|
assert cm.json == 'bar' |
|
|
|
|
|
|
|
|
|
|
|
Packet.json = saved_json |
|
|
|
|
|
EIOPacket.json = saved_json |
|
|
|
|
|
@ -5,9 +5,11 @@ from unittest import mock |
|
|
|
|
|
|
|
|
import pytest |
|
|
import pytest |
|
|
|
|
|
|
|
|
|
|
|
from engineio.packet import Packet as EIOPacket |
|
|
from socketio import manager |
|
|
from socketio import manager |
|
|
from socketio import pubsub_manager |
|
|
from socketio import pubsub_manager |
|
|
from socketio import packet |
|
|
from socketio import packet |
|
|
|
|
|
from socketio import server |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class TestPubSubManager: |
|
|
class TestPubSubManager: |
|
|
@ -822,3 +824,14 @@ class TestPubSubManager: |
|
|
self.pm._handle_emit.assert_called_with( |
|
|
self.pm._handle_emit.assert_called_with( |
|
|
{'method': 'emit', 'value': 'bar', 'host_id': 'x'} |
|
|
{'method': 'emit', 'value': 'bar', 'host_id': 'x'} |
|
|
) |
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
def test_custom_json(self): |
|
|
|
|
|
saved_json = packet.Packet.json |
|
|
|
|
|
|
|
|
|
|
|
cm = pubsub_manager.PubSubManager(json='foo') |
|
|
|
|
|
assert cm.json == 'foo' |
|
|
|
|
|
server.Server(json='bar', client_manager=cm) |
|
|
|
|
|
assert cm.json == 'bar' |
|
|
|
|
|
|
|
|
|
|
|
packet.Packet.json = saved_json |
|
|
|
|
|
EIOPacket.json = saved_json |
|
|
|
|
|
@ -2,7 +2,9 @@ import pytest |
|
|
import redis |
|
|
import redis |
|
|
import valkey |
|
|
import valkey |
|
|
|
|
|
|
|
|
from socketio import redis_manager |
|
|
from engineio.packet import Packet as EIOPacket |
|
|
|
|
|
from socketio import redis_manager, Server |
|
|
|
|
|
from socketio.packet import Packet |
|
|
from socketio.redis_manager import RedisManager, parse_redis_sentinel_url |
|
|
from socketio.redis_manager import RedisManager, parse_redis_sentinel_url |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -144,3 +146,14 @@ class TestPubSubManager: |
|
|
'myredis', |
|
|
'myredis', |
|
|
{'username': 'user', 'password': 'password', 'db': 0} |
|
|
{'username': 'user', 'password': 'password', 'db': 0} |
|
|
) |
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
def test_custom_json(self): |
|
|
|
|
|
saved_json = Packet.json |
|
|
|
|
|
|
|
|
|
|
|
cm = RedisManager('redis://', json='foo') |
|
|
|
|
|
assert cm.json == 'foo' |
|
|
|
|
|
Server(json='bar', client_manager=cm) |
|
|
|
|
|
assert cm.json == 'bar' |
|
|
|
|
|
|
|
|
|
|
|
Packet.json = saved_json |
|
|
|
|
|
EIOPacket.json = saved_json |
|
|
|
|
|
@ -14,7 +14,7 @@ python = |
|
|
[testenv] |
|
|
[testenv] |
|
|
commands= |
|
|
commands= |
|
|
pip install -e . |
|
|
pip install -e . |
|
|
pytest -p no:logging --timeout=60 --cov=socketio --cov-branch --cov-report=term-missing --cov-report=xml |
|
|
pytest -p no:logging --timeout=60 --cov=socketio --cov-branch --cov-report=term-missing --cov-report=xml {posargs} |
|
|
deps= |
|
|
deps= |
|
|
simple-websocket |
|
|
simple-websocket |
|
|
uvicorn |
|
|
uvicorn |
|
|
|