Skip to content

Commit

Permalink
Fix - Improved coverage for utils
Browse files Browse the repository at this point in the history
  • Loading branch information
davidusb-geek committed Jan 4, 2024
1 parent da94662 commit 69b7d10
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 2 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# Changelog

## [0.6.2] - Unreleased
### Improvement
- Added option to pass additional weight for battery usage
- Improved coverage
### Fix
- Updated optimization constraints to solve conflict for `set_def_constant` and `treat_def_as_semi_cont` cases

Expand Down
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
author = 'David HERNANDEZ'

# The full version, including alpha/beta/rc tags
release = '0.6.1'
release = '0.6.2'

# -- General configuration ---------------------------------------------------

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

setup(
name='emhass', # Required
version='0.6.1', # Required
version='0.6.2', # Required
description='An Energy Management System for Home Assistant', # Optional
long_description=long_description, # Optional
long_description_content_type='text/markdown', # Optional (see note above)
Expand Down
25 changes: 25 additions & 0 deletions tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,24 @@ def test_treat_runtimeparams(self):
runtimeparams.update({'def_total_hours':[5, 8, 10]})
runtimeparams.update({'treat_def_as_semi_cont':[True, True, True]})
runtimeparams.update({'set_def_constant':[False, False, False]})
runtimeparams.update({'weight_battery_discharge':2.0})
runtimeparams.update({'weight_battery_charge':2.0})
runtimeparams.update({'solcast_api_key':'yoursecretsolcastapikey'})
runtimeparams.update({'solcast_rooftop_id':'yourrooftopid'})
runtimeparams.update({'solar_forecast_kwp':5.0})
runtimeparams.update({'SOCtarget':0.4})
runtimeparams.update({'publish_prefix':'emhass_'})
runtimeparams.update({'custom_pv_forecast_id':'my_custom_pv_forecast_id'})
runtimeparams.update({'custom_load_forecast_id':'my_custom_load_forecast_id'})
runtimeparams.update({'custom_batt_forecast_id':'my_custom_batt_forecast_id'})
runtimeparams.update({'custom_batt_soc_forecast_id':'my_custom_batt_soc_forecast_id'})
runtimeparams.update({'custom_grid_forecast_id':'my_custom_grid_forecast_id'})
runtimeparams.update({'custom_cost_fun_id':'my_custom_cost_fun_id'})
runtimeparams.update({'custom_optim_status_id':'my_custom_optim_status_id'})
runtimeparams.update({'custom_unit_load_cost_id':'my_custom_unit_load_cost_id'})
runtimeparams.update({'custom_unit_prod_price_id':'my_custom_unit_prod_price_id'})
runtimeparams.update({'custom_deferrable_forecast_id':'my_custom_deferrable_forecast_id'})

runtimeparams_json = json.dumps(runtimeparams)
retrieve_hass_conf, optim_conf, plant_conf = utils.get_yaml_parse(
pathlib.Path(root+'/config_emhass.yaml'), use_secrets=True, params=self.params_json)
Expand All @@ -137,11 +150,23 @@ def test_treat_runtimeparams(self):
self.assertTrue(optim_conf['def_total_hours'] == [5, 8, 10])
self.assertTrue(optim_conf['treat_def_as_semi_cont'] == [True, True, True])
self.assertTrue(optim_conf['set_def_constant'] == [False, False, False])
self.assertTrue(optim_conf['weight_battery_discharge'] == 2.0)
self.assertTrue(optim_conf['weight_battery_charge'] == 2.0)
self.assertTrue(retrieve_hass_conf['solcast_api_key'] == 'yoursecretsolcastapikey')
self.assertTrue(retrieve_hass_conf['solcast_rooftop_id'] == 'yourrooftopid')
self.assertTrue(retrieve_hass_conf['solar_forecast_kwp'] == 5.0)
self.assertTrue(plant_conf['SOCtarget'] == 0.4)
self.assertTrue(params['passed_data']['publish_prefix'] == 'emhass_')
self.assertTrue(params['passed_data']['custom_pv_forecast_id'] == 'my_custom_pv_forecast_id')
self.assertTrue(params['passed_data']['custom_load_forecast_id'] == 'my_custom_load_forecast_id')
self.assertTrue(params['passed_data']['custom_batt_forecast_id'] == 'my_custom_battforecast_id')
self.assertTrue(params['passed_data']['custom_batt_soc_forecast_id'] == 'my_custom_batt_soc_forecast_id')
self.assertTrue(params['passed_data']['custom_grid_forecast_id'] == 'my_custom_grid_forecast_id')
self.assertTrue(params['passed_data']['custom_cost_fun_id'] == 'my_custom_cost_fun_id')
self.assertTrue(params['passed_data']['custom_optim_status_id'] == 'my_custom_optim_status_id')
self.assertTrue(params['passed_data']['custom_unit_load_cost_id'] == 'my_custom_unit_load_cost_id')
self.assertTrue(params['passed_data']['custom_unit_prod_price_id'] == 'my_custom_unit_prod_price_id')
self.assertTrue(params['passed_data']['custom_deferrable_forecast_id'] == 'my_custom_deferrable_forecast_id')

def test_treat_runtimeparams_failed(self):
params = TestCommandLineUtils.get_test_params()
Expand Down

0 comments on commit 69b7d10

Please sign in to comment.