<commit_before># coding: utf-8
from .. import consts
from django.contrib.auth.models import User
from django.core.urlresolvers import reverse

from django.test import TestCase
from division_perm import models
from division_perm.tests.helpers import ListTestMixin, DetailTestMixin


class BaseFuncTest(TestCase):
    view_path = None

    def setUp(self):
        self.user = User.objects.create_user(username='tester', email='<EMAIL>', password='<PASSWORD>')
        self.empl = models.Employee.objects.create(user=self.user, last_name='test', first_name='test', middle_name='test')
        func_edit = models.Func.objects.create(code=consts.SYS_EDIT_FUNC, name='test_edit', level=5)
        self.func_read = models.Func.objects.create(code=consts.SYS_READ_FUNC, name='test_read', level=0)
        self.division = models.Division.objects.create(name='Tech Support')
        self.division.employees.add(self.empl)
        role_read = models.Role.objects.create(name='manger', code=self.func_read.code, level=9, division=self.division)
        self.empl.roles.add(role_read)
        self.client.login(username=self.user.username, password='<PASSWORD>')

    def get_url(self):
        url = reverse(self.view_path)
        return url


class ListFuncTest(BaseFuncTest, ListTestMixin):
    view_path = 'perm_func_list'
    success_url = reverse('perm_func_list') + '?sort=code'
    model_access = models.Func


class DetailFuncTest(BaseFuncTest, DetailTestMixin):
    view_path = 'perm_func_detail'

    def get_url(self):
        url = reverse(self.view_path, args=[self.func_read.id])
        return url

    def get_instance(self):
        return self.func_read<commit_msg>#5 - рефакторинг в связи с появлением base<commit_after># coding: utf-8
from .. import consts

from division_perm.tests.base import BaseTest
from division_perm.tests.helpers import *


class ListFuncTest(FuncAccessTestMixin, ListTestMixin, BaseTest):
    view_path = 'perm_func_list'
    success_url = reverse('perm_func_list') + '?sort=code'
    model_access = models.Func
    func_code = consts.SYS_READ_FUNC


class DetailFuncTest(FuncAccessTestMixin, DetailTestMixin, BaseTest):
    view_path = 'perm_func_detail'
    func_code = consts.SYS_READ_FUNC

    def get_url(self):
        url = reverse(self.view_path, args=[self.get_instance().id])
        return url

    def get_instance(self):
        func_read = models.Func.objects.get(code=consts.SYS_READ_FUNC)
        return func_read
{'fraction_non_alphanumeric': 0.10957792207792208, 'fraction_numerical': 0.002435064935064935, 'mean_word_length': 4.178571428571429, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 6, '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': '5979465', 'n_tokens_mistral': 805, 'n_tokens_neox': 795, 'n_words': 146}