Source

django-russian-admin / test_project / blog / tests.py

Full commit
# -*- coding: utf-8 -*-
from __future__ import absolute_import
from django_webtest import WebTest
from django.contrib.auth.models import User

class BaseTestCase(WebTest):
    extra_environ = {'HTTP_ACCEPT_LANGUAGE': 'ru'}

    def setUp(self):
        self.user = User.objects.create_superuser('vasia', 'vasia@example.com', '123')

    def admin_index(self):
        return self.app.get('/admin/', user=self.user)

    def assertHaveValue(self, response, selector, value):
        values = []
        for elem in response.lxml.cssselect(selector):
            values.append(elem.text_content())
        self.assertIn(value, values)


class AppNameLocalizeTest(BaseTestCase):

    def test_localized_blog(self):
        page = self.admin_index()
        self.assertHaveValue(page, '.dashboard-module-content h3', u'Блог')

    def test_app_list_correct_template(self):
        page = self.admin_index()
        self.assertTemplateUsed(page, 'russian_admin/dashboard/modules/app_list.html')