<commit_before>from django.test import TestCase

from django.contrib.auth.models import User
from django.contrib.contenttypes.models import ContentType

from .models import Demo

from ..models import Like
from ..utils import _allowed, get_config, per_model_perm_check


class UtilsTestCase(TestCase):

    def setUp(self):
        self.content_type = ContentType.objects.get(model="user")

    def test_allowed_model(self):
        self.assertTrue(_allowed(User))

    def test_allowed_str(self):
        self.assertTrue(_allowed("auth.User"))

    def test_allowed_other(self):
        self.assertFalse(_allowed(TestCase))

    def test_get_config(self):
        config = get_config(User)
        self.assertEquals(config["css_class_on"], "fa-heart")

    def test_per_model_perm_check(self):
        patrick = User.objects.create_user(username="patrick")
        check = per_model_perm_check(patrick, User)
        self.assertTrue(check)

    def test_per_model_perm_check_default(self):
        patrick = User.objects.create_user(username="patrick")
        check = per_model_perm_check(patrick, Demo)
        self.assertTrue(check)

<commit_msg>Fix flake8 issues<commit_after>from django.test import TestCase

from django.contrib.auth.models import User
from django.contrib.contenttypes.models import ContentType

from .models import Demo

from ..utils import _allowed, get_config, per_model_perm_check


class UtilsTestCase(TestCase):

    def setUp(self):
        self.content_type = ContentType.objects.get(model="user")

    def test_allowed_model(self):
        self.assertTrue(_allowed(User))

    def test_allowed_str(self):
        self.assertTrue(_allowed("auth.User"))

    def test_allowed_other(self):
        self.assertFalse(_allowed(TestCase))

    def test_get_config(self):
        config = get_config(User)
        self.assertEquals(config["css_class_on"], "fa-heart")

    def test_per_model_perm_check(self):
        patrick = User.objects.create_user(username="patrick")
        check = per_model_perm_check(patrick, User)
        self.assertTrue(check)

    def test_per_model_perm_check_default(self):
        patrick = User.objects.create_user(username="patrick")
        check = per_model_perm_check(patrick, Demo)
        self.assertTrue(check)

{'fraction_non_alphanumeric': 0.09758241758241758, 'fraction_numerical': 0.00043956043956043956, 'mean_word_length': 3.9264069264069263, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '4862011', 'n_tokens_mistral': 688, 'n_tokens_neox': 667, 'n_words': 124}