PYthon WebSocket Integration TESTing framework
Project description
pywsitest
PYthon WebSocket Integration TESTing framework
A python API to assist with automated websocket integration testing.
Installation
pip install pywsitest
Package contents
Examples
Testing a reponse with a body is received on connection to a websocket:
from pywsitest import WSTest, WSResponse
ws_test = (
WSTest("wss://example.com")
.with_response(
WSResponse()
.with_attribute("body")
)
)
await ws_test.run()
assert ws_test.is_complete()
Testing a more complex set of responses and messages:
from pywsitest import WSTest, WSResponse, WSMessage
ws_test = (
WSTest("wss://example.com")
.with_parameter("Authorization", "eyJra...")
.with_response_timeout(15) # 15 seconds
.with_message_timeout(7.5)
.with_test_timeout(45)
.with_message(
WSMessage()
.with_attribute("type", "connect")
.with_attribute("body", {"chatroom": "general"})
)
.with_response(
WSResponse()
.with_attribute("type", "connected")
.with_trigger(
WSMessage()
.with_attribute("type", "message")
.with_attribute("body", "Hello, world!")
)
)
.with_response(
WSResponse()
.with_attribute("type", "message")
.with_attribute("body", "Hello, world!")
)
)
await ws_test.run()
assert ws_test.is_complete()
Documentation
Links
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
pywsitest-0.1.tar.gz
(4.5 kB
view hashes)