Skip to content

Commit ab85740

Browse files
committed
Testing demand-data-update and sql filtering functionality
1 parent 82b73c1 commit ab85740

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

tests/test_pyngeso.py

+37
Original file line numberDiff line numberDiff line change
@@ -90,3 +90,40 @@ def test_historic_generation_mix():
9090
assert "2009-01-01 00:00:00" in first_row
9191
assert len(headers_row) == len(first_row)
9292

93+
94+
@pytest.mark.vcr
95+
def test_demand_data_update():
96+
date_col = "SETTLEMENT_DATE"
97+
start_date = "2021-10-01"
98+
end_date = "2021-10-01"
99+
client = NgEso("demand-data-update")
100+
r = client.query(date_col=date_col, start_date=start_date, end_date=end_date)
101+
102+
assert isinstance(r, bytes)
103+
r_dict = json.loads(r)
104+
records = r_dict.get("result").get("records")
105+
assert isinstance(records, list)
106+
assert len(records) > 0
107+
unique_target_dates = set([record.get(date_col) for record in records])
108+
assert len(unique_target_dates) == 1
109+
assert len(records) == 48
110+
111+
112+
@pytest.mark.vcr
113+
def test_demand_data_update_with_filter():
114+
date_col = "SETTLEMENT_DATE"
115+
start_date = "2021-10-01"
116+
end_date = "2021-10-01"
117+
filter_condition = "\"FORECAST_ACTUAL_INDICATOR\" = 'A'"
118+
client = NgEso("demand-data-update")
119+
r = client.query(date_col=date_col, start_date=start_date, end_date=end_date,
120+
filters=[filter_condition])
121+
122+
assert isinstance(r, bytes)
123+
r_dict = json.loads(r)
124+
records = r_dict.get("result").get("records")
125+
assert isinstance(records, list)
126+
assert len(records) > 0
127+
unique_target_dates = set([record.get(date_col) for record in records])
128+
assert len(unique_target_dates) == 1
129+
assert len(records) == 48

0 commit comments

Comments
 (0)