Skip to content

Commit

Permalink
Merge branch 'develop' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
BottlecapDave committed Oct 14, 2024
2 parents 25c591c + 88896a9 commit 628b3b3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ async def async_merge_dispatch_data(*args, **kwargs):
assert retrieved_dispatches.dispatches.planned[index].start == mocked_data.planned[index].start

@pytest.mark.asyncio
async def test_when_next_refresh_is_in_the_past_then_existing_settings_returned():
async def test_when_next_refresh_is_in_the_future_then_existing_dispatches_returned():
current = datetime.strptime("2023-07-14T10:30:01+01:00", "%Y-%m-%dT%H:%M:%S%z")
expected_dispatches = IntelligentDispatches([], [])
mock_api_called = False
Expand All @@ -206,7 +206,7 @@ async def async_merge_dispatch_data(*args, **kwargs):
return completed_dispatches

account_info = get_account_info()
existing_settings = IntelligentDispatchesCoordinatorResult(current - timedelta(minutes=4, seconds=59), 1, mock_intelligent_dispatches())
existing_dispatches = IntelligentDispatchesCoordinatorResult(current - timedelta(minutes=(REFRESH_RATE_IN_MINUTES_INTELLIGENT - 1), seconds=59), 1, mock_intelligent_dispatches())

with mock.patch.multiple(OctopusEnergyApiClient, async_get_intelligent_dispatches=async_mock_get_intelligent_dispatches):
client = OctopusEnergyApiClient("NOT_REAL")
Expand All @@ -215,14 +215,13 @@ async def async_merge_dispatch_data(*args, **kwargs):
client,
account_info,
intelligent_device,
existing_settings,
existing_dispatches,
False,
async_merge_dispatch_data
)

assert retrieved_dispatches == existing_settings
assert mock_api_called == False

assert retrieved_dispatches == existing_dispatches

@pytest.mark.asyncio
@pytest.mark.parametrize("existing_settings",[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ async def async_mock_get_intelligent_settings(*args, **kwargs):
return expected_settings

account_info = get_account_info()
existing_settings = IntelligentCoordinatorResult(current - timedelta(minutes=4, seconds=59), 1, mock_intelligent_settings())
existing_settings = IntelligentCoordinatorResult(current - timedelta(minutes=REFRESH_RATE_IN_MINUTES_INTELLIGENT - 1, seconds=59), 1, mock_intelligent_settings())

with mock.patch.multiple(OctopusEnergyApiClient, async_get_intelligent_settings=async_mock_get_intelligent_settings):
client = OctopusEnergyApiClient("NOT_REAL")
Expand Down

0 comments on commit 628b3b3

Please sign in to comment.