SIGN IN SIGN UP
openai / openai-python UNCLAIMED

The official Python library for the OpenAI API

30344 0 0 Python
2024-05-01 00:00:17 -04:00
#!/usr/bin/env bash
set -e
cd "$(dirname "$0")/.."
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[0;33m'
NC='\033[0m' # No Color
function steady_is_running() {
curl --silent "http://127.0.0.1:4010/_x-steady/health" >/dev/null 2>&1
2024-05-01 00:00:17 -04:00
}
kill_server_on_port() {
pids=$(lsof -t -i tcp:"$1" || echo "")
if [ "$pids" != "" ]; then
kill "$pids"
echo "Stopped $pids."
fi
}
function is_overriding_api_base_url() {
[ -n "$TEST_API_BASE_URL" ]
}
if ! is_overriding_api_base_url && ! steady_is_running ; then
2024-05-01 00:00:17 -04:00
# When we exit this script, make sure to kill the background mock server process
trap 'kill_server_on_port 4010' EXIT
# Start the dev server
./scripts/mock --daemon
fi
if is_overriding_api_base_url ; then
echo -e "${GREEN}✔ Running tests against ${TEST_API_BASE_URL}${NC}"
echo
elif ! steady_is_running ; then
echo -e "${RED}ERROR:${NC} The test suite will not run without a mock Steady server"
2024-05-01 00:00:17 -04:00
echo -e "running against your OpenAPI spec."
echo
echo -e "To run the server, pass in the path or url of your OpenAPI"
echo -e "spec to the steady command:"
2024-05-01 00:00:17 -04:00
echo
2026-03-31 19:26:08 +00:00
echo -e " \$ ${YELLOW}npm exec --package=@stdy/cli@0.20.2 -- steady path/to/your.openapi.yml --host 127.0.0.1 -p 4010 --validator-query-array-format=brackets --validator-form-array-format=brackets --validator-query-object-format=brackets --validator-form-object-format=brackets${NC}"
2024-05-01 00:00:17 -04:00
echo
exit 1
else
echo -e "${GREEN}✔ Mock steady server is running with your OpenAPI spec${NC}"
2024-05-01 00:00:17 -04:00
echo
fi
export DEFER_PYDANTIC_BUILD=false
2024-05-01 00:00:17 -04:00
echo "==> Running tests"
rye run pytest "$@"
echo "==> Running Pydantic v1 tests"
rye run nox -s test-pydantic-v1 -- "$@"