veilid/veilid-python/tests/test_basic.py

40 lines
1.1 KiB
Python
Raw Normal View History

2023-06-16 00:22:54 +00:00
# Basic veilid tests
2023-06-14 20:33:14 +00:00
2023-06-16 00:22:54 +00:00
import veilid
2023-06-14 20:33:14 +00:00
import pytest
2023-06-15 01:06:10 +00:00
from . import *
2023-06-14 20:33:14 +00:00
##################################################################
@pytest.mark.asyncio
async def test_connect():
2023-06-16 00:22:54 +00:00
async def func(api: veilid.VeilidAPI):
2023-06-14 20:33:14 +00:00
pass
2023-06-16 00:22:54 +00:00
await simple_connect_and_run(func)
2023-06-14 20:33:14 +00:00
2023-06-16 15:57:55 +00: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 20:33:14 +00:00
@pytest.mark.asyncio
async def test_fail_connect():
with pytest.raises(Exception):
2023-06-16 00:22:54 +00:00
api = await veilid.json_api_connect("fuahwelifuh32luhwafluehawea", 1, simple_update_callback)
async with api:
2023-06-14 20:33:14 +00:00
pass
@pytest.mark.asyncio
async def test_version():
2023-06-16 00:22:54 +00:00
async def func(api: veilid.VeilidAPI):
2023-06-14 20:33:14 +00: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-16 00:22:54 +00:00
await simple_connect_and_run(func)
2023-06-16 15:57:55 +00:00