コード例 #1
0
ファイル: tests.py プロジェクト: NotSqrt/django-parler
    def test_admin_change(self):
        self.client.login(**self.credentials)

        # careful, running tests from the example app with
        # python example/manage.py test article
        # will fail, because languages declared in the settings are
        # different, and not in the same order.
        self.assertEqual("nl", PARLER_LANGUAGES.get_first_language())

        translation.activate("en")
        resp = self.client.get(reverse("admin:article_article_change", args=[self.art_id]))
        self.assertEqual(200, resp.status_code)
        self.assertInContent("<h1>Change Article (Dutch)</h1>", resp)

        resp = self.client.get(reverse("admin:article_article_change", args=[self.art_id]), {"language": "en"})
        self.assertEqual(200, resp.status_code)
        self.assertInContent("<h1>Change Article (English)</h1>", resp)
        self.assertInContent('name="title" type="text" value="Cheese omelet"', resp)

        translation.activate("fr")
        resp = self.client.get(reverse("admin:article_article_change", args=[self.art_id]), {"language": "en"})
        self.assertEqual(200, resp.status_code)
        self.assertInContent("<h1>Modification de Article (Anglais)</h1>", resp)
        self.assertInContent('name="title" type="text" value="Cheese omelet"', resp)

        translation.activate("en")

        resp = self.client.get(reverse("admin:article_article_change", args=[self.art_id]), {"language": "nl"})
        self.assertEqual(200, resp.status_code)
        self.assertInContent("<h1>Change Article (Dutch)</h1>", resp)
        self.assertInContent('name="title" type="text" />', resp)
コード例 #2
0
ファイル: tests.py プロジェクト: django-parler/django-parler
    def test_admin_add(self):
        self.client.login(**self.credentials)

        # careful, running tests from the example app with
        # python example/manage.py test article
        # will fail, because languages declared in the settings are
        # different, and not in the same order.
        self.assertEqual("nl", PARLER_LANGUAGES.get_first_language())

        resp = self.client.get(reverse("admin:article_article_add"))
        self.assertEqual(200, resp.status_code)
        self.assertIn("<h1>Add Article (Dutch)</h1>", smart_str(resp.content))

        translation.activate("fr")
        resp = self.client.get(reverse("admin:article_article_add"))
        self.assertEqual(200, resp.status_code)

        if django.VERSION >= (3, 0):
            self.assertInContent("<h1>Ajout de Article (Hollandais)</h1>",
                                 resp)
        else:
            self.assertInContent("<h1>Ajout Article (Hollandais)</h1>", resp)

        translation.activate("en")

        resp = self.client.get(reverse("admin:article_article_add"),
                               {"language": "nl"})
        self.assertEqual(200, resp.status_code)
        self.assertInContent("<h1>Add Article (Dutch)</h1>", resp)
コード例 #3
0
    def test_admin_change(self):
        self.client.login(**self.credentials)

        # careful, running tests from the example app with
        # python example/manage.py test article
        # will fail, because languages declared in the settings are
        # different, and not in the same order.
        self.assertEqual('nl', PARLER_LANGUAGES.get_first_language())

        translation.activate('en')
        resp = self.client.get(reverse('admin:article_article_change', args=[self.art_id]))
        self.assertEqual(200, resp.status_code)
        self.assertInContent('<h1>Change Article (Dutch)</h1>', resp)

        resp = self.client.get(reverse('admin:article_article_change', args=[self.art_id]), {"language": "en"})
        self.assertEqual(200, resp.status_code)
        self.assertInContent('<h1>Change Article (English)</h1>', resp)
        self.assertHTMLInContent('<input name="title" type="text" value="Cheese omelet">', resp)

        translation.activate('fr')
        resp = self.client.get(reverse('admin:article_article_change', args=[self.art_id]), {"language": "en"})
        self.assertEqual(200, resp.status_code)
        self.assertInContent('<h1>Modification de Article (Anglais)</h1>', resp)
        self.assertHTMLInContent('<input name="title" type="text" value="Cheese omelet">', resp)

        translation.activate('en')

        resp = self.client.get(reverse('admin:article_article_change', args=[self.art_id]), {"language": "nl"})
        self.assertEqual(200, resp.status_code)
        self.assertInContent('<h1>Change Article (Dutch)</h1>', resp)
        self.assertHTMLInContent('<input name="title" type="text">', resp)
コード例 #4
0
    def test_admin_add(self):
        self.client.login(**self.credentials)

        # careful, running tests from the example app with
        # python example/manage.py test article
        # will fail, because languages declared in the settings are
        # different, and not in the same order.
        self.assertEqual('nl', PARLER_LANGUAGES.get_first_language())

        resp = self.client.get(reverse('admin:article_article_add'))
        self.assertEqual(200, resp.status_code)
        self.assertIn('<h1>Add Article (Dutch)</h1>',
                      encoding.smart_text(resp.content))

        translation.activate('fr')
        resp = self.client.get(reverse('admin:article_article_add'))
        self.assertEqual(200, resp.status_code)
        self.assertInContent('<h1>Ajout Article (Hollandais)</h1>', resp)

        translation.activate('en')

        resp = self.client.get(reverse('admin:article_article_add'),
                               {"language": "nl"})
        self.assertEqual(200, resp.status_code)
        self.assertInContent('<h1>Add Article (Dutch)</h1>', resp)
コード例 #5
0
ファイル: tests.py プロジェクト: NotSqrt/django-parler
    def test_admin_add(self):
        self.client.login(**self.credentials)

        # careful, running tests from the example app with
        # python example/manage.py test article
        # will fail, because languages declared in the settings are
        # different, and not in the same order.
        self.assertEqual("nl", PARLER_LANGUAGES.get_first_language())

        resp = self.client.get(reverse("admin:article_article_add"))
        self.assertEqual(200, resp.status_code)
        self.assertIn("<h1>Add Article (Dutch)</h1>", encoding.smart_text(resp.content))

        translation.activate("fr")
        resp = self.client.get(reverse("admin:article_article_add"))
        self.assertEqual(200, resp.status_code)
        self.assertInContent("<h1>Ajout Article (Hollandais)</h1>", resp)

        translation.activate("en")

        resp = self.client.get(reverse("admin:article_article_add"), {"language": "nl"})
        self.assertEqual(200, resp.status_code)
        self.assertInContent("<h1>Add Article (Dutch)</h1>", resp)