<commit_before>from django.test import TestCase
from django.test import Client
from noveltorpedo.models import *
from django.utils import timezone
from django.core.management import call_command

client = Client()


class AuthTests(TestCase):

    def test_registration(self):
        # We can see the 'Login' button, but not the 'Logout' button since we haven't registered yet.
        response = client.get('/register')
        self.assertContains(response, 'Login')
        self.assertNotContains(response, 'Logout')

        # Ensure validation is working.
        response = client.post('/register', {
            'username': 'johndoe',
            'email': '<EMAIL>',
            'password1': '<PASSWORD>',
            'password2': '<PASSWORD>',
        })
        self.assertContains(response, 'The two password fields didn&#39;t match.')

        # Ensure a successful registration redirects back to the home page with the user automatically logged in.
        response = client.post('/register', {
            'username': 'johndoe',
            'email': '<EMAIL>',
            'password1': '<PASSWORD>',
            'password2': '<PASSWORD>',
        }, follow=True)
        self.assertRedirects(response, '/')

        # Now the user should be logged in, and so should see the 'Logout' button.
        response = client.get('/register')
        self.assertContains(response, 'Logout')
        self.assertNotContains(response, 'Login')<commit_msg>Expand registration integration test to check user info<commit_after>from django.contrib import auth
from django.core.management import call_command
from django.test import TestCase
from django.test import Client
from django.utils import timezone
from noveltorpedo.models import *
from django.contrib.auth.models import User

client = Client()


class AuthTests(TestCase):

    def test_registration(self):
        # We can see the 'Login' button, but not the 'Logout' button since we haven't registered yet.
        response = client.get('/register')
        self.assertContains(response, 'Login')
        self.assertNotContains(response, 'Logout')

        # Ensure validation is working.
        response = client.post('/register', {
            'username': 'johndoe',
            'email': '<EMAIL>',
            'password1': '<PASSWORD>',
            'password2': '<PASSWORD>',
        })
        self.assertContains(response, 'The two password fields didn&#39;t match.')

        # Ensure a successful registration redirects back to the home page with the user automatically logged in.
        response = client.post('/register', {
            'username': 'johndoe',
            'email': '<EMAIL>',
            'password1': '<PASSWORD>',
            'password2': '<PASSWORD>',
        }, follow=True)
        self.assertRedirects(response, '/')

        # Now the user should be logged in, and so should see the 'Logout' button.
        response = client.get('/register')
        self.assertContains(response, 'Logout')
        self.assertNotContains(response, 'Login')

        # Sanity check that the user's information was properly saved.
        user = User.objects.last()
        self.assertEquals('johndoe', user.username)
        self.assertEquals('<EMAIL>', user.email)
{'fraction_non_alphanumeric': 0.11550339715873996, 'fraction_numerical': 0.0037059913526868438, 'mean_word_length': 2.770663562281723, 'pattern_counts': {'":': 0, '<': 16, '<?xml version=': 0, '>': 16, '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': '1052566', 'n_tokens_mistral': 840, 'n_tokens_neox': 835, 'n_words': 261}