mirror of
https://github.com/invariantlabs-ai/invariant-gateway.git
synced 2026-08-17 06:20:29 +02:00
Initial test setup.
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
FROM mcr.microsoft.com/playwright/python:v1.50.0-noble
|
||||
|
||||
RUN mkdir -p /tests
|
||||
COPY ./requirements.txt /tests/requirements.txt
|
||||
WORKDIR /tests
|
||||
RUN pip install --no-cache-dir -r requirements.txt
|
||||
|
||||
ENTRYPOINT ["pytest", "-s", "-vv"]
|
||||
@@ -0,0 +1,22 @@
|
||||
"""Test the chat completions proxy calls without tool calling."""
|
||||
|
||||
import os
|
||||
|
||||
# add tests folder (parent) to sys.path
|
||||
import sys
|
||||
|
||||
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
||||
|
||||
from util import * # needed for pytest fixtures
|
||||
|
||||
pytest_plugins = ("pytest_asyncio",)
|
||||
|
||||
|
||||
async def test_hello_world(context, url):
|
||||
"""Demo test"""
|
||||
response = await context.request.get(
|
||||
f"{url}/api/v1/dataset/byuser/developer/Welcome-to-Explorer"
|
||||
)
|
||||
dataset = await response.json()
|
||||
assert dataset["name"] == "Welcome-to-Explorer"
|
||||
assert dataset["user"]["username"] == "developer"
|
||||
@@ -0,0 +1,2 @@
|
||||
[pytest]
|
||||
asyncio_mode = auto
|
||||
@@ -0,0 +1,4 @@
|
||||
openai
|
||||
pytest
|
||||
pytest-asyncio
|
||||
pytest-playwright
|
||||
@@ -0,0 +1,29 @@
|
||||
"""Util functions for tests"""
|
||||
|
||||
import pytest
|
||||
from playwright.async_api import async_playwright
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def url():
|
||||
return "http://127.0.0.1"
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
async def playwright(scope="session"):
|
||||
async with async_playwright() as playwright_instance:
|
||||
yield playwright_instance
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
async def browser(playwright, scope="session"):
|
||||
browser = await playwright.firefox.launch(headless=True)
|
||||
yield browser
|
||||
await browser.close()
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
async def context(browser):
|
||||
context = await browser.new_context(ignore_https_errors=True)
|
||||
yield context
|
||||
await context.close()
|
||||
Reference in New Issue
Block a user