Initial test setup.

This commit is contained in:
Hemang
2025-02-05 19:33:17 +01:00
parent e279351e93
commit c4fe6ebae3
8 changed files with 106 additions and 1 deletions
+8
View File
@@ -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"
+2
View File
@@ -0,0 +1,2 @@
[pytest]
asyncio_mode = auto
+4
View File
@@ -0,0 +1,4 @@
openai
pytest
pytest-asyncio
pytest-playwright
+29
View File
@@ -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()