<commit_before>from django.test import TestCase

# Create your tests here.
<commit_msg>Write folder tests<commit_after>from django.test import TestCase
from django.core.urlresolvers import reverse

from rest_framework.test import APIClient
from rest_framework import status


class FolderSelfTest(TestCase):

    def setUp(self):
        self.client = APIClient()
        response = self.client.post(reverse('registration'), {
            'email': '<EMAIL>',
            'password': '<PASSWORD>',
            'first_name': 'Testy',
            'last_name': 'McTesterson'
        }, format='json')
        token = response.data['token']
        self.client.credentials(HTTP_AUTHORIZATION='Token ' + token)

    def testSuccess(self):
        # Create
        response = self.client.post(reverse('folder-self-list'), {
            'name': 'Test Folder'
        }, format='json')
        self.assertEqual(response.status_code, status.HTTP_201_CREATED)

        detail_url = reverse('folder-self-detail', args=(response.data['id'],))

        # List
        response = self.client.get(reverse('folder-self-list'), format='json')
        self.assertEqual(response.status_code, status.HTTP_200_OK)
        self.assertEqual(response.data['count'], 1)

        # Detail
        response = self.client.get(detail_url, format='json')
        self.assertEqual(response.status_code, status.HTTP_200_OK)
        self.assertEqual(response.data['id'], 1)
        self.assertEqual(response.data['name'], 'Test Folder')

        # Update name
        response = self.client.patch(detail_url, {
            'name': 'Something Else'
        }, format='json')
        self.assertEqual(response.status_code, status.HTTP_200_OK)
        self.assertEqual(response.data['name'], 'Something Else')

        # Update is_public
        response = self.client.patch(detail_url, {
            'is_public': False
        }, format='json')
        self.assertEqual(response.status_code, status.HTTP_200_OK)
        self.assertEqual(response.data['is_public'], False)

        # Update description
        response = self.client.patch(detail_url, {
            'description': 'This is the description'
        }, format='json')
        self.assertEqual(response.status_code, status.HTTP_200_OK)
        self.assertEqual(response.data['description'], 'This is the description')

        # Delete
        response = self.client.delete(detail_url, format='json')
        self.assertEqual(response.status_code, status.HTTP_204_NO_CONTENT)


{'fraction_non_alphanumeric': 0.1253993610223642, 'fraction_numerical': 0.009185303514376996, 'mean_word_length': 2.92018779342723, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '7518773', 'n_tokens_mistral': 717, 'n_tokens_neox': 693, 'n_words': 127}