Source

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

# -*- 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')
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.