Skip to content

Commit

Permalink
reformat for ruff
Browse files Browse the repository at this point in the history
  • Loading branch information
Christine Caggiano committed Jun 6, 2024
1 parent 3006a2c commit 8e1b958
Showing 1 changed file with 10 additions and 16 deletions.
26 changes: 10 additions & 16 deletions backend/src/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
from azure.cosmos import CosmosClient
from azure.identity import DefaultAzureCredential
from azure.storage.blob import BlobServiceClient
from fastapi.testclient import TestClient
from dotenv import load_dotenv

from ..main import app
load_dotenv()


def _upload_files(blob_service_client, directory, container_name):
Expand All @@ -36,20 +36,14 @@ def _upload_files(blob_service_client, directory, container_name):

@pytest.fixture(scope="session")
def client(request):
"""Return the outside URL or a TestClient based on environment variable USE_LOCAL_SERVER."""
use_local_server = os.getenv("USE_LOCAL_SERVER", "false").lower() == "true"
if use_local_server:
# If running with -localserver flag, use FastAPI TestClient
return TestClient(app)
else:
# Otherwise, use the outside URL
deployment_url = os.environ["DEPLOYMENT_URL"]
deployment_url = deployment_url.rstrip("/")
apim_key = os.environ["APIM_SUBSCRIPTION_KEY"]
session = requests.Session()
session.headers.update({"Ocp-Apim-Subscription-Key": apim_key})
session.base_url = deployment_url
return session
"""Return the session base url which is the deployment url authorized with the apim subscription key stored in your .env file"""
deployment_url = os.environ["DEPLOYMENT_URL"]
deployment_url = deployment_url.rstrip("/")
apim_key = os.environ["APIM_SUBSCRIPTION_KEY"]
session = requests.Session()
session.headers.update({"Ocp-Apim-Subscription-Key": apim_key})
session.base_url = deployment_url
return session


@pytest.fixture()
Expand Down

0 comments on commit 8e1b958

Please sign in to comment.