Esempio n. 1
0
 def test_mpc_deserialiation(self) -> None:
     # this tests that old fields (and instances) can be deserialized
     with open(LIFT_MPC_PATH) as f:
         instance_json = f.read().strip()
     try:
         PCSMPCInstance.loads_schema(instance_json)
     except Exception as e:
         raise RuntimeError(ERR_MSG) from e
 def test_read_existing_instance(self):
     self.local_instance_repo._exist = MagicMock(return_value=True)
     data = self.mpc_instance.dumps_schema()
     path = TEST_BASE_DIR.joinpath(TEST_INSTANCE_ID)
     with patch("builtins.open", mock_open(read_data=data)) as mock_file:
         self.assertEqual(open(path).read().strip(), data)
         mpc_instance = PCSMPCInstance.loads_schema(
             self.local_instance_repo.read(TEST_INSTANCE_ID))
         self.assertEqual(self.mpc_instance, mpc_instance)
         mock_file.assert_called_with(path, "r")
 def read(self, instance_id: str) -> PCSMPCInstance:
     return PCSMPCInstance.loads_schema(self.repo.read(instance_id))