def test_station_config_can_be_loaded_from_snapshot(example_station): assert station_config_has_been_loaded(example_station) # ensure that we can correctly dump config which is a subclass of UserDict configdump = json.dumps(example_station.config, cls=NumpyJSONEncoder) # as this is now a regular dict we can load it back loaded_config = json.loads(configdump) # now lets ensure that we can recreate the # station from the loaded config # first we need to get a yaml repr of the data yaml = YAML() with StringIO() as output: yaml.dump(loaded_config, output) yaml_repr = output.getvalue() # which we can then reload into the station new_station = Station(default=False) new_station.load_config(yaml_repr) assert example_station.config == new_station.config
def station_from_config_str(config: str) -> Station: st = Station(config_file=None) st.load_config(config) return st