<commit_before>from django.test import TestCase
from search.models import BookCategory, Book, DatesMixin


class ModelsTestCase(TestCase):
    """Test suite for the models."""

    def setUp(self):
        """Setup variables."""
        self.title = "Harry Porter and the Goblet of Fire"
        self.category_name = "Adventure"
        self.category = BookCategory(name=self.category_name)
        self.category.save()
        self.book = Book(title=self.title, category=self.category)
        self.dates = DatesMixin()

    def test_category_creation(self):
        """Test whether a book category can be created."""
        self.old_count = BookCategory.objects.count()
        self.new_cat = BookCategory(name="non-fiction")
        self.new_cat.save()
        self.new_count = BookCategory.objects.count()
        self.assertIsInstance(self.category, BookCategory)
        self.assertNotEquals(self.old_count, self.new_count)

    def test_book_creation(self):
        """Test whether a book can be created."""
        self.old_count = Book.objects.count()
        self.book.save()
        self.new_count = Book.objects.count()
        self.assertNotEquals(self.old_count, self.new_count)
        self.assertIsInstance(self.book, Book)
        self.assertEquals(self.book.title, self.title)

    def test_date_mixin(self):
        """Test the date mixin works."""
        self.assertIsInstance(self.dates, DatesMixin)<commit_msg>(chore) test for return string in models<commit_after>from django.test import TestCase
from search.models import BookCategory, Book, DatesMixin


class ModelsTestCase(TestCase):
    """Test suite for the models."""

    def setUp(self):
        """Setup variables."""
        self.title = "Harry Porter and the Goblet of Fire"
        self.category_name = "Adventure"
        self.category = BookCategory(name=self.category_name)
        self.category.save()
        self.book = Book(title=self.title, category=self.category)
        self.dates = DatesMixin()

    def test_category_creation(self):
        """Test whether a book category can be created."""
        self.old_count = BookCategory.objects.count()
        self.new_cat = BookCategory(name="non-fiction")
        self.new_cat.save()
        self.new_count = BookCategory.objects.count()
        self.assertIsInstance(self.category, BookCategory)
        self.assertNotEquals(self.old_count, self.new_count)

    def test_book_creation(self):
        """Test whether a book can be created."""
        self.old_count = Book.objects.count()
        self.book.save()
        self.new_count = Book.objects.count()
        self.assertNotEquals(self.old_count, self.new_count)
        self.assertIsInstance(self.book, Book)
        self.assertEquals(self.book.title, self.title)

    def test_date_mixin(self):
        """Test the date mixin works."""
        self.assertIsInstance(self.dates, DatesMixin)

    def test_models_return_human_readable_representation(self):
        """Test the models instances return a string."""
        self.assertEqual(str(self.category), self.category_name)
        self.assertEqual(str(self.book), self.title)
{'fraction_non_alphanumeric': 0.11228070175438597, 'fraction_numerical': 0.0, 'mean_word_length': 3.0516795865633073, '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': '4198765', 'n_tokens_mistral': 914, 'n_tokens_neox': 885, 'n_words': 196}