コード例 #1
0
async def test_workitem_messages(client):
    response = await client.get(f"{configuration.base_url}/v1/workitems/1/messages")
    assert response.status_code == 200

    errors = [MessageSchema(**item) for item in response.json()["items"]]
    message_ids = {error.id for error in errors}
    assert message_ids == {1, 3}
コード例 #2
0
async def test_masterrecord_messages(client):
    response = await client.get(
        f"{configuration.base_url}/v1/masterrecords/1/messages")
    assert response.status_code == 200

    errors = [MessageSchema(**item) for item in response.json()["items"]]
    returned_ids = {item.id for item in errors}
    assert returned_ids == {1, 3}
コード例 #3
0
async def test_messages_list(client):
    since = days_ago(730).isoformat()
    until = days_ago(0).isoformat()
    response = await client.get(
        f"{configuration.base_url}/v1/messages/?since={since}&until={until}")
    assert response.status_code == 200
    messages = [MessageSchema(**item) for item in response.json()["items"]]
    returned_ids = {item.id for item in messages}
    assert returned_ids == {1, 2, 3}
コード例 #4
0
ファイル: messages.py プロジェクト: renalreg/ukrdc-fastapi
def error_detail(
        message_id: str,
        user: UKRDCUser = Security(auth.get_user()),
        errorsdb: Session = Depends(get_errorsdb),
        audit: Auditer = Depends(get_auditer),
):
    """Retreive detailed information about a specific error message"""
    # For some reason the fastAPI response_model doesn't call our channel_name
    # validator, meaning we don't get a populated channel name unless we explicitly
    # call it here.
    message = get_message(errorsdb, message_id, user)
    audit.add_event(Resource.MESSAGE, message.id, MessageOperation.READ)
    return MessageSchema.from_orm(message)
コード例 #5
0
ファイル: __init__.py プロジェクト: renalreg/ukrdc-fastapi
async def cache_channel_info(mirth: MirthAPI, redis: Redis) -> list[ChannelModel]:
    """Cache (to Redis) the list of Mirth channel infos

    Args:
        mirth (MirthAPI): API instance
        redis (Redis): Redis cache instance

    Returns:
        list[ChannelModel]: List of channel infos
    """
    redis_key: str = "mirth:channel_info"
    channel_info: list[ChannelModel] = await mirth.channel_info()
    redis.hset(  # type: ignore
        redis_key,
        mapping={
            str(channel.id): channel.json(by_alias=True) for channel in channel_info
        },
    )

    # Some of our models need the ID-name map to function properly
    id_name_map = {str(channel.id): channel.name for channel in channel_info}
    MessageSchema.set_channel_id_name_map(id_name_map)

    return channel_info
コード例 #6
0
async def test_message_detail(client):
    response = await client.get(f"{configuration.base_url}/v1/messages/1")
    assert response.status_code == 200
    error = MessageSchema(**response.json())
    assert error.id == 1