Skip to content

Commit 7b5985a

Browse files
authored
Merge pull request #81 from knikolla/feature/ignore_hours
Extend outage list to support hours
2 parents d31b698 + 8411f44 commit 7b5985a

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

src/openstack_billing_db/billing.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,10 @@
1818
# until we have formalized how to store them in the nerc-rates repo.
1919
# Usage during these intervals is subtracted from the usage during
2020
# the month.
21-
OUTAGES_FOR_MONTH = {"2024-05": [("2024-05-22", "2024-05-29")]}
21+
OUTAGES_FOR_MONTH = {
22+
"2024-05": [("2024-05-22", "2024-05-29")],
23+
"2025-01": [("2025-01-14 14:00:00", "2025-01-15 17:00:00")],
24+
}
2225

2326

2427
@dataclass()

src/openstack_billing_db/tests/unit/test_billing.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ def test_instance_simple_runtime():
2323
datetime(year=2000, month=2, day=1, hour=0, minute=0, second=0),
2424
excluded_intervals=[
2525
["2000-01-07", "2000-01-08"],
26-
["2000-01-01", "2000-01-02"],
26+
["2000-01-01 09:00:00", "2000-01-01 10:00:00"],
2727
],
2828
)
29-
assert r.total_seconds_running == (15 * DAY) - (DAY * 2)
29+
assert r.total_seconds_running == (15 * DAY) - (DAY * 1) - (HOUR * 1)
3030
assert r.total_seconds_stopped == 0
3131

3232

src/openstack_billing_db/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22

33

44
def parse_time_from_string(time_str: str) -> datetime:
5-
return datetime.strptime(time_str, "%Y-%m-%d")
5+
return datetime.fromisoformat(time_str)

0 commit comments

Comments
 (0)