<commit_before>from __future__ import unicode_literals

from django.contrib.auth.models import User
from django.db.transaction import TransactionManagementError
from django.test import TestCase

from estmator_project.factories import UserFactory
from .models import UserProfile


class UserProfileTestCase(TestCase):
    """Test behavior of user profile"""
    def setUp(self):
        pass

    def test_profile_is_created_when_user_is_saved(self):
        self.assertEqual(len(UserProfile.objects.all()), 0)
        user = UserFactory.create()
        user.save()
        self.assertTrue(UserProfile.objects.count() == 1)

    def test_delete_profile_deletes_user(self):
        user = UserFactory.create()
        user.save()
        self.assertEqual(len(UserProfile.objects.all()), 1)
        user.profile.delete()
        self.assertEqual(len(User.objects.all()), 0)

    def test_profile_str_is_user_username(self):
        user = UserFactory.create(username='user1')
        user.save()
        profile = UserProfile.objects.get(user__username='user1')
        self.assertEqual(str(profile),
                         user.get_full_name() or profile.user.username)

    def test_active_user_is_active_property(self):
        user = UserFactory.create(username='user1')
        user.save()
        self.assertTrue(user.is_active)

    # def test_cell_phone_char_limit(self):
    #     user = UserFactory.create()
    #     profile = user.profile
    #     with self.assertRaises(TransactionManagementError):
    #         profile.cell = '1234567890123456789012356'
    #         profile.save()

    # def test_desk_phone_char_limit(self):
    #     user = UserFactory.create()
    #     profile = user.profile
    #     profile.desk = '1234567890123456789012356'
    #     with self.assertRaises(DataError):<commit_msg>comment out tests for later work<commit_after>from __future__ import unicode_literals

from django.contrib.auth.models import User
from django.db.transaction import TransactionManagementError
from django.test import TestCase

from estmator_project.factories import UserFactory
from .models import UserProfile


class UserProfileTestCase(TestCase):
    """Test behavior of user profile"""
    def setUp(self):
        pass

    def test_profile_is_created_when_user_is_saved(self):
        self.assertEqual(len(UserProfile.objects.all()), 0)
        user = UserFactory.create()
        user.save()
        self.assertTrue(UserProfile.objects.count() == 1)

    def test_delete_profile_deletes_user(self):
        user = UserFactory.create()
        user.save()
        self.assertEqual(len(UserProfile.objects.all()), 1)
        user.profile.delete()
        self.assertEqual(len(User.objects.all()), 0)

    def test_profile_str_is_user_username(self):
        user = UserFactory.create(username='user1')
        user.save()
        profile = UserProfile.objects.get(user__username='user1')
        self.assertEqual(str(profile),
                         user.get_full_name() or profile.user.username)

    def test_active_user_is_active_property(self):
        user = UserFactory.create(username='user1')
        user.save()
        self.assertTrue(user.is_active)

    # def test_cell_phone_char_limit(self):
    #     user = UserFactory.create()
    #     profile = user.profile
    #     with self.assertRaises(TransactionManagementError):
    #         profile.cell = '12345678901234567890123567827957432'
    #         profile.save()

    # def test_desk_phone_char_limit(self):
    #     user = UserFactory.create()
    #     profile = user.profile
    #     profile.desk = '1234567890123456789012356'
    #     with self.assertRaises(DataError):
{'fraction_non_alphanumeric': 0.09953766657601305, 'fraction_numerical': 0.03372314386728311, 'mean_word_length': 3.123318385650224, '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': '4253257', 'n_tokens_mistral': 1146, 'n_tokens_neox': 1044, 'n_words': 186}