-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add `znsocket.List` * unit test List * more unit tests * better tests * add tests * do not test with redis * use redis server container * always test against redis * improve testing and small bugfix * add pypi badge * raise exceptions * test Server.from_url * add lpush, improve tests * update `srem` * update README * remove * bump version * update description
- Loading branch information
Showing
13 changed files
with
627 additions
and
101 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import eventlet.wsgi | ||
|
||
eventlet.monkey_patch() # MUST BE THERE FOR THE TESTS TO WORK | ||
|
||
import random | ||
|
||
import pytest | ||
import redis | ||
import socketio.exceptions | ||
|
||
from znsocket import Client, Server | ||
|
||
|
||
@pytest.fixture | ||
def eventlet_memory_server(): | ||
port = random.randint(10000, 20000) | ||
|
||
def start_server(): | ||
server = Server(port=port) | ||
server.run() | ||
|
||
thread = eventlet.spawn(start_server) | ||
|
||
# wait for the server to be ready | ||
for _ in range(100): | ||
try: | ||
with socketio.SimpleClient() as client: | ||
client.connect(f"http://localhost:{port}") | ||
break | ||
except socketio.exceptions.ConnectionError: | ||
eventlet.sleep(0.1) | ||
else: | ||
raise TimeoutError("Server did not start in time") | ||
|
||
yield f"znsocket://127.0.0.1:{port}" | ||
|
||
thread.kill() | ||
|
||
|
||
@pytest.fixture | ||
def znsclient(eventlet_memory_server): | ||
r = Client.from_url(eventlet_memory_server) | ||
yield r | ||
r.flushall() | ||
|
||
|
||
@pytest.fixture | ||
def redisclient(): | ||
r = redis.Redis.from_url("redis://localhost:6379/0", decode_responses=True) | ||
yield r | ||
r.flushdb() |
Oops, something went wrong.