Beispiel #1
0
 def test_default_returns_params(self):
     thrift_result = module.migrate_params_thrift(
         RawParams({
             "A": [1],
             "B": "x"
         }).to_thrift())
     result = RawParams.from_thrift(thrift_result).params
     self.assertEqual(result, {"A": [1], "B": "x"})
Beispiel #2
0
 def migrate_params(self, compiled_module: CompiledModule,
                    params: Dict[str, Any]) -> None:
     request = RawParams(params).to_thrift()
     with _chroot_dir_context() as chroot:
         response = self._run_in_child(
             chroot=chroot,
             chroot_paths=DATA_PATHS,
             compiled_module=compiled_module,
             timeout=self.migrate_params_timeout,
             result=ttypes.RawParams(),
             function="migrate_params_thrift",
             args=[request],
         )
     return RawParams.from_thrift(response).params
Beispiel #3
0
 def migrate_params(
     self, compiled_module: CompiledModule, params: Dict[str, Any]
 ) -> None:
     """
     Call a module's migrate_params().
     """
     request = RawParams(params).to_thrift()
     response = self._run_in_child(
         chroot_dir=READONLY_CHROOT_DIR,
         network_config=None,
         compiled_module=compiled_module,
         timeout=self.migrate_params_timeout,
         result=ttypes.RawParams(),
         function="migrate_params_thrift",
         args=[request],
     )
     return RawParams.from_thrift(response).params
Beispiel #4
0
 def _test(self, fn, params={}):
     with patch.object(module, "migrate_params", fn):
         thrift_result = module.migrate_params_thrift(RawParams(params).to_thrift())
         return RawParams.from_thrift(thrift_result).params