<commit_before>from django.test import TestCase

# Create your tests here.<commit_msg>wrote profile tests for creation, __str__, deletion, is_active, not is_active<commit_after>from django.test import TestCase
from django.contrib.auth.models import User
import factory
from .models import ImagerProfile


class UserFactory(factory.Factory):
    class Meta:
        model = User

    username = factory.Sequence(lambda n: 'user{}'.format(n))
    email = factory.Sequence(lambda n: '<EMAIL>'.<EMAIL>(n))


class ProfileTestCase(TestCase):

    def setUp(self):
        self.user0 = UserFactory.build()
        self.user1 = UserFactory.build()
        self.user2 = UserFactory.build()

    def test_profile_created_on_user_save(self):
        self.assertEqual(ImagerProfile.objects.count(), 0)

        self.user0.save()

        self.assertEqual(ImagerProfile.objects.count(), 1)

    def test_profile___str___is_formatted_properly(self):
        self.user0.save()
        profile = ImagerProfile.objects.get(user=self.user0)

        self.assertEqual(
            "{}'s profile".format(self.user0.username),
            str(profile)
        )

    def test_profile_deleted_on_user_delete(self):
        self.user0.save()

        num_profiles = ImagerProfile.objects.count()
        self.user0 = User.objects.all()[0]

        self.user0.delete()

        self.assertEqual(
            num_profiles - 1,
            ImagerProfile.objects.count()
        )

    def test_profile_is_active_method(self):
        self.user0.save()
        self.profile0 = ImagerProfile.objects.all()[0]

        self.assertTrue(self.profile0.is_active)

    def test_profile_is_active_when_user_inactive(self):
        self.user0.is_active = False
        self.user0.save()

        self.profile0 = ImagerProfile.objects.all()[0]

        self.assertFalse(self.profile0.is_active)
{'fraction_non_alphanumeric': 0.10758472296933835, 'fraction_numerical': 0.01237224314147391, 'mean_word_length': 2.9157894736842107, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '1192286', 'n_tokens_mistral': 575, 'n_tokens_neox': 552, 'n_words': 96}