Skip to content

Commit

Permalink
Merge pull request #566 from ibpsa/issue546_sceFlag
Browse files Browse the repository at this point in the history
Closes #546
  • Loading branch information
dhblum authored Aug 28, 2023
2 parents db0f10e + fa5bfed commit c3e0192
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 1 deletion.
1 change: 1 addition & 0 deletions releasenotes.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Released on xx/xx/xxxx.
- In unit test checking fetching of single forecast variable, specify specific forecast point to check for each test case. This is for [#529](https://github.com/ibpsa/project1-boptest/issues/529).
- Update ``KPI_Calculator.get_computational_time_ratio`` to return ``None`` if no simulation steps have been processed. This is for [#540](https://github.com/ibpsa/project1-boptest/issues/540).
- Add ``forecastParameters`` to dashboard submission with empty dictionary and update url for submitting dashboard results. This is for [#548](https://github.com/ibpsa/project1-boptest/issues/548).
- Fix so that results can be submitted to dashboard if sitting at end of scenario time period instead of needing to try to advance one step past. This is for [#546](https://github.com/ibpsa/project1-boptest/issues/546).

**The following changes are backwards-compatible, but might change benchmark results:**

Expand Down
4 changes: 3 additions & 1 deletion testcase.py
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,9 @@ def advance(self, u):
message = alert_message
# Advance start time
self.start_time = self.final_time
# Check if scenario is over
if self.start_time >= self.end_time:
self.scenario_end = True
# Log and return
logging.info(message)
return status, message, payload
Expand All @@ -357,7 +360,6 @@ def advance(self, u):
return status, message, payload
else:
# Simulation at end time
self.scenario_end = True
payload = dict()
message = "End of test case scenario time period reached."
logging.info(message)
Expand Down
31 changes: 31 additions & 0 deletions testing/test_bestest_air.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import unittest
import os
import utilities
import requests

class Run(unittest.TestCase, utilities.partialTestTimePeriod):
'''Tests the example test case.
Expand Down Expand Up @@ -43,6 +44,36 @@ def test_typical_cool_day(self):
def test_mix_day(self):
self.run_time_period('mix_day')

def test_scenario_flag(self):
'''Ensures the scenario flag is set properly.
Parameters
----------
None
Returns
-------
None
'''

length = 86400*14
# Get current step
step_current = requests.get('{0}/step'.format(self.url)).json()['payload']
# Initialize test case scenario
requests.put('{0}/scenario'.format(self.url), json={'time_period':'peak_heat_day'})
# Set simulation step
requests.put('{0}/step'.format(self.url), json={'step':length})
# Simulation Loop
requests.post('{0}/advance'.format(self.url))
# Try submit results to dashboard
status = requests.post("{0}/submit".format(self.url), json={"api_key": 'valid_key',
"unit_test":"True"}).json()['status']
# Check result
self.assertEqual(status,200)
# Return scenario and step to original
requests.put('{0}/step'.format(self.url), json={'step':step_current})

class API(unittest.TestCase, utilities.partialTestAPI):
'''Tests the api for testcase.
Expand Down

0 comments on commit c3e0192

Please sign in to comment.