<commit_before># -*- coding: utf-8 -*-
#
# inventory/accounts/tests/test_accounts.py
#
# Run ./manage.py test -k # Keep the DB, don't rebuild.
#

from django.contrib.auth import get_user_model
from django.test import TestCase
from django.core.exceptions import ValidationError

from inventory.projects.models import Project

from ..models import Question, Answer, create_hash

User = get_user_model()


class BaseAccounts(TestCase):
    _TEST_USERNAME = 'TestUser'
    _TEST_PASSWORD = '<PASSWORD>'

    def __init__(self, name):
        super(BaseAccounts, self).__init__(name)
        self.user = None

    def setUp(self):
        self.user = self._create_user()

    def _create_user(self, username=_TEST_USERNAME, email=None,
                     password=_<PASSWORD>, is_superuser=True,
                     role=User.DEFAULT_USER):
        user = User.objects.create_user(username=username, password=password)
        user.first_name = "Test"
        user.last_name = "User"
        user.is_active = True
        user.is_staff = True
        user.is_superuser = is_superuser
        user.role = role
        user.save()
        return user

    def _create_question_record(self, question, active=True):
        kwargs = {}
        kwargs['question'] = question
        kwargs['active'] = active
        kwargs['creator'] = self.user
        kwargs['updater'] = self.user
        return Question.objects.create(**kwargs)

    def _create_answer_record(self, answer, question_obj):
        kwargs = {}
        kwargs['answer'] = answer
        kwargs['question'] = question_obj
        kwargs['creator'] = self.user
        kwargs['updater'] = self.user
        return Answer.objects.create(**kwargs)

    def _create_project_record(self, name, public=True):
        kwargs = {}
        kwargs['name'] = name
        kwargs['public'] = public
        kwargs['creator'] = self.user
        kwargs['updater'] = self.user
        return Project.objects.create(**kwargs)


class TestUser(BaseAccounts):

    def __init__(self, name):
        super(TestUser, self).__init__(name)


    def test_create_superuser(self):
        """<commit_msg>Formatting<commit_after># -*- coding: utf-8 -*-
#
# inventory/accounts/tests/test_accounts.py
#
# Run ./manage.py test -k # Keep the DB, don't rebuild.
#

from django.contrib.auth import get_user_model
from django.test import TestCase
from django.core.exceptions import ValidationError

from inventory.projects.models import Project

from ..models import Question, Answer, create_hash

User = get_user_model()


class BaseAccounts(TestCase):
    _TEST_USERNAME = 'TestUser'
    _TEST_PASSWORD = '<PASSWORD>'

    def __init__(self, name):
        super(BaseAccounts, self).__init__(name)
        self.user = None

    def setUp(self):
        self.user = self._create_user()

    def _create_user(self, username=_TEST_USERNAME, email=None,
                     password=_<PASSWORD>, is_superuser=True,
                     role=User.DEFAULT_USER):
        user = User.objects.create_user(username=username, password=password)
        user.first_name = "Test"
        user.last_name = "User"
        user.is_active = True
        user.is_staff = True
        user.is_superuser = is_superuser
        user.role = role
        user.save()
        return user

    def _create_question_record(self, question, active=True):
        kwargs = {}
        kwargs['question'] = question
        kwargs['active'] = active
        kwargs['creator'] = self.user
        kwargs['updater'] = self.user
        return Question.objects.create(**kwargs)

    def _create_answer_record(self, answer, question_obj):
        kwargs = {}
        kwargs['answer'] = answer
        kwargs['question'] = question_obj
        kwargs['creator'] = self.user
        kwargs['updater'] = self.user
        return Answer.objects.create(**kwargs)

    def _create_project_record(self, name, public=True):
        kwargs = {}
        kwargs['name'] = name
        kwargs['public'] = public
        kwargs['creator'] = self.user
        kwargs['updater'] = self.user
        return Project.objects.create(**kwargs)


class TestUser(BaseAccounts):

    def __init__(self, name):
        super(TestUser, self).__init__(name)

    def test_create_superuser(self):
        """
{'fraction_non_alphanumeric': 0.11495327102803739, 'fraction_numerical': 0.00046728971962616824, 'mean_word_length': 2.7161458333333335, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '3212782', 'n_tokens_mistral': 1261, 'n_tokens_neox': 1231, 'n_words': 266}