-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathtest_small_office_osw.py
72 lines (53 loc) · 2 KB
/
test_small_office_osw.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
import datetime
import pytest
from alfalfa_client.alfalfa_client import AlfalfaClient
from tests.integration.conftest import prepare_model
@pytest.mark.integration
def test_python_environment():
zip_file_path = prepare_model('small_office')
alfalfa = AlfalfaClient(host='http://localhost')
model_id = alfalfa.submit(zip_file_path)
alfalfa.wait(model_id, "ready")
start_dt = datetime.datetime(2019, 1, 2, 0, 2, 0)
alfalfa.start(
model_id,
external_clock=False,
start_datetime=start_dt,
end_datetime=datetime.datetime(2019, 1, 3, 0, 0, 0),
timescale=1
)
alfalfa.wait(model_id, "running")
alfalfa.advance([model_id])
alfalfa.stop(model_id)
alfalfa.wait(model_id, "complete")
@pytest.mark.integration
def test_io_enable_disable():
zip_file_path = prepare_model('small_office')
alfalfa = AlfalfaClient(host='http://localhost')
site_id = alfalfa.submit(zip_file_path)
alfalfa.wait(site_id, "ready")
start_dt = datetime.datetime(2019, 1, 2, 0, 2, 0)
alfalfa.start(
site_id,
external_clock=True,
start_datetime=start_dt,
end_datetime=datetime.datetime(2019, 1, 3, 0, 0, 0),
timescale=1
)
inputs = alfalfa.get_inputs(site_id)
outputs = alfalfa.get_outputs(site_id)
assert "OfficeSmall HTGSETP_SCH_NO_OPTIMUM" in inputs
assert "OfficeSmall HTGSETP_SCH_NO_OPTIMUM" in outputs.keys()
inputs = {"OfficeSmall HTGSETP_SCH_NO_OPTIMUM": 0}
alfalfa.set_inputs(site_id, inputs)
for _ in range(5):
alfalfa.advance(site_id)
outputs = alfalfa.get_outputs(site_id)
assert outputs["OfficeSmall HTGSETP_SCH_NO_OPTIMUM"] == pytest.approx(0)
inputs = {"OfficeSmall HTGSETP_SCH_NO_OPTIMUM": None}
alfalfa.set_inputs(site_id, inputs)
alfalfa.advance(site_id)
outputs = alfalfa.get_outputs(site_id)
assert outputs["OfficeSmall HTGSETP_SCH_NO_OPTIMUM"] != pytest.approx(0)
alfalfa.stop(site_id)
alfalfa.wait(site_id, "complete")