test: add contract test for discord bot

This commit is contained in:
Jack Michaud
2022-12-31 18:56:13 -05:00
committed by Andreas Köpf
parent 5c9b9e3c9f
commit 036c4b6c6c
4 changed files with 32 additions and 1 deletions
+2
View File
@@ -0,0 +1,2 @@
pytest
pytest-asyncio
+15
View File
@@ -0,0 +1,15 @@
import pytest
from bot.api_client import OasstApiClient
from oasst_shared.schemas import protocol as protocol_schema
@pytest.fixture
def oasst_api_client_mocked():
client = OasstApiClient(backend_url="http://localhost:8080", api_key="123")
yield client
@pytest.mark.asyncio
async def test_fetch_task(oasst_api_client_mocked: OasstApiClient):
assert await oasst_api_client_mocked.fetch_task(task_type=protocol_schema.TaskRequestType.random) is not None
@@ -10,7 +10,11 @@ python -m print_openapi_schema > oasst-openapi.json
MOCK_SERVER_PORT=8080
docker run --init --rm -d -p $MOCK_SERVER_PORT:4010 -v $(pwd):/tmp -P stoplight/prism:4 proxy -h 0.0.0.0 "/tmp/oasst-openapi.json"
docker run --init --rm -d \
-p $MOCK_SERVER_PORT:4010 \
-v $(pwd):/tmp \
-P stoplight/prism:4 \
mock -h 0.0.0.0 "/tmp/oasst-openapi.json"
popd
+10
View File
@@ -0,0 +1,10 @@
#!/usr/bin/env bash
parent_path=$( cd "$(dirname "${BASH_SOURCE[0]}")" ; pwd -P )
# switch to backend directory
pushd "$parent_path/../../discord-bot"
pytest .
popd