Websocket server for testing
Project description
Fake Websocket Server
Fake in the sense that it's actually a working server (created using
websockets
library) but one that that exists briefly to allow
integration testing.
Installation
pip install fakewsserver
Usage
One message sent, one received, everything is as expected
from fakewsserver import assert_communication
async with assert_communication(
port=12345,
communication=[('hello', 'there')],
):
async with websockets.connect('ws://localhost:12345') as client:
await client.send('hello')
response = await client.recv()
assert response == 'there'
Expected communication pattern does not match
communication = [
('hello', 'there'),
('general', 'Kenobi'),
]
async with assert_communication(
port=12345,
communication=communication,
):
async with websockets.connect('ws://localhost:12345') as client:
await client.send('hello')
response = await client.recv()
assert response == 'there'
await client.send('admiral')
await client.recv()
And there's a feedback what went wrong:
AssertionError: Failed 2nd step:
Expected: "general"
Got: "admiral"
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
fakewsserver-0.2.1.tar.gz
(3.8 kB
view details)
Built Distribution
File details
Details for the file fakewsserver-0.2.1.tar.gz
.
File metadata
- Download URL: fakewsserver-0.2.1.tar.gz
- Upload date:
- Size: 3.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.6 CPython/3.8.10 Linux/5.4.0-77-generic
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7601d29024da4890cf4332edad564bec16820975bb85f971a655dca10323c7b1 |
|
MD5 | 96cf5146dcaff52074128d099b7b9d1e |
|
BLAKE2b-256 | 2f226d14d1cbc44fa85a533141239377219f7a8e1aed0b64875c32e1a00ed925 |
File details
Details for the file fakewsserver-0.2.1-py3-none-any.whl
.
File metadata
- Download URL: fakewsserver-0.2.1-py3-none-any.whl
- Upload date:
- Size: 4.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.6 CPython/3.8.10 Linux/5.4.0-77-generic
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 86ed10e3ab6a25eae9926cbb27072d47c51ed4accebbb0c3a3bb628985fde847 |
|
MD5 | 617b70b3df04f8d0e3629c3dfea93a5d |
|
BLAKE2b-256 | 3dc2a2bc2a4001ee1c5b52468bb91604b297cf0201b0d5d886a1161aa55eac83 |