<commit_before>import django

from django.test import TestCase
from django.contrib.auth.models import User
from django.core.urlresolvers import reverse

from mtr.utils.helpers import themed


class AdminMixinTest(TestCase):

    def setUp(self):
        self.password = '<PASSWORD>'
        self.user = User.objects.create_superuser(
            'admin', 'admin', password=self.password)
        self.client.login(username=self.user.username, password=self.password)

    def test_mixin_has_buttons_in_change_view(self):
        content = self.client.get(reverse('admin:app_person_changelist'))

        self.assertIn(
            themed('admin/change_list.html', True),
            map(lambda t: t.name, content.templates))

        self.assertContains(content, 'Export')
        self.assertContains(content, 'Import')

    def test_settings_export_import_modified_by_link(self):
        if django.get_version()[:2] > '1.6':
            link = reverse('admin:mtr_sync_settings_add')
        else:
            link = reverse('admin:sync_settings_add')

        content = self.client.get(
            '{}?action=export&model=app.person&filter='
            'security_level__gte%3D10%26surname__icont'
            'ains%3Ddas%26o%3D-3.2%26gender__exact%3DM'
            '%26fields=action_checkbox%2Cname%2Csurname%'
            '2Csecurity_level%2Cgender'.format(link))
        form = content.context['adminform'].form

        self.assertEqual(form.initial['action'], 0)
        self.assertEqual(form.initial['model'], 'app.person')
        self.assertEqual(form.initial['create_fields'], True)<commit_msg>Fixed django 1.6+ tests, sliced on 3 symbols<commit_after>import django

from django.test import TestCase
from django.contrib.auth.models import User
from django.core.urlresolvers import reverse

from mtr.utils.helpers import themed


class AdminMixinTest(TestCase):

    def setUp(self):
        self.password = '<PASSWORD>'
        self.user = User.objects.create_superuser(
            'admin', 'admin', password=self.password)
        self.client.login(username=self.user.username, password=self.password)

    def test_mixin_has_buttons_in_change_view(self):
        content = self.client.get(reverse('admin:app_person_changelist'))

        self.assertIn(
            themed('admin/change_list.html', True),
            map(lambda t: t.name, content.templates))

        self.assertContains(content, 'Export')
        self.assertContains(content, 'Import')

    def test_settings_export_import_modified_by_link(self):
        if django.get_version()[:3] > '1.6':
            link = reverse('admin:mtr_sync_settings_add')
        else:
            link = reverse('admin:sync_settings_add')

        content = self.client.get(
            '{}?action=export&model=app.person&filter='
            'security_level__gte%3D10%26surname__icont'
            'ains%3Ddas%26o%3D-3.2%26gender__exact%3DM'
            '%26fields=action_checkbox%2Cname%2Csurname%'
            '2Csecurity_level%2Cgender'.format(link))
        form = content.context['adminform'].form

        self.assertEqual(form.initial['action'], 0)
        self.assertEqual(form.initial['model'], 'app.person')
        self.assertEqual(form.initial['create_fields'], True)
{'fraction_non_alphanumeric': 0.12125887071891392, 'fraction_numerical': 0.01573588398642394, 'mean_word_length': 3.249017038007864, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6579490', 'n_tokens_mistral': 1007, 'n_tokens_neox': 972, 'n_words': 148}