Fix remaining type issues

This commit is contained in:
Teknique 2023-06-17 12:09:40 -07:00
parent f1aad14099
commit e0efb2853b
No known key found for this signature in database
GPG key ID: 54D9906A294B7FF3
3 changed files with 22 additions and 9 deletions

View file

@ -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