<commit_before>from __future__ import absolute_import

from django.core import mail
from django.core.urlresolvers import reverse_lazy
from django.test import TestCase
from django.utils import timezone
from guardian.shortcuts import assign_perm, get_perms

from cases.factories import CaseFactory
from cases.models import Case
from users.factories import UserFactory
from users.forms import TranslatedUserObjectPermissionsForm, UserForm
from users.models import User


class UserTestCase(TestCase):

    def test_get_user_by_get_by_email_or_create(self):
        self.assertEqual(User.objects.count(), 1)
        new_user = User.objects.get_by_email_or_create('<EMAIL>')
        self.assertEqual(User.objects.count(), 2)
        get_user = User.objects.get_by_email_or_create('<EMAIL>')
        self.assertEqual(new_user, get_user)
        self.assertEqual(User.objects.count(), 2)

    def _create_user(self, email, username):
        User.objects.email_to_unique_username(email)
        self.assertEqual(username, username)
        User.objects.create_user(username=username)

    def test_emaTeil_to_username(self):
        self._create_user('<EMAIL>', 'example_example_com')
        for i in range(1, 11):<commit_msg>Fix typo<commit_after>from __future__ import absolute_import

from django.core import mail
from django.core.urlresolvers import reverse_lazy
from django.test import TestCase
from django.utils import timezone
from guardian.shortcuts import assign_perm, get_perms

from cases.factories import CaseFactory
from cases.models import Case
from users.factories import UserFactory
from users.forms import TranslatedUserObjectPermissionsForm, UserForm
from users.models import User


class UserTestCase(TestCase):

    def test_get_user_by_get_by_email_or_create(self):
        self.assertEqual(User.objects.count(), 1)
        new_user = User.objects.get_by_email_or_create('<EMAIL>')
        self.assertEqual(User.objects.count(), 2)
        get_user = User.objects.get_by_email_or_create('<EMAIL>')
        self.assertEqual(new_user, get_user)
        self.assertEqual(User.objects.count(), 2)

    def _create_user(self, email, username):
        User.objects.email_to_unique_username(email)
        self.assertEqual(username, username)
        User.objects.create_user(username=username)

    def test_email_to_username(self):
        self._create_user('<EMAIL>', 'example_example_com')
        for i in range(1, 11):
{'fraction_non_alphanumeric': 0.08466913275791205, 'fraction_numerical': 0.004932182490752158, 'mean_word_length': 4.557077625570776, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '2063846', 'n_tokens_mistral': 727, 'n_tokens_neox': 706, 'n_words': 158}