Skip to content

Commit 8fcc3e0

Browse files
committed
tests: socket_comms: add simple check
Add a simple test for `comms_check` to ensure the logic works on all OS's in CI. Signed-off-by: Jordan Yates <jordan@embeint.com>
1 parent 17eeb4c commit 8fcc3e0

1 file changed

Lines changed: 26 additions & 0 deletions

File tree

tests/test_socket_comms.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import os
2+
3+
import infuse_iot.socket_comms as comms
4+
5+
assert "TOXTEMPDIR" in os.environ, "you must run these tests using tox"
6+
7+
8+
def test_socket_comms():
9+
# Ensure notifications can be sent from the server to the client, and requests sent in reverse
10+
mulicast_addr = comms.default_multicast_address()
11+
server = comms.LocalServer(mulicast_addr)
12+
client = comms.LocalClient(mulicast_addr)
13+
14+
# Send request to server
15+
request = comms.GatewayRequestCommsCheck()
16+
client.send(request)
17+
18+
# Server receives request, responds
19+
recv_req = server.receive()
20+
assert isinstance(recv_req, comms.GatewayRequestCommsCheck)
21+
response = comms.ClientNotificationCommsCheck()
22+
server.broadcast(response)
23+
24+
# Client receives the response
25+
recv_rsp = client.receive()
26+
assert isinstance(recv_rsp, comms.ClientNotificationCommsCheck)

0 commit comments

Comments
 (0)