<commit_before># import json
# import time

from django.contrib.auth.models import User

from django.test import TestCase
from django.core.urlresolvers import reverse

from people.models import Artist

from ..models import StudentApplication


class TestApplicationEndPoint(TestCase):
    """
    Tests concernants le endpoint des Student Application
    """

    def setUp(self):
        self.user = User()
        self.user.first_name = "Andrew"
        self.user.last_name = "Warhola"
        self.user.username = "awarhol"
        self.user.save()

        self.artist = Artist(user=self.user, nickname="<NAME>")
        self.artist.save()

        self.application = StudentApplication(artist=self.artist)
        self.application.save()

    def tearDown(self):
        pass

    def _get_list(self):
        url = reverse('studentapplication-list')
        return self.client.get(url)

    # List display now only on user Authenticated
    # TODO Need to know how authentify user in pytest
    #
    # def test_list(self):
    #     """
    #     Test list of applications
    #     """
    #     response = self._get_list()
    #     self.assertEqual(response.status_code, 200)
    #
    # def test_json_response(self):
    #     """
    #     Test JSON response
    #     """
    #     response = self._get_list()
    #     self.assertTrue(json.loads(response.content))
    #
    # def test_first_app_default_value(self):
    #     """
    #     Test default value
    #     """
    #     url = reverse('studentapplication-detail', kwargs={'pk': 1})
    #     response = self.client.get(url)<commit_msg>tests solution for login user in comment<commit_after># import json
# import time
# from django.contrib.auth import authenticate, login, logout
from django.contrib.auth.models import User

from django.test import TestCase
from django.core.urlresolvers import reverse

from people.models import Artist

from ..models import StudentApplication


class TestApplicationEndPoint(TestCase):
    """
    Tests concernants le endpoint des Student Application
    """

    def setUp(self):
        self.user = User()
        self.user.first_name = "Andrew"
        self.user.last_name = "Warhola"
        self.user.username = "awarhol"
        self.user.password = "<PASSWORD>"
        self.user.save()
        # save generate token

        self.artist = Artist(user=self.user, nickname="<NAME>")
        self.artist.save()

        self.application = StudentApplication(artist=self.artist)
        self.application.save()

    def tearDown(self):
        pass

    def _get_list(self):
        url = reverse('studentapplication-list')
        return self.client.get(url)

    # Must have an login token : client.get(url_for('ping'), headers=[('X-Something', '42')])
    # Read the doc : http://pytest-flask.readthedocs.io/en/latest/features.html
    # def test_list(self):
    #     """
    #     Test list of applications without authentification
    #     """
    #     response = self._get_list()
    #     self.assertEqual(response.status_code, 200)
    #
    # def test_list_auth(self):
    #     """
    #     Test list of applications with authentification
    #     """
    #     user = authenticate(username=self.user.username, password=<PASSWORD>)
    #     response = self._get_list()
    #     self.assertEqual(response.status_code, 200)
    #
    # def test_list_items_auth(self):
    #     """
    #     Test numbers of applications with authentification
    #     """
    #     user = authenticate(username=self.user.username, password=<PASSWORD>)
    #     response = self._get_list()
    #     data = json.loads(response.content)
    #     self.assertEqual(len(data), 1)

    # def test_json_response(self):
    #     """
    #     Test JSON response
    #     """
    #     response = self._get_list()
    #     self.assertTrue(json.loads(response.content))
    #
    # def test_first_app_default_value(self):
    #     """
    #     Test default value
    #     """
    #     url = reverse('studentapplication-detail', kwargs={'pk': 1})
    #     response = self.client.get(url)
{'fraction_non_alphanumeric': 0.11677230619210141, 'fraction_numerical': 0.0034129692832764505, 'mean_word_length': 2.497868712702472, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 8, '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': '2734257', 'n_tokens_mistral': 1230, 'n_tokens_neox': 1209, 'n_words': 258}