Skip to content

Commit

Permalink
fix test cases; lint
Browse files Browse the repository at this point in the history
  • Loading branch information
sschirr committed Apr 22, 2024
1 parent f4ae40e commit 86ce5bf
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 14 deletions.
15 changes: 7 additions & 8 deletions miio/integrations/chunmi/cooker_multi/cooker_multi.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,12 +269,9 @@ def ready_at(self) -> Optional[datetime.datetime]:
return None

return (
datetime.datetime.now()
+ datetime.timedelta(
minutes=self.remaining
)
datetime.datetime.now() + datetime.timedelta(minutes=self.remaining)
).replace(second=0, microsecond=0)

@property
@sensor("Cooking process time remaining in minutes")
def remaining(self) -> int:
Expand All @@ -283,14 +280,16 @@ def remaining(self) -> int:
if self.mode != OperationMode.PreCook and self.mode != OperationMode.Running:
return 0

remaining_minutes = int(self.data["t_left"]/60)
remaining_minutes = int(self.data["t_left"] / 60)
if self.mode == OperationMode.PreCook:
remaining_minutes = int(self.data["t_pre"])

return remaining_minutes

@property
@sensor("Cooking process delay time remaining in minutes (precook phase time remaining)")
@sensor(
"Cooking process delay time remaining in minutes (precook phase time remaining)"
)
def delay_remaining(self) -> int:
"""Remaining minutes of the cooking delay (precook phase)."""

Expand Down
12 changes: 6 additions & 6 deletions miio/integrations/chunmi/cooker_multi/test_cooker_multi.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,12 +214,12 @@ def test_case_0(self):
status = self.device.status()
assert status.mode == OperationMode.PreCook
assert status.menu == "Fine Rice"
assert status.cooking_delayed == 75
assert status.delay_remaining == 75 - 60
assert status.keep_warm is True

# Total time should be 75min delay + 60min cooking time for "Fine rice"
assert status.ready_at == (
datetime.datetime.now() + datetime.timedelta(0, (75 + 60) * 60)
datetime.datetime.now() + datetime.timedelta(0, minutes=(15 + 60))
).replace(second=0, microsecond=0)
self.device.stop()

Expand All @@ -228,12 +228,12 @@ def test_case_1(self):
status = self.device.status()
assert status.mode == OperationMode.PreCook
assert status.menu == "Fine Rice"
assert status.cooking_delayed == 75
assert status.delay_remaining == 75 - 60
assert status.keep_warm is False

# Total time should be 75min delay + 60min cooking time for "Fine rice"
assert status.ready_at == (
datetime.datetime.now() + datetime.timedelta(0, (75 + 60) * 60)
datetime.datetime.now() + datetime.timedelta(0, minutes=(15 + 60))
).replace(second=0, microsecond=0)
self.device.stop()

Expand All @@ -242,12 +242,12 @@ def test_case_2(self):
status = self.device.status()
assert status.mode == OperationMode.PreCook
assert status.menu == "Quick Rice"
assert status.cooking_delayed == 75
assert status.delay_remaining == 75 - 40
assert status.keep_warm is False

# Total time should be 75min delay + 40min cooking time for "Quick rice"
assert status.ready_at == (
datetime.datetime.now() + datetime.timedelta(0, (75 + 40) * 60)
datetime.datetime.now() + datetime.timedelta(0, minutes=(35 + 40))
).replace(second=0, microsecond=0)
self.device.stop()

Expand Down

0 comments on commit 86ce5bf

Please sign in to comment.