Skip to content

Commit

Permalink
test: Updated go rate tests to be in bst
Browse files Browse the repository at this point in the history
  • Loading branch information
BottlecapDave committed Oct 20, 2022
1 parent 3f6a75e commit 579ff09
Showing 1 changed file with 50 additions and 25 deletions.
75 changes: 50 additions & 25 deletions tests/unit/test_rates_to_thirty_minute_increments.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,31 +4,56 @@
from homeassistant.util.dt import (as_utc, parse_datetime)
from custom_components.octopus_energy.utils import rates_to_thirty_minute_increments

# Based on E-1R-GO-22-07-05-D
@pytest.mark.asyncio
async def test_go_rates():
async def test_go_rates_bst():
# Act
period_from = as_utc(parse_datetime("2022-10-09T00:00Z"))
period_to = as_utc(parse_datetime("2022-10-10T00:00Z"))
period_from = as_utc(parse_datetime("2022-10-09T00:00+01:00"))
period_to = as_utc(parse_datetime("2022-10-10T00:00+01:00"))
tariff_code = "test_tariff"
rates = [
{
"value_exc_vat": 38.217,
"value_inc_vat": 40.12785,
"valid_from": "2022-10-08T04:30:00Z",
"valid_to": "2022-10-09T00:30:00Z"
},
{
"value_exc_vat": 7.142,
"value_inc_vat": 7.4991,
"valid_from": "2022-10-09T00:30:00Z",
"valid_to": "2022-10-09T04:30:00Z"
},
{
"value_exc_vat": 38.217,
"value_inc_vat": 40.12785,
"valid_from": "2022-10-09T04:30:00Z",
"valid_to": "2022-10-10T00:30:00Z"
}
"value_exc_vat": 40.274,
"value_inc_vat": 42.2877,
"valid_from": "2022-10-10T03:30:00Z",
"valid_to": "2022-10-10T23:30:00Z"
},
{
"value_exc_vat": 7.142,
"value_inc_vat": 7.4991,
"valid_from": "2022-10-09T23:30:00Z",
"valid_to": "2022-10-10T03:30:00Z"
},
{
"value_exc_vat": 40.274,
"value_inc_vat": 42.2877,
"valid_from": "2022-10-09T03:30:00Z",
"valid_to": "2022-10-09T23:30:00Z"
},
{
"value_exc_vat": 7.142,
"value_inc_vat": 7.4991,
"valid_from": "2022-10-08T23:30:00Z",
"valid_to": "2022-10-09T03:30:00Z"
},
{
"value_exc_vat": 40.274,
"value_inc_vat": 42.2877,
"valid_from": "2022-10-08T03:30:00Z",
"valid_to": "2022-10-08T23:30:00Z"
},
{
"value_exc_vat": 7.142,
"value_inc_vat": 7.4991,
"valid_from": "2022-10-07T23:30:00Z",
"valid_to": "2022-10-08T03:30:00Z"
},
{
"value_exc_vat": 40.274,
"value_inc_vat": 42.2877,
"valid_from": "2022-10-07T03:30:00Z",
"valid_to": "2022-10-07T23:30:00Z"
}
]

result = rates_to_thirty_minute_increments(
Expand All @@ -44,17 +69,17 @@ async def test_go_rates():
assert result != None
assert len(result) == 48

start_time = as_utc(parse_datetime("2022-10-09T00:00Z"))
start_time = as_utc(parse_datetime("2022-10-09T00:00+01:00"))
for index in range(48):
end_time = start_time + timedelta(minutes=30)
assert result[index]["valid_from"] == start_time
assert result[index]["valid_to"] == end_time

rates_index = 2
rates_index = 6
if index < 1:
rates_index = 0
rates_index = 4
elif index < 9:
rates_index = 1
rates_index = 5

assert result[index]["value_inc_vat"] == rates[rates_index]["value_inc_vat"]
assert result[index]["value_exc_vat"] == rates[rates_index]["value_exc_vat"]
Expand All @@ -63,4 +88,4 @@ async def test_go_rates():

start_time = end_time

assert start_time == as_utc(parse_datetime("2022-10-10T00:00Z"))
assert start_time == as_utc(parse_datetime("2022-10-10T00:00+01:00"))

0 comments on commit 579ff09

Please sign in to comment.