Skip to content

Commit

Permalink
Test merge error with patching.
Browse files Browse the repository at this point in the history
  • Loading branch information
cipherself committed Feb 15, 2024
1 parent c8247f8 commit 0c44539
Showing 1 changed file with 15 additions and 42 deletions.
57 changes: 15 additions & 42 deletions tests/enlyze/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -427,68 +427,41 @@ def test__get_timeseries_raises_on_chunk_value_error(
@given(
start=datetime_before_today_strategy,
end=datetime_today_until_now_strategy,
variables=st.lists(
st.builds(
user_models.Variable,
data_type=st.just("INTEGER"),
machine=st.builds(timeseries_api_models.Machine),
),
min_size=3,
max_size=3,
),
first_chunk_records=st.lists(
st.tuples(
datetime_today_until_now_strategy.map(datetime.isoformat),
st.integers(),
),
min_size=10,
max_size=20,
variable=st.builds(
user_models.Variable,
data_type=st.just("INTEGER"),
machine=st.builds(timeseries_api_models.Machine),
),
second_chunk_records=st.lists(
records=st.lists(
st.tuples(
datetime_today_until_now_strategy.map(datetime.isoformat),
st.integers(),
),
min_size=21,
max_size=50,
min_size=2,
),
)
@settings(suppress_health_check=[HealthCheck.function_scoped_fixture])
def test__get_timeseries_raises_on_merge_value_error(
start, end, variables, first_chunk_records, second_chunk_records, monkeypatch
start, end, variable, records, monkeypatch
):
client = make_client()
variables_uuids = [str(variable.uuid) for variable in variables]

monkeypatch.setattr(
"enlyze.client.MAXIMUM_NUMBER_OF_VARIABLES_PER_TIMESERIES_REQUEST", 2
)
def f(*args, **kwargs):
raise ValueError

with respx_mock_with_base_url(TIMESERIES_API_SUB_PATH) as mock:
mock.get(
"timeseries", params={"variables": ','.join(variables_uuids[:2])}
).mock(
PaginatedTimeseriesApiResponse(
data=timeseries_api_models.TimeseriesData(
columns=["time", *variables_uuids[:2]],
records=first_chunk_records,
).model_dump()
)
)
monkeypatch.setattr("enlyze.client.reduce", f)

mock.get(
"timeseries", params={"variables": ','.join(variables_uuids[2:])}
).mock(
with respx_mock_with_base_url(TIMESERIES_API_SUB_PATH) as mock:
mock.get("timeseries").mock(
PaginatedTimeseriesApiResponse(
data=timeseries_api_models.TimeseriesData(
columns=["time", *variables_uuids[100:]],
records=second_chunk_records,
columns=["time", str(variable.uuid)],
records=records,
).model_dump()
)
)

with pytest.raises(EnlyzeError) as exc_info:
client._get_timeseries(start, end, variables)
client._get_timeseries(start, end, [variable])


@given(
Expand Down

0 comments on commit 0c44539

Please sign in to comment.