Skip to content

Commit

Permalink
Test client raises EnlyzeError from ValueError.
Browse files Browse the repository at this point in the history
  • Loading branch information
cipherself committed Feb 15, 2024
1 parent d596f1e commit e27b66f
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions tests/enlyze/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,38 @@ def test_get_timeseries_raises_api_returned_no_timestamps(
client.get_timeseries(start_datetime, end_datetime, [variable])


@given(
variable=st.builds(user_models.Variable),
)
@settings(suppress_health_check=[HealthCheck.function_scoped_fixture])
def test__get_timeseries_raises_variables_without_resampling_method(
start_datetime, end_datetime, variable
):
"""
Test that `get_timeseries` will raise an `EnlyzeError` when a
`resampling_interval` is specified but variables don't have
resampling methods.
"""
client = make_client()
with pytest.raises(EnlyzeError) as exc_info:
client._get_timeseries(start_datetime, end_datetime, [variable], 30)
assert isinstance(exc_info.value.__cause__, ValueError)


@given(
variable=st.builds(user_models.Variable),
)
@settings(suppress_health_check=[HealthCheck.function_scoped_fixture])
def test__get_timeseries_raises_on_chunk_value_error(
start_datetime, end_datetime, variable, monkeypatch
):
monkeypatch.setattr("enlyze.client.MAXIMUM_NUMBER_OF_VARIABLES_PER_TIMESERIES_REQUEST", 0)
client = make_client()
with pytest.raises(EnlyzeError) as exc_info:
client._get_timeseries(start_datetime, end_datetime, [variable])
assert isinstance(exc_info.value.__cause__, ValueError)


@given(
production_order=st.just(PRODUCTION_ORDER),
product=st.one_of(
Expand Down

0 comments on commit e27b66f

Please sign in to comment.