Skip to content

Commit f328a51

Browse files
authoredNov 9, 2021
Merge pull request #1 from atsangarides/date_filter
date filter adjusted to include end_date
2 parents 1b9939c + c65eb9c commit f328a51

File tree

4 files changed

+8
-5
lines changed

4 files changed

+8
-5
lines changed
 

‎pyngeso/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
from .pyngeso import NgEso
22

3-
__version__ = '0.1.0'
3+
__version__ = '0.1.1'

‎pyngeso/pyngeso.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import logging
22
from typing import Optional, List
3-
from datetime import datetime
3+
from datetime import datetime, timedelta
44
import json
55
import re
66

@@ -91,6 +91,9 @@ def construct_date_range(
9191
raise ValueError("At least one of {start_date,end_date} should be provided")
9292
if all(dates_provided):
9393
self.validate_date_range(start_date, end_date)
94+
# add 1 day to end_date as casting as timestamp rounds it down to midnight
95+
if end_date:
96+
end_date = datetime.strptime(end_date, "%Y-%m-%d") + timedelta(days=1)
9497

9598
date_range_map = {
9699
(True, False): f"where \"{date_col}\" > '{start_date}'::timestamp",

‎pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "pyngeso"
3-
version = "0.1.0"
3+
version = "0.1.1"
44
description = "Simple python wrapper for the National Grid ESO Portal"
55
authors = ["atsangarides <andreas_tsangarides@hotmail.com>"]
66
license = "MIT"

‎tests/test_pyngeso.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def test_day_ahead_historic_forecast():
2020
assert isinstance(records, list)
2121
assert len(records) > 0
2222
unique_target_dates = set([record.get("TARGETDATE") for record in records])
23-
assert len(unique_target_dates) == 1
23+
assert len(unique_target_dates) == 2
2424

2525

2626
@pytest.mark.vcr
@@ -52,4 +52,4 @@ def test_2day_ahead_historic_forecast():
5252
assert isinstance(records, list)
5353
assert len(records) > 0
5454
unique_target_dates = set([record.get("TARGETDATE") for record in records])
55-
assert len(unique_target_dates) == 1
55+
assert len(unique_target_dates) == 2

0 commit comments

Comments
 (0)
Please sign in to comment.