more tests
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
import pytest
|
||||
pytest_plugins = ('pytest_asyncio',)
|
||||
|
||||
import os
|
||||
|
||||
##################################################################
|
||||
VEILID_SERVER = os.getenv("VEILID_SERVER")
|
||||
if VEILID_SERVER is not None:
|
||||
vsparts = VEILID_SERVER.split(":")
|
||||
VEILID_SERVER = vsparts[0]
|
||||
if len(vsparts) == 2:
|
||||
VEILID_SERVER_PORT = int(vsparts[1])
|
||||
else:
|
||||
VEILID_SERVER_PORT = 5959
|
||||
else:
|
||||
VEILID_SERVER = "localhost"
|
||||
VEILID_SERVER_PORT = 5959
|
||||
|
||||
##################################################################
|
||||
|
||||
async def simple_update_callback(update):
|
||||
print("VeilidUpdate: {}".format(update))
|
||||
|
@@ -2,42 +2,24 @@
|
||||
|
||||
import veilid_python
|
||||
import pytest
|
||||
import os
|
||||
|
||||
pytest_plugins = ('pytest_asyncio',)
|
||||
from . import *
|
||||
|
||||
##################################################################
|
||||
VEILID_SERVER = os.getenv("VEILID_SERVER")
|
||||
if VEILID_SERVER is not None:
|
||||
vsparts = VEILID_SERVER.split(":")
|
||||
VEILID_SERVER = vsparts[0]
|
||||
if len(vsparts) == 2:
|
||||
VEILID_SERVER_PORT = int(vsparts[1])
|
||||
else:
|
||||
VEILID_SERVER_PORT = 5959
|
||||
else:
|
||||
VEILID_SERVER = "localhost"
|
||||
VEILID_SERVER_PORT = 5959
|
||||
|
||||
##################################################################
|
||||
|
||||
async def _simple_update_callback(update):
|
||||
print("VeilidUpdate: {}".format(update))
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_connect():
|
||||
async with await veilid_python.json_api_connect(VEILID_SERVER, VEILID_SERVER_PORT, _simple_update_callback) as api:
|
||||
async with await veilid_python.json_api_connect(VEILID_SERVER, VEILID_SERVER_PORT, simple_update_callback) as api:
|
||||
pass
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_fail_connect():
|
||||
with pytest.raises(Exception):
|
||||
async with await veilid_python.json_api_connect("fuahwelifuh32luhwafluehawea", 1, _simple_update_callback) as api:
|
||||
async with await veilid_python.json_api_connect("fuahwelifuh32luhwafluehawea", 1, simple_update_callback) as api:
|
||||
pass
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_version():
|
||||
async with await veilid_python.json_api_connect(VEILID_SERVER, VEILID_SERVER_PORT, _simple_update_callback) as api:
|
||||
async with await veilid_python.json_api_connect(VEILID_SERVER, VEILID_SERVER_PORT, simple_update_callback) as api:
|
||||
v = await api.veilid_version()
|
||||
print("veilid_version: {}".format(v.__dict__))
|
||||
vstr = await api.veilid_version_string()
|
||||
|
28
veilid-python/tests/test_crypto.py
Normal file
28
veilid-python/tests/test_crypto.py
Normal file
@@ -0,0 +1,28 @@
|
||||
# Crypto veilid_python tests
|
||||
|
||||
import veilid_python
|
||||
import pytest
|
||||
from . import *
|
||||
|
||||
##################################################################
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_best_crypto_system():
|
||||
async with await veilid_python.json_api_connect(VEILID_SERVER, VEILID_SERVER_PORT, simple_update_callback) as api:
|
||||
bcs = await api.best_crypto_system()
|
||||
# let handle dangle for test
|
||||
# del bcs
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_get_crypto_system():
|
||||
async with await veilid_python.json_api_connect(VEILID_SERVER, VEILID_SERVER_PORT, simple_update_callback) as api:
|
||||
cs = await api.get_crypto_system(veilid_python.CryptoKind.CRYPTO_KIND_VLD0)
|
||||
# clean up handle early
|
||||
del cs
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_get_crypto_system_invalid():
|
||||
async with await veilid_python.json_api_connect(VEILID_SERVER, VEILID_SERVER_PORT, simple_update_callback) as api:
|
||||
with pytest.raises(veilid_python.VeilidAPIError):
|
||||
cs = await api.get_crypto_system(veilid_python.CryptoKind.CRYPTO_KIND_NONE)
|
||||
|
Reference in New Issue
Block a user