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"
Release files for fakewsserver 0.2.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| fakewsserver-0.2.1.tar.gz | 3.8 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| fakewsserver-0.2.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 7.8 kB
Release files / fakewsserver-0.2.1.tar.gz
| Download URL | fakewsserver-0.2.1.tar.gz |
|---|---|
| Size | 3.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7601d29024da4890cf4332edad564bec16820975bb85f971a655dca10323c7b1
|
|
BLAKE2b-256 checksum How to use checksums |
2f226d14d1cbc44fa85a533141239377219f7a8e1aed0b64875c32e1a00ed925
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.1.6 CPython/3.8.10 Linux/5.4.0-77-generic
|
Release files / fakewsserver-0.2.1-py3-none-any.whl
| Download URL | fakewsserver-0.2.1-py3-none-any.whl |
|---|---|
| Size | 4.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
86ed10e3ab6a25eae9926cbb27072d47c51ed4accebbb0c3a3bb628985fde847
|
|
BLAKE2b-256 checksum How to use checksums |
3dc2a2bc2a4001ee1c5b52468bb91604b297cf0201b0d5d886a1161aa55eac83
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.1.6 CPython/3.8.10 Linux/5.4.0-77-generic
|