def test_get_object(self): view = SubmitSnippetTranslationView() view.object = self.en_snippet view.kwargs = { "app_label": "some_app", "model_name": "some_model", "pk": 1, } with self.assertRaises(Http404): view.get_object() content_type = ContentType.objects.get_for_model(self.en_snippet) view.kwargs = { "app_label": content_type.app_label, "model_name": content_type.model, "pk": str(self.en_snippet.pk), } self.assertEqual(view.get_object(), self.en_snippet)
def test_get_success_url(self): view = SubmitSnippetTranslationView() view.object = self.en_snippet view.kwargs = { "app_label": "some_app", "model_name": "some_model", "pk": 99, } self.assertEqual(view.get_success_url(), "/admin/snippets/some_app/some_model/edit/99/")
def test_get_success_url_for_single_locale(self): view = SubmitSnippetTranslationView() view.object = self.en_snippet view.kwargs = { "app_label": "snippetstests", "model_name": "translatablesnippet", "pk": 99, } self.assertEqual( view.get_success_url(view.object), reverse( "wagtailsnippets_snippetstests_translatablesnippet:edit", args=[view.object.pk], ), )