Skip to content

Commit

Permalink
Add autouse fixture, use join
Browse files Browse the repository at this point in the history
  • Loading branch information
mikehgrantsgov committed Jan 28, 2025
1 parent de4bd08 commit 57ee4f8
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 2 deletions.
5 changes: 5 additions & 0 deletions analytics/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,11 @@ def reset_aws_env_vars(monkeypatch: pytest.MonkeyPatch) -> None:
monkeypatch.setenv("AWS_DEFAULT_REGION", "us-east-1")


@pytest.fixture(autouse=True)
def use_cdn(monkeypatch: pytest.MonkeyPatch) -> None:
monkeypatch.setenv("CDN_URL", "http://localhost:4566")


@pytest.fixture
def mock_s3() -> boto3.resource:
"""Instantiate an S3 bucket resource."""
Expand Down
2 changes: 2 additions & 0 deletions api/local.env
Original file line number Diff line number Diff line change
Expand Up @@ -150,3 +150,5 @@ DEPLOY_GITHUB_REF=main
DEPLOY_GITHUB_SHA=ffaca647223e0b6e54344122eefa73401f5ec131
DEPLOY_TIMESTAMP=2024-12-02T21:25:18Z
DEPLOY_WHOAMI=local-developer

CDN_URL=http://localhost:4566
2 changes: 1 addition & 1 deletion api/src/util/file_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,4 +179,4 @@ def convert_s3_to_cdn_url(file_path: str, cdn_url: str) -> str:
raise ValueError(f"Expected s3:// path, got: {file_path}")

_, key = split_s3_url(file_path)
return f"{cdn_url.rstrip('/')}/{key}"
return join(cdn_url, key)
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,9 @@ def test_get_opportunity_with_agency_200(client, api_auth_token, enable_factory_


def test_get_opportunity_s3_endpoint_url_200(
client, api_auth_token, enable_factory_create, db_session, mock_s3_bucket
client, api_auth_token, enable_factory_create, db_session, mock_s3_bucket, monkeypatch_session
):
monkeypatch_session.delenv("CDN_URL")
# Create an opportunity with a specific attachment
opportunity = OpportunityFactory.create(opportunity_attachments=[])
object_name = "test_file_1.txt"
Expand Down

0 comments on commit 57ee4f8

Please sign in to comment.