stuartleeks / aoai-simulated-api

An exploration into creating a simulated API implementation for Azure OpenAI (AOAI)
MIT License
11 stars 4 forks source link

Add testing #6

Closed stuartleeks closed 2 months ago

stuartleeks commented 5 months ago

There are currently a lack of automated tests - this should be remedied!

The goal is to provide an easy way to exercise the key aspects of the simulator (e.g. record/replay, generator, hooks, rate-limiting).

Tests:

stuartleeks commented 5 months ago

One question around this is how to test the record mode.

After speaking with @tanya-borisova I think the simplest route forward is to have a very simple api for testing that has hard-coded responses for the required endpoints to pretend to be OpenAI (or other endpoints needed). This can be started for tests and the simulator can be pointed to that when it needs to forward requests.

stuartleeks commented 5 months ago

@tanya-borisova also pointed me to https://pypi.org/project/pytest_httpserver/ which could also work if running the simulator directly from the tests via uvicorn.run (rather than spinning up via a separate process)