<commit_before>from django.contrib.auth import get_user_model
from django.core.exceptions import ValidationError
from django.core.urlresolvers import reverse
from django.test import Client, TestCase, override_settings
from qa.mixins import LoginRequired
from qa.models import (Answer, AnswerVote, Question, QuestionComment,
                       QuestionVote, UserQAProfile, AnswerComment)
from qa.views import CreateAnswerView, CreateQuestionView


class TestViews(TestCase):
    """
    Includes tests for all the functionality
    associated with Views
    """
    def setUp(self):
        self.client = Client()
        self.user = get_user_model().objects.create_user(
            username='test_user',
            email='<EMAIL>',
            password='<PASSWORD>'
        )
        self.client.login(username='test_user', password='<PASSWORD>')
        self.user_two = get_user_model().objects.create_user(
            username='user2', password='<PASSWORD>')

    def test_create_question_login(self):
        """
        CreateQuestionView should require login.
        Assertion can be made just by checking that the correct mixin
        is a superclass.
        """
        self.assertTrue(issubclass(CreateQuestionView, LoginRequired))

    def test_create_answer_login(self):
        """
        CreateAnswerView should require login.
        """
        self.assertTrue(issubclass(CreateAnswerView, LoginRequired))

    def test_create_question_view_one(self):
        """
        CreateQuestionView should create a new question object.<commit_msg>Adding new test to cover additional code<commit_after>from django.contrib.auth import get_user_model
from django.core.exceptions import ValidationError
from django.core.urlresolvers import reverse
from django.test import Client, TestCase, override_settings
from qa.mixins import LoginRequired
from qa.models import (Answer, AnswerVote, Question, QuestionComment,
                       QuestionVote, UserQAProfile, AnswerComment)
from qa.views import CreateAnswerView, CreateQuestionView


class TestViews(TestCase):
    """
    Includes tests for all the functionality
    associated with Views
    """
    def setUp(self):
        self.client = Client()
        self.user = get_user_model().objects.create_user(
            username='test_user',
            email='<EMAIL>',
            password='<PASSWORD>'
        )
        self.client.login(username='test_user', password='<PASSWORD>')
        self.user_two = get_user_model().objects.create_user(
            username='user2', password='<PASSWORD>')

    def test_create_question_login(self):
        """
        CreateQuestionView should require login.
        Assertion can be made just by checking that the correct mixin
        is a superclass.
        """
        self.assertTrue(issubclass(CreateQuestionView, LoginRequired))

    def test_create_answer_login(self):
        """
        CreateAnswerView should require login.
        """
        self.assertTrue(issubclass(CreateAnswerView, LoginRequired))

    def test_profile_view(self):
        """Test than the profile view is working properly
        """
        response = self.client.get(
            reverse('qa_profile',
                    kwargs={'user_id': self.user.userqaprofile.user_id}))
        self.assertEqual(response.status_code, 200)

    def test_create_question_view_one(self):
        """
        CreateQuestionView should create a new question object.
{'fraction_non_alphanumeric': 0.08654124457308249, 'fraction_numerical': 0.001447178002894356, 'mean_word_length': 3.0, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, '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': '1167340', 'n_tokens_mistral': 913, 'n_tokens_neox': 889, 'n_words': 226}