def test_render_error_to_thrift(self):
     self.assertEqual(
         types.RenderError(
             types.I18nMessage("foo", {}),
             [
                 types.QuickFix(
                     types.I18nMessage("click"),
                     types.QuickFixAction.PrependStep("filter", {"x": "y"}),
                 )
             ],
         ).to_thrift(),
         ttypes.RenderError(
             ttypes.I18nMessage("foo", {}, ttypes.I18nMessageSource()),
             [
                 ttypes.QuickFix(
                     ttypes.I18nMessage("click", {}, ttypes.I18nMessageSource()),
                     ttypes.QuickFixAction(
                         prepend_step=ttypes.PrependStepQuickFixAction(
                             "filter", ttypes.RawParams('{"x":"y"}')
                         )
                     ),
                 )
             ],
         ),
     )
示例#2
0
 def test_prepend_step_quick_fix_action_to_thrift(self):
     self.assertEqual(
         types.arrow_quick_fix_action_to_thrift(
             types.QuickFixAction.PrependStep("filter", {"x": "y"})),
         ttypes.QuickFixAction(
             prepend_step=ttypes.PrependStepQuickFixAction(
                 "filter", ttypes.RawParams('{"x":"y"}'))),
     )
示例#3
0
 def test_raw_params_to_thrift(self):
     self.assertEqual(
         types.RawParams({
             "A": "x",
             "B": [1, 2]
         }).to_thrift(),
         ttypes.RawParams('{"A":"x","B":[1,2]}'),
     )
示例#4
0
 def test_raw_params_from_thrift(self):
     self.assertEqual(
         types.thrift_raw_params_to_arrow(
             ttypes.RawParams('{"A":"x","B":[1,2]}')),
         types.RawParams({
             "A": "x",
             "B": [1, 2]
         }),
     )
示例#5
0
 def test_quick_fix_to_thrift(self):
     self.assertEqual(
         types.QuickFix(
             types.I18nMessage("click"),
             types.QuickFixAction.PrependStep("filter", {"x": "y"}),
         ).to_thrift(),
         ttypes.QuickFix(
             ttypes.I18nMessage("click", {}),
             ttypes.QuickFixAction(
                 prepend_step=ttypes.PrependStepQuickFixAction(
                     "filter", ttypes.RawParams('{"x":"y"}'))),
         ),
     )
示例#6
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
示例#7
0
 def migrate_params(self, compiled_module: CompiledModule,
                    params: Dict[str, Any]) -> None:
     """Call a module's migrate_params()."""
     request = arrow_raw_params_to_thrift(RawParams(params))
     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 thrift_raw_params_to_arrow(response).params