Beispiel #1
0
 def test_get_success_message(self):
     view = SubmitSnippetTranslationView()
     view.object = self.en_snippet
     self.assertEqual(
         view.get_success_message(self.fr_locale),
         f"Successfully created French for translatable snippet 'TranslatableSnippet object ({self.en_snippet.id})'",
     )
Beispiel #2
0
 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/")
Beispiel #3
0
    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],
            ),
        )
Beispiel #4
0
    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)
Beispiel #5
0
 def test_get_title(self):
     view = SubmitSnippetTranslationView()
     view.object = self.en_snippet
     self.assertEqual(view.get_title(), "Translate translatable snippet")