outposts: add ack and disconnect tests
Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
parent
e7dc763612
commit
425b87a6d0
|
@ -126,7 +126,7 @@ class OutpostConsumer(AuthJsonConsumer):
|
||||||
self.send_json(asdict(response))
|
self.send_json(asdict(response))
|
||||||
|
|
||||||
# pylint: disable=unused-argument
|
# pylint: disable=unused-argument
|
||||||
def event_update(self, event):
|
def event_update(self, event): # pragma: no cover
|
||||||
"""Event handler which is called by post_save signals, Send update instruction"""
|
"""Event handler which is called by post_save signals, Send update instruction"""
|
||||||
self.send_json(
|
self.send_json(
|
||||||
asdict(WebsocketMessage(instruction=WebsocketMessageInstruction.TRIGGER_UPDATE))
|
asdict(WebsocketMessage(instruction=WebsocketMessageInstruction.TRIGGER_UPDATE))
|
||||||
|
|
|
@ -75,3 +75,23 @@ class TestOutpostWS(TransactionTestCase):
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
response, asdict(WebsocketMessage(instruction=WebsocketMessageInstruction.ACK, args={}))
|
response, asdict(WebsocketMessage(instruction=WebsocketMessageInstruction.ACK, args={}))
|
||||||
)
|
)
|
||||||
|
await communicator.disconnect()
|
||||||
|
|
||||||
|
async def test_send_ack(self):
|
||||||
|
"""Test sending of ACK"""
|
||||||
|
communicator = WebsocketCommunicator(
|
||||||
|
URLRouter(websocket.websocket_urlpatterns),
|
||||||
|
f"/ws/outpost/{self.outpost.pk}/",
|
||||||
|
{b"authorization": f"Bearer {self.token}".encode()},
|
||||||
|
)
|
||||||
|
connected, _ = await communicator.connect()
|
||||||
|
self.assertTrue(connected)
|
||||||
|
await communicator.send_json_to(
|
||||||
|
asdict(
|
||||||
|
WebsocketMessage(
|
||||||
|
instruction=WebsocketMessageInstruction.ACK,
|
||||||
|
args={},
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
await communicator.disconnect()
|
||||||
|
|
Reference in New Issue