Skip to content

Commit c35cc74

Browse files
committed
Removed patch decorators from fixtures due to decorator conflict
1 parent e6c0f3c commit c35cc74

File tree

1 file changed

+22
-20
lines changed

1 file changed

+22
-20
lines changed

tests/server/api/test_movies.py

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -45,35 +45,37 @@
4545
# app.dependency_overrides[murfey_db] = override_murfey_db
4646

4747

48-
@patch("murfey.server.murfey_db.get_security_config")
49-
@patch("murfey.server.murfey_db.url")
5048
@pytest.fixture
51-
def fastapi_client(
52-
mock_get_url,
53-
mock_get_security_config,
49+
def fastapi_test_client(
5450
mock_security_configuration,
5551
murfey_db_session,
5652
):
5753
# Set up mock security configs for
58-
mock_get_url.return_value = murfey_db_url
59-
mock_get_security_config.return_value = security_from_file(
60-
mock_security_configuration
61-
)
62-
63-
# Defer import of 'murfey_db' until after mocks are configured
64-
from murfey.server.murfey_db import murfey_db
54+
with (
55+
patch(
56+
"murfey.server.murfey_db.get_security_config"
57+
) as mock_get_security_config,
58+
patch("murfey.server.murfey_db.url") as mock_get_url,
59+
):
60+
61+
# Defer import of 'murfey_db' until after mocks are configured
62+
mock_get_url.return_value = murfey_db_url
63+
mock_get_security_config.return_value = security_from_file(
64+
mock_security_configuration
65+
)
66+
from murfey.server.murfey_db import murfey_db
6567

66-
# Replace the murfey_db instance in endpoint with properly initialised pytest one
67-
app.dependency_overrides[murfey_db] = murfey_db_session
68-
# Disable instrument token validation
69-
app.dependency_overrides[validate_instrument_token] = lambda: None
68+
# Replace the murfey_db instance in endpoint with properly initialised pytest one
69+
app.dependency_overrides[murfey_db] = murfey_db_session
70+
# Disable instrument token validation
71+
app.dependency_overrides[validate_instrument_token] = lambda: None
7072

71-
with TestClient(app) as client:
72-
yield client
73+
with TestClient(app) as client:
74+
yield client
7375

7476

7577
def test_movie_count(
76-
fastapi_client: TestClient,
78+
fastapi_test_client: TestClient,
7779
murfey_db_session: Session, # From conftest.py
7880
):
7981

@@ -138,7 +140,7 @@ def test_movie_count(
138140
},
139141
)
140142

141-
response = fastapi_client.get(
143+
response = fastapi_test_client.get(
142144
f"{url_path_for('session_control.router', 'count_number_of_movies')}",
143145
headers={"Authorization": f"Bearer {ANY}"},
144146
)

0 commit comments

Comments
 (0)