def test_allow_override(self): def migrate_params(params): self.assertEqual(params, {"x": "y"}) return {"y": "z"} with patch.object(module, "migrate_params", migrate_params): self.assertEqual( module.migrate_params_thrift( {"x": ttypes.Json(string_value="y")}), ttypes.MigrateParamsResult( {"y": ttypes.Json(string_value="z")}), )
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")})), ) ], ), )
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", {"x": ttypes.Json(string_value="y")})), )
def test_quick_fix_from_thrift(self): self.assertEqual( types.thrift_quick_fix_to_arrow( ttypes.QuickFix( ttypes.I18nMessage("click", {}, None), ttypes.QuickFixAction( prepend_step=ttypes.PrependStepQuickFixAction( "filter", {"x": ttypes.Json(string_value="y")})), )), types.QuickFix( I18nMessage("click", {}, None), types.QuickFixAction.PrependStep("filter", {"x": "y"}), ), )
def test_default_returns_params(self): self.assertEqual( module.migrate_params_thrift({"x": ttypes.Json(string_value="y")}), ttypes.MigrateParamsResult({"x": ttypes.Json(string_value="y")}), )
def test_pydict_to_thrift_json_object(self): self.assertEqual( types.pydict_to_thrift_json_object({ "str": "s", "int": 2, "float": 1.2, "null": None, "bool": False, "arrayofobjects": [{ "A": "a", "B": "b" }, { "C": "c", "D": "d" }], }), { "str": ttypes.Json(string_value="s"), "int": ttypes.Json(int64_value=2), "float": ttypes.Json(number_value=1.2), "null": ttypes.Json(), "bool": ttypes.Json(boolean_value=False), "arrayofobjects": ttypes.Json(array_value=[ ttypes.Json( object_value={ "A": ttypes.Json(string_value="a"), "B": ttypes.Json(string_value="b"), }), ttypes.Json( object_value={ "C": ttypes.Json(string_value="c"), "D": ttypes.Json(string_value="d"), }), ]), }, )