def test_json_loadable(self): dict_ = self.helper_action.to_dict() tmp = json.dumps(obj=dict_, indent=4, sort_keys=True) res = HelperAction.from_dict(json.loads(tmp)) assert np.all(res.name_gen == self.helper_action.name_gen) assert np.all(res.name_load == self.helper_action.name_load) assert np.all(res.name_line == self.helper_action.name_line) assert np.all(res.sub_info == self.helper_action.sub_info) assert np.all(res.load_to_subid == self.helper_action.load_to_subid) assert np.all(res.gen_to_subid == self.helper_action.gen_to_subid) assert np.all( res.line_or_to_subid == self.helper_action.line_or_to_subid) assert np.all( res.line_ex_to_subid == self.helper_action.line_ex_to_subid) assert np.all( res.load_to_sub_pos == self.helper_action.load_to_sub_pos) assert np.all(res.gen_to_sub_pos == self.helper_action.gen_to_sub_pos) assert np.all( res.line_or_to_sub_pos == self.helper_action.line_or_to_sub_pos) assert np.all( res.line_ex_to_sub_pos == self.helper_action.line_ex_to_sub_pos) assert np.all( res.load_pos_topo_vect == self.helper_action.load_pos_topo_vect) assert np.all( res.gen_pos_topo_vect == self.helper_action.gen_pos_topo_vect) assert np.all(res.line_or_pos_topo_vect == self.helper_action.line_or_pos_topo_vect) assert np.all(res.line_ex_pos_topo_vect == self.helper_action.line_ex_pos_topo_vect) assert np.all(res.actionClass == self.helper_action.actionClass)
def test_from_dict(self): res = HelperAction.from_dict(self.res) assert np.all(res.name_gen == self.helper_action.name_gen) assert np.all(res.name_load == self.helper_action.name_load) assert np.all(res.name_line == self.helper_action.name_line) assert np.all(res.sub_info == self.helper_action.sub_info) assert np.all(res.load_to_subid == self.helper_action.load_to_subid) assert np.all(res.gen_to_subid == self.helper_action.gen_to_subid) assert np.all( res.line_or_to_subid == self.helper_action.line_or_to_subid) assert np.all( res.line_ex_to_subid == self.helper_action.line_ex_to_subid) assert np.all( res.load_to_sub_pos == self.helper_action.load_to_sub_pos) assert np.all(res.gen_to_sub_pos == self.helper_action.gen_to_sub_pos) assert np.all( res.line_or_to_sub_pos == self.helper_action.line_or_to_sub_pos) assert np.all( res.line_ex_to_sub_pos == self.helper_action.line_ex_to_sub_pos) assert np.all( res.load_pos_topo_vect == self.helper_action.load_pos_topo_vect) assert np.all( res.gen_pos_topo_vect == self.helper_action.gen_pos_topo_vect) assert np.all(res.line_or_pos_topo_vect == self.helper_action.line_or_pos_topo_vect) assert np.all(res.line_ex_pos_topo_vect == self.helper_action.line_ex_pos_topo_vect) # pdb.set_trace() assert np.all(res.actionClass == self.helper_action.actionClass)