2023-06-15 19:22:54 -05:00
|
|
|
# Basic veilid tests
|
2023-06-14 15:33:14 -05:00
|
|
|
|
2023-06-17 13:34:09 -05:00
|
|
|
import socket
|
|
|
|
|
2023-06-14 15:33:14 -05:00
|
|
|
import pytest
|
2023-06-17 13:34:09 -05:00
|
|
|
import veilid
|
|
|
|
|
|
|
|
from . import api_connection, simple_update_callback
|
2023-06-14 15:33:14 -05:00
|
|
|
|
|
|
|
##################################################################
|
|
|
|
|
2023-06-17 13:34:09 -05:00
|
|
|
|
2023-06-14 15:33:14 -05:00
|
|
|
@pytest.mark.asyncio
|
2023-06-17 13:34:09 -05:00
|
|
|
async def test_connect(api_connection):
|
|
|
|
pass
|
2023-06-14 15:33:14 -05:00
|
|
|
|
2023-06-16 10:57:55 -05:00
|
|
|
|
|
|
|
@pytest.mark.asyncio
|
2023-06-17 13:34:09 -05:00
|
|
|
async def test_get_node_id(api_connection):
|
|
|
|
state = await api_connection.get_state()
|
|
|
|
node_ids = state.config.config.network.routing_table.node_id
|
|
|
|
|
|
|
|
assert len(node_ids) >= 1
|
|
|
|
|
|
|
|
for node_id in node_ids:
|
|
|
|
assert node_id[4] == ":"
|
|
|
|
|
2023-06-16 10:57:55 -05:00
|
|
|
|
2023-06-14 15:33:14 -05:00
|
|
|
@pytest.mark.asyncio
|
|
|
|
async def test_fail_connect():
|
2023-06-17 13:34:09 -05:00
|
|
|
with pytest.raises(socket.gaierror) as exc:
|
|
|
|
await veilid.json_api_connect(
|
|
|
|
"fuahwelifuh32luhwafluehawea", 1, simple_update_callback
|
|
|
|
)
|
|
|
|
|
|
|
|
assert exc.value.errno == socket.EAI_NONAME
|
|
|
|
|
2023-06-14 15:33:14 -05:00
|
|
|
|
|
|
|
@pytest.mark.asyncio
|
2023-06-17 13:34:09 -05:00
|
|
|
async def test_version(api_connection):
|
|
|
|
v = await api_connection.veilid_version()
|
|
|
|
print(f"veilid_version: {v.__dict__}")
|
|
|
|
assert v.__dict__.keys() >= {"_major", "_minor", "_patch"}
|
2023-06-16 10:57:55 -05:00
|
|
|
|
2023-06-17 13:34:09 -05:00
|
|
|
vstr = await api_connection.veilid_version_string()
|
|
|
|
print(f"veilid_version_string: {vstr}")
|