veilid/veilid-python/tests/test_basic.py

40 lines
1.1 KiB
Python
Raw Normal View History

2023-06-15 20:22:54 -04:00
# Basic veilid tests
2023-06-14 16:33:14 -04:00
2023-06-15 20:22:54 -04:00
import veilid
2023-06-14 16:33:14 -04:00
import pytest
2023-06-14 21:06:10 -04:00
from . import *
2023-06-14 16:33:14 -04:00
##################################################################
@pytest.mark.asyncio
async def test_connect():
2023-06-15 20:22:54 -04:00
async def func(api: veilid.VeilidAPI):
2023-06-14 16:33:14 -04:00
pass
2023-06-15 20:22:54 -04:00
await simple_connect_and_run(func)
2023-06-14 16:33:14 -04:00
2023-06-16 11:57:55 -04:00
@pytest.mark.asyncio
async def test_get_node_id():
async def func(api: veilid.VeilidAPI):
# get our own node id
state = await api.get_state()
node_id = state.config.config.network.routing_table.node_id.pop()
await simple_connect_and_run(func)
2023-06-14 16:33:14 -04:00
@pytest.mark.asyncio
async def test_fail_connect():
with pytest.raises(Exception):
2023-06-15 20:22:54 -04:00
api = await veilid.json_api_connect("fuahwelifuh32luhwafluehawea", 1, simple_update_callback)
async with api:
2023-06-14 16:33:14 -04:00
pass
@pytest.mark.asyncio
async def test_version():
2023-06-15 20:22:54 -04:00
async def func(api: veilid.VeilidAPI):
2023-06-14 16:33:14 -04:00
v = await api.veilid_version()
print("veilid_version: {}".format(v.__dict__))
vstr = await api.veilid_version_string()
print("veilid_version_string: {}".format(vstr))
2023-06-15 20:22:54 -04:00
await simple_connect_and_run(func)
2023-06-16 11:57:55 -04:00