Skip to content

Commit 41303db

Browse files
authored
fix: Fix the log leakages in integration tests (#787)
1 parent fdd83c5 commit 41303db

File tree

2 files changed

+5
-20
lines changed

2 files changed

+5
-20
lines changed

tests/integration/api/conftest.py

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"""Module for test configurations for the integration test directory."""
66

77
from logging import LogRecord
8-
from typing import Iterator, Generator
8+
from typing import Iterator
99
from unittest.mock import AsyncMock
1010

1111
import pytest
@@ -30,7 +30,6 @@
3030
)
3131
from merino.main import app
3232
from merino.utils.log_data_creators import RequestSummaryLogDataModel
33-
from merino.middleware import ScopeKey
3433
from tests.integration.api.types import RequestSummaryLogDataFixture
3534

3635

@@ -70,18 +69,6 @@ def fixture_test_client() -> TestClient:
7069
return TestClient(app)
7170

7271

73-
@pytest.fixture(name="client_with_metrics")
74-
def fixture_client_with_metrics() -> Generator[TestClient, None, None]:
75-
"""Create test client with NoOpMetricsClient in request scope."""
76-
77-
async def asgi_wrapper(scope, receive, send):
78-
scope[ScopeKey.METRICS_CLIENT] = NoOpMetricsClient()
79-
await app(scope, receive, send)
80-
81-
with TestClient(asgi_wrapper) as client:
82-
yield client
83-
84-
8572
@pytest.fixture(name="client_with_events")
8673
def fixture_test_client_with_events() -> Iterator[TestClient]:
8774
"""Return a FastAPI TestClient instance.

tests/integration/api/v1/manifest/test_manifest.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ async def cleanup_tasks(provider: Provider):
2828

2929

3030
@pytest.mark.asyncio
31-
async def test_get_manifest_success(client_with_metrics, gcp_uploader, mock_manifest, cleanup):
31+
async def test_get_manifest_success(client, gcp_uploader, mock_manifest, cleanup):
3232
"""Uploads a manifest to the gcs bucket and verifies that the endpoint returns the uploaded file."""
3333
# initialize provider on startup
3434
await init_provider()
@@ -44,7 +44,7 @@ async def test_get_manifest_success(client_with_metrics, gcp_uploader, mock_mani
4444

4545
cleanup(provider)
4646

47-
response = client_with_metrics.get("/api/v1/manifest")
47+
response = client.get("/api/v1/manifest")
4848
assert response.status_code == 200
4949

5050
manifest = ManifestData(**response.json())
@@ -55,9 +55,7 @@ async def test_get_manifest_success(client_with_metrics, gcp_uploader, mock_mani
5555

5656

5757
@pytest.mark.asyncio
58-
async def test_get_manifest_from_gcs_bucket_should_return_empty_manifest_file(
59-
client_with_metrics, cleanup
60-
):
58+
async def test_get_manifest_from_gcs_bucket_should_return_empty_manifest_file(client, cleanup):
6159
"""Does not upload any manifests to the gcs bucket. Should return none and a 404."""
6260
await init_provider()
6361

@@ -69,7 +67,7 @@ async def test_get_manifest_from_gcs_bucket_should_return_empty_manifest_file(
6967

7068
cleanup(provider)
7169

72-
response = client_with_metrics.get("/api/v1/manifest")
70+
response = client.get("/api/v1/manifest")
7371
assert response.status_code == 404
7472

7573
assert response.json()["domains"] == []

0 commit comments

Comments
 (0)