<commit_before>
from __future__ import absolute_import, unicode_literals

import datetime

from django.conf import settings
from django.core import management
from django.test import TestCase
from django.test.utils import override_settings
from django.utils.six import StringIO

from wagtail.contrib.wagtailsearchpromotions.models import SearchPromotion
from wagtail.tests.utils import WagtailTestUtils
from wagtail.wagtailsearch import models
from wagtail.wagtailsearch.utils import normalise_query_string


class TestHitCounter(TestCase):
    def test_no_hits(self):
        self.assertEqual(models.Query.get("Hello").hits, 0)

    def test_hit(self):
        # Add a hit
        models.Query.get("Hello").add_hit()

        # Test<commit_msg>Fix flake8 error<commit_after>from __future__ import absolute_import, unicode_literals

import datetime

from django.core import management
from django.test import TestCase
from django.utils.six import StringIO

from wagtail.contrib.wagtailsearchpromotions.models import SearchPromotion
from wagtail.tests.utils import WagtailTestUtils
from wagtail.wagtailsearch import models
from wagtail.wagtailsearch.utils import normalise_query_string


class TestHitCounter(TestCase):
    def test_no_hits(self):
        self.assertEqual(models.Query.get("Hello").hits, 0)

    def test_hit(self):
        # Add a hit
        models.Query.get("Hello").add_hit()

        # Test
{'fraction_non_alphanumeric': 0.06874557051736357, 'fraction_numerical': 0.002126151665485471, 'mean_word_length': 4.763265306122449, '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': '1449531', 'n_tokens_mistral': 418, 'n_tokens_neox': 405, 'n_words': 106}