|
4 | 4 | from flask import Blueprint |
5 | 5 |
|
6 | 6 |
|
7 | | -def test_socket_subscriber_property_notify(view_cls, fake_websocket): |
8 | | - setattr(view_cls, "endpoint", "index") |
9 | | - ws = fake_websocket("", recieve_once=True) |
10 | | - sub = base.SocketSubscriber(ws) |
11 | | - |
12 | | - sub.property_notify(view_cls) |
13 | | - assert json.loads(ws.response) == { |
14 | | - "messageType": "propertyStatus", |
15 | | - "data": {"index": "GET"}, |
16 | | - } |
17 | | - |
18 | | - |
19 | | -def test_socket_subscriber_property_notify_empty_view(flask_view_cls, fake_websocket): |
20 | | - ws = fake_websocket("", recieve_once=True) |
21 | | - sub = base.SocketSubscriber(ws) |
22 | | - |
23 | | - sub.property_notify(flask_view_cls) |
24 | | - assert json.loads(ws.response) == { |
25 | | - "messageType": "propertyStatus", |
26 | | - "data": {flask_view_cls.__name__: None}, |
27 | | - } |
28 | | - |
29 | | - |
30 | | -def test_socket_subscriber_event_notify(fake_websocket): |
31 | | - ws = fake_websocket("", recieve_once=True) |
32 | | - sub = base.SocketSubscriber(ws) |
33 | | - |
34 | | - data = {"key": "value"} |
35 | | - |
36 | | - sub.event_notify(data) |
37 | | - assert json.loads(ws.response) == {"messageType": "event", "data": data} |
38 | | - |
39 | | - |
40 | 7 | def test_sockets_flask_init(app): |
41 | 8 | original_wsgi_app = app.wsgi_app |
42 | 9 | socket = gsocket.Sockets(app) |
|
0 commit comments