def test_serialize(self): status = AppStatus(AppState.FAILED) serialized = status.__repr__() deser_status_dict = json.loads(serialized) deser_status = AppStatus(**deser_status_dict) self.assertEqual(status.state, deser_status.state) self.assertEqual(status.msg, deser_status.msg) self.assertEqual(status.structured_error_msg, deser_status.structured_error_msg)
def test_serialize_embed_json(self): status = AppStatus(AppState.FAILED, structured_error_msg='{"message": "test error"}') serialized = status.__repr__() deser_status_dict = json.loads(serialized) scheduler_msg = deser_status_dict.pop("structured_error_msg") scheduler_msg_json = json.dumps(scheduler_msg) deser_status_dict["structured_error_msg"] = scheduler_msg_json deser_status = AppStatus(**deser_status_dict) self.assertEqual(status.state, deser_status.state) self.assertEqual(status.msg, deser_status.msg) self.assertEqual(status.structured_error_msg, deser_status.structured_error_msg)