def test_parses_cached_devices(self): """it should parse cached devices """ config_file = f'{os.getcwd()}/tests/fixtures/config_cache.yaml' cache_folder = f'{os.getcwd()}/tests/fixtures' mec = myenergi.Client(config_file, cache_folder) mec.populate_devices() self.assertListEqual(mec.list_devices(), ['Zappi[12345678]', 'Harvi[12345678]'])
def test_config_parses(self): """it should parse config correctly""" mec = myenergi.Client( f'{os.getcwd()}/tests/fixtures/config_cache.yaml') expected_config = { 'hub_serial': '12345678', 'hub_password': '******', 'use_cache': True } self.assertDictEqual(mec.config, expected_config)
def test_fails_for_bad_config(self): """it should fail for bad config""" config_file = f'{os.getcwd()}/tests/fixtures/config_bad.yaml' with self.assertRaisesRegex(Exception, 'missing from config'): myenergi.Client(config_file)
import sys from pprint import pprint sys.path.append('.') import myenergi mec = myenergi.Client() mec.populate_devices() for device in mec.devices: if isinstance(device, (myenergi.Zappi)): pprint(device.name) pprint(device.get_boost_times()) pprint(device.translated_attributes)