openai/openai-python

Public

mirrored from https://github.com/openai/openai-pythonAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
v2.33.0

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

scripts/test

61lines · modeblame

d2738d42Stainless Bot2 years ago1#!/usr/bin/env bash
2
3set -e
4
5cd "$(dirname "$0")/.."
6
7RED='\033[0;31m'
8GREEN='\033[0;32m'
9YELLOW='\033[0;33m'
10NC='\033[0m' # No Color
11
85ac9313stainless-app[bot]3 months ago12function steady_is_running() {
13curl --silent "http://127.0.0.1:4010/_x-steady/health" >/dev/null 2>&1
d2738d42Stainless Bot2 years ago14}
15
16kill_server_on_port() {
17pids=$(lsof -t -i tcp:"$1" || echo "")
18if [ "$pids" != "" ]; then
19kill "$pids"
20echo "Stopped $pids."
21fi
22}
23
24function is_overriding_api_base_url() {
25[ -n "$TEST_API_BASE_URL" ]
26}
27
85ac9313stainless-app[bot]3 months ago28if ! is_overriding_api_base_url && ! steady_is_running ; then
d2738d42Stainless Bot2 years ago29# When we exit this script, make sure to kill the background mock server process
30trap 'kill_server_on_port 4010' EXIT
31
32# Start the dev server
33./scripts/mock --daemon
34fi
35
36if is_overriding_api_base_url ; then
37echo -e "${GREEN}✔ Running tests against ${TEST_API_BASE_URL}${NC}"
38echo
85ac9313stainless-app[bot]3 months ago39elif ! steady_is_running ; then
40echo -e "${RED}ERROR:${NC} The test suite will not run without a mock Steady server"
d2738d42Stainless Bot2 years ago41echo -e "running against your OpenAPI spec."
42echo
43echo -e "To run the server, pass in the path or url of your OpenAPI"
85ac9313stainless-app[bot]3 months ago44echo -e "spec to the steady command:"
d2738d42Stainless Bot2 years ago45echo
de2c7b1dstainless-app[bot]2 months ago46echo -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}"
d2738d42Stainless Bot2 years ago47echo
48
49exit 1
50else
85ac9313stainless-app[bot]3 months ago51echo -e "${GREEN}✔ Mock steady server is running with your OpenAPI spec${NC}"
d2738d42Stainless Bot2 years ago52echo
53fi
54
bf4a7e67stainless-app[bot]1 years ago55export DEFER_PYDANTIC_BUILD=false
56
d2738d42Stainless Bot2 years ago57echo "==> Running tests"
58rye run pytest "$@"
e8c28f2estainless-app[bot]1 years ago59
60echo "==> Running Pydantic v1 tests"
61rye run nox -s test-pydantic-v1 -- "$@"