(test) test key/generate against deployed proxy

This commit is contained in:
ishaan-jaff 2024-01-08 17:25:56 +05:30
parent 02c166138f
commit 9b04b1c9ad

View file

@ -10,13 +10,13 @@ import os, io
sys.path.insert(
0, os.path.abspath("../..")
) # Adds the parent directory to the system path
import pytest, logging
import pytest, logging, requests
import litellm
from litellm import embedding, completion, completion_cost, Timeout
from litellm import RateLimitError
def test_add_new_key(client):
def test_add_new_key():
try:
# Your test data
test_data = {
@ -29,10 +29,25 @@ def test_add_new_key(client):
token = os.getenv("PROXY_MASTER_KEY")
headers = {"Authorization": f"Bearer {token}"}
response = client.post("/key/generate", json=test_data, headers=headers)
staging_endpoint = "https://litellm-litellm-pr-1366.up.railway.app"
# Your bearer token
token = os.getenv("PROXY_MASTER_KEY")
headers = {"Authorization": f"Bearer {token}"}
# Make a request to the staging endpoint
response = requests.post(
staging_endpoint + "/key/generate", json=test_data, headers=headers
)
print(f"response: {response.text}")
assert response.status_code == 200
result = response.json()
except Exception as e:
print(traceback.format_exc())
pytest.fail(f"An error occurred {e}")
# test_add_new_key()