Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename charge_schedule helpers #1306

Merged
merged 8 commits into from
Aug 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 28 additions & 2 deletions src/renault_api/kamereon/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from __future__ import annotations

from typing import Any
from warnings import warn

from . import models

Expand All @@ -17,8 +18,22 @@
]


def update_schedule(schedule: models.ChargeSchedule, settings: dict[str, Any]) -> None:
"""Update schedule."""
def update_schedule(
schedule: models.ChargeSchedule, settings: dict[str, Any]
) -> None: # pragma: no cover
"""Update charge schedule."""
warn(
"This method is deprecated, please use update_charge_schedule.",
DeprecationWarning,
stacklevel=2,
)
update_charge_schedule(schedule, settings)


def update_charge_schedule(
schedule: models.ChargeSchedule, settings: dict[str, Any]
) -> None:
"""Update charge schedule."""
if "activated" in settings:
schedule.activated = settings["activated"]
for day in DAYS_OF_WEEK:
Expand All @@ -40,6 +55,17 @@ def update_schedule(schedule: models.ChargeSchedule, settings: dict[str, Any]) -

def create_schedule(
settings: dict[str, Any],
) -> models.ChargeSchedule: # pragma: no cover
warn(
"This method is deprecated, please use create_charge_schedule.",
DeprecationWarning,
stacklevel=2,
)
return create_charge_schedule(settings)


def create_charge_schedule(
settings: dict[str, Any],
) -> models.ChargeSchedule: # pragma: no cover
"""Update schedule."""
raise NotImplementedError
Expand Down
4 changes: 2 additions & 2 deletions src/renault_api/kamereon/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -639,9 +639,9 @@ def update(self, args: Dict[str, Any]) -> None:
self.schedules = []
for schedule in self.schedules:
if schedule.id == args["id"]: # pragma: no branch
helpers.update_schedule(schedule, args)
helpers.update_charge_schedule(schedule, args)
return
self.schedules.append(helpers.create_schedule(args)) # pragma: no cover
self.schedules.append(helpers.create_charge_schedule(args)) # pragma: no cover


@dataclass
Expand Down
Loading