def test_from_list(self): with self.assertRaises(ValueError): coerce_RenderError([{ "id": "my_id", "arguments": { "hello": "there" } }])
def test_from_dict_without_message(self): with self.assertRaises(ValueError): coerce_RenderError({ "id": "my_id", "arguments": { "hello": "there" } })
def test_from_string_with_quick_fix(self): self.assertEqual( coerce_RenderError( { "message": "error", "quickFixes": [ dict( text="button text", action="prependModule", args=["converttotext", {"colnames": ["A", "B"]}], ) ], } ), RenderError( TODO_i18n("error"), [ QuickFix( TODO_i18n("button text"), QuickFixAction.PrependStep( "converttotext", {"colnames": ["A", "B"]} ), ) ], ), )
def test_from_message_3tuple(self): self.assertEqual( coerce_RenderError(("my_id", { "hello": "there" }, "cjwmodule")), RenderError(I18nMessage("my_id", {"hello": "there"}, "cjwmodule")), )
def test_from_message_2tuple(self): self.assertEqual( coerce_RenderError(("my_id", { "hello": "there" })), RenderError(I18nMessage("my_id", {"hello": "there"}, None)), )
def test_from_none(self): with self.assertRaises(ValueError): coerce_RenderError(None)
def test_from_string(self): self.assertEqual( coerce_RenderError("some string"), RenderError(I18nMessage("TODO_i18n", {"text": "some string"}, None)), )
def test_from_dict_without_quick_fixes(self): self.assertEqual( coerce_RenderError({"message": ("my id", {})}), RenderError(I18nMessage("my id", {}, None), []), )