mirror of
https://gitlab.com/veilid/veilid.git
synced 2025-05-03 15:14:56 -04:00
Fix remaining type issues
This commit is contained in:
parent
f1aad14099
commit
e0efb2853b
3 changed files with 22 additions and 9 deletions
|
@ -4,6 +4,7 @@ import asyncio
|
|||
|
||||
import pytest
|
||||
import veilid
|
||||
from veilid.types import OperationId
|
||||
|
||||
from .conftest import server_info
|
||||
|
||||
|
@ -20,7 +21,8 @@ async def test_routing_contexts(api_connection):
|
|||
|
||||
@pytest.mark.asyncio
|
||||
async def test_routing_context_app_message_loopback():
|
||||
app_message_queue = asyncio.Queue()
|
||||
# Seriously, mypy?
|
||||
app_message_queue: asyncio.Queue = asyncio.Queue()
|
||||
|
||||
async def app_message_queue_update_callback(update: veilid.VeilidUpdate):
|
||||
if update.kind == veilid.VeilidUpdateKind.APP_MESSAGE:
|
||||
|
@ -51,13 +53,14 @@ async def test_routing_context_app_message_loopback():
|
|||
update: veilid.VeilidUpdate = await asyncio.wait_for(
|
||||
app_message_queue.get(), timeout=10
|
||||
)
|
||||
appmsg: veilid.VeilidAppMessage = update.detail
|
||||
assert appmsg.message == message
|
||||
|
||||
assert isinstance(update.detail, veilid.VeilidAppMessage)
|
||||
assert update.detail.message == message
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_routing_context_app_call_loopback():
|
||||
app_call_queue = asyncio.Queue()
|
||||
app_call_queue: asyncio.Queue = asyncio.Queue()
|
||||
|
||||
async def app_call_queue_update_callback(update: veilid.VeilidUpdate):
|
||||
if update.kind == veilid.VeilidUpdateKind.APP_CALL:
|
||||
|
@ -88,12 +91,19 @@ async def test_routing_context_app_call_loopback():
|
|||
update: veilid.VeilidUpdate = await asyncio.wait_for(
|
||||
app_call_queue.get(), timeout=10
|
||||
)
|
||||
appcall: veilid.VeilidAppCall = update.detail
|
||||
appcall = update.detail
|
||||
|
||||
assert isinstance(appcall, veilid.VeilidAppCall)
|
||||
assert appcall.message == request
|
||||
|
||||
# now we reply to the request
|
||||
reply = b"qwer5678"
|
||||
await api.app_call_reply(appcall.call_id, reply)
|
||||
# TK: OperationId use to be a subclass of `int`. When I wrapped `appcall.call_id` in int(),
|
||||
# this failed JSON schema validation, which defines `call_id` as a string. Maybe that was a
|
||||
# typo, and OperationId is really *supposed* to be a str? Alternatively, perhaps the
|
||||
# signature of `app_call_reply` is wrong and it's supposed to take a type other than
|
||||
# OperationId?
|
||||
await api.app_call_reply(OperationId(appcall.call_id), reply)
|
||||
|
||||
# now we should get the reply from the call
|
||||
result = await app_call_task
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue