Skip to content

Commit

Permalink
Change default charge.energy_cost from None to 0
Browse files Browse the repository at this point in the history
  • Loading branch information
mattrayner committed Nov 12, 2022
1 parent 3d24b80 commit 13fcee9
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion podpointclient/charge.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def __init__(self, data: Dict[str, Any]):
self.duration: int = data.get('duration', 0)
self.starts_at: datetime = lazy_convert_to_datetime(data.get('starts_at', None))
self.ends_at: datetime = lazy_convert_to_datetime(data.get('ends_at', None))
self.energy_cost: int = data.get('energy_cost', None)
self.energy_cost: int = data.get('energy_cost', 0)

charging_duration_data = data.get('charging_duration', {})
self.charging_duration = self.ChargingDuration(
Expand Down
2 changes: 1 addition & 1 deletion podpointclient/version.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
"""Version for the podpointclient library"""

__version__ = "0.3.0-beta6"
__version__ = "0.3.0-beta7"
3 changes: 3 additions & 0 deletions tests/test_charge.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ def test_charge():
ongoing_charge_data = charges_data[0]
completed_charge_data = charges_data[1]

empty_charge = Charge(data={})
assert empty_charge.energy_cost == 0

ongoing_charge = Charge(data=ongoing_charge_data)
assert 1 == ongoing_charge.id
assert 12.2 == ongoing_charge.kwh_used
Expand Down

0 comments on commit 13fcee9

Please sign in to comment.