コード例 #1
0
 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_render_error_to_thrift(self):
     self.assertEqual(
         types.arrow_render_error_to_thrift(
             types.RenderError(
                 I18nMessage("foo", {}, None),
                 [
                     types.QuickFix(
                         I18nMessage("click", {}, None),
                         types.QuickFixAction.PrependStep(
                             "filter", {"x": "y"}),
                     )
                 ],
             )),
         ttypes.RenderError(
             ttypes.I18nMessage("foo", {}, None),
             [
                 ttypes.QuickFix(
                     ttypes.I18nMessage("click", {}, None),
                     ttypes.QuickFixAction(
                         prepend_step=ttypes.PrependStepQuickFixAction(
                             "filter", {"x": ttypes.Json(
                                 string_value="y")})),
                 )
             ],
         ),
     )
コード例 #3
0
 def test_fetch_result_from_thrift_happy_path(self):
     with tempfile.NamedTemporaryFile(dir=str(self.basedir)) as tf:
         self.assertEqual(
             types.thrift_fetch_result_to_arrow(
                 ttypes.FetchResult(
                     Path(tf.name).name,
                     [ttypes.RenderError(ttypes.I18nMessage("hi", {}), [])],
                 ),
                 self.basedir,
             ),
             types.FetchResult(Path(
                 tf.name), [types.RenderError(types.I18nMessage("hi"))]),
         )
コード例 #4
0
 def test_default_render_returns_fetch_result(self):
     # Functionality used by libraryofcongress
     with ExitStack() as ctx:
         input_arrow_table = ctx.enter_context(
             arrow_table_context({"A": [1]}, dir=self.basedir)
         )
         parquet_filename = Path(
             ctx.enter_context(parquet_file({"A": [2]}, dir=self.basedir)).name
         ).name
         out_filename = ctx.enter_context(tempfile_context(dir=self.basedir)).name
         thrift_result = module.render_thrift(
             ttypes.RenderRequest(
                 str(self.basedir),
                 arrow_arrow_table_to_thrift(input_arrow_table),
                 {},  # params
                 ttypes.Tab("tab-1", "Tab 1"),
                 ttypes.FetchResult(
                     parquet_filename,
                     [
                         ttypes.RenderError(
                             ttypes.I18nMessage(
                                 "TODO_i18n",
                                 {
                                     "text": ttypes.I18nArgument(
                                         string_value="A warning"
                                     )
                                 },
                             ),
                             [],
                         )
                     ],
                 ),
                 out_filename,
             )
         )
         result = thrift_render_result_to_arrow(thrift_result, self.basedir)
         assert_render_result_equals(
             result,
             RenderResult(
                 arrow_table({"A": [2]}),
                 [RenderError(I18nMessage.TODO_i18n("A warning"))],
             ),
         )