-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathtest_schedule_override.py
55 lines (42 loc) · 1.97 KB
/
test_schedule_override.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
from datetime import datetime
import pytest
from alfalfa_client.alfalfa_client import AlfalfaClient
from tests.integration.conftest import prepare_model
@pytest.mark.integration
def test_schedule_point_generation():
alfalfa = AlfalfaClient('http://localhost')
site_id = alfalfa.submit(prepare_model('schedule_model'))
inputs = alfalfa.get_inputs(site_id)
outputs = alfalfa.get_outputs(site_id)
assert "CONSTANT HEATING" in inputs, "Constant Schedule input not generated"
assert "COMPACT COOLING" in inputs, "Compact Schedule input not generated"
assert "YEAR HEATING" in inputs, "Year Schedule input not generated"
assert "RULESET COOLING" in inputs, "Rulseset Schedule input not generated"
assert "FIXEDINTERVAL HEATING" in inputs, "Fixed Interval Schedule input not generated"
assert "CONSTANT HEATING" in outputs.keys(), "Constant Schedule output not generated"
assert "COMPACT COOLING" in outputs.keys(), "Compact Schedule output not generated"
assert "YEAR HEATING" in outputs.keys(), "Year Schedule output not generated"
assert "RULESET COOLING" in outputs.keys(), "Rulseset Schedule output not generated"
assert "FIXEDINTERVAL HEATING" in outputs.keys(), "Fixed Interval Schedule output not generated"
@pytest.mark.integration
def test_schedule_override():
alfalfa = AlfalfaClient('http://localhost')
site_id = alfalfa.submit(prepare_model('schedule_model'))
alfalfa.start(
site_id,
external_clock=True,
start_datetime=datetime(2020, 1, 1, 0, 0),
end_datetime=datetime(2020, 1, 2, 0, 0)
)
inputs = {
"CONSTANT HEATING": 23.0,
"COMPACT COOLING": 15.0,
"YEAR HEATING": 23.0,
"RULESET COOLING": 15.0,
"FIXEDINTERVAL HEATING": 23.0
}
alfalfa.set_inputs(site_id, inputs)
alfalfa.advance(site_id)
outputs = alfalfa.get_outputs(site_id)
assert inputs.items() <= outputs.items(), "Schedule override failed"
alfalfa.stop(site_id)