-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathtest_message.py
40 lines (33 loc) · 996 Bytes
/
test_message.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import pytest
from distributed_websocket._message import Message, untag_broker_message
def test_message_01():
m = Message(
data={'msg': 'hello'},
typ='send',
topic='test',
conn_id='test',
)
assert m.data == {'msg': 'hello'}
data = m.__serialize__()
assert data == {
'msg': 'hello',
'type': 'send',
'topic': 'test',
'conn_id': 'test',
}
def test_message_02():
m = Message.from_client_message(
data={'msg': 'hello', 'type': 'send', 'topic': 'test', 'conn_id': 'test'}
)
assert m.data == {'msg': 'hello'}
assert m.typ == 'send'
assert m.topic == 'test'
assert m.conn_id == 'test'
def test_untag_broker_message_01():
typ, topic, conn_id, data = untag_broker_message(
'{"msg": "hello", "type": "send", "topic": "test", "conn_id": "test"}'
)
assert typ == 'send'
assert topic == 'test'
assert conn_id == 'test'
assert data == {'msg': 'hello'}