mirror of
https://github.com/wassname/Open-Assistant.git
synced 2026-06-27 16:10:30 +08:00
test: add contract test for discord bot
This commit is contained in:
committed by
Andreas Köpf
parent
5c9b9e3c9f
commit
036c4b6c6c
@@ -0,0 +1,2 @@
|
||||
pytest
|
||||
pytest-asyncio
|
||||
@@ -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
|
||||
|
||||
Executable
+10
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user