Skip to content

Commit

Permalink
Fix performance of test resulting in Hypothesis health check error.
Browse files Browse the repository at this point in the history
  • Loading branch information
daniel-k committed Oct 1, 2024
1 parent d1d393c commit b0b4240
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions tests/enlyze/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
from enlyze.client import EnlyzeClient
from enlyze.constants import (
ENLYZE_BASE_URL,
MAXIMUM_NUMBER_OF_VARIABLES_PER_TIMESERIES_REQUEST,
PRODUCTION_RUNS_API_SUB_PATH,
TIMESERIES_API_SUB_PATH,
)
Expand Down Expand Up @@ -350,6 +349,7 @@ def test_get_timeseries_returns_none_on_empty_response(
)
@settings(suppress_health_check=[HealthCheck.function_scoped_fixture])
def test__get_timeseries_raises_on_mixed_response(
monkeypatch,
data_strategy,
start_datetime,
end_datetime,
Expand All @@ -360,6 +360,14 @@ def test__get_timeseries_raises_on_mixed_response(
Tests that an `EnlyzeError` is raised if the timeseries API returns
data for some of the variables but not all of them.
"""

# patch to lower value to improve test performance
max_vars_per_request = 10
monkeypatch.setattr(
"enlyze.client.MAXIMUM_NUMBER_OF_VARIABLES_PER_TIMESERIES_REQUEST",
max_vars_per_request,
)

client = make_client()
variables = data_strategy.draw(
st.lists(
Expand All @@ -368,8 +376,8 @@ def test__get_timeseries_raises_on_mixed_response(
data_type=st.just("INTEGER"),
machine=st.just(machine),
),
min_size=MAXIMUM_NUMBER_OF_VARIABLES_PER_TIMESERIES_REQUEST + 1,
max_size=MAXIMUM_NUMBER_OF_VARIABLES_PER_TIMESERIES_REQUEST + 5,
min_size=max_vars_per_request + 1,
max_size=max_vars_per_request + 5,
)
)

Expand All @@ -382,9 +390,7 @@ def test__get_timeseries_raises_on_mixed_response(
"time",
*[
str(variable.uuid)
for variable in variables[
:MAXIMUM_NUMBER_OF_VARIABLES_PER_TIMESERIES_REQUEST
]
for variable in variables[:max_vars_per_request]
],
],
records=records,
Expand Down

0 comments on commit b0b4240

Please sign in to comment.