<commit_before>from test_base import MainTestCase
from main.models import UserProfile
from django.core.urlresolvers import reverse
from main.views import profile_settings

class TestUserSettings(MainTestCase):

    def setUp(self):
        MainTestCase.setUp(self)
        self.settings_url = reverse(profile_settings, kwargs={'username': self.user.username})

    def test_render_user_settings(self):
        response = self.client.get(self.settings_url)
        self.assertEqual(response.status_code, 200)

    def test_show_existing_profile_data(self):
        profile, created = UserProfile.objects.get_or_create(user=self.user)
        profile.name = "Bobby"
        profile.save()
        response = self.client.get(self.settings_url)
        self.assertContains(response, profile.name)

    def test_update_user_settings(self):
        post_data = {
            'name': 'Bobby',
            'organization': 'Bob Inc',
            'city': 'Bobville',
            'country': 'BB',
            'twitter': 'bobo',
            'home_page': 'bob.com',
        }
        response = self.client.post(self.settings_url, post_data)
        self.assertEqual(response.status_code, 302)
        for key, value in post_data.iteritems():
            self.assertEqual(self.user.profile.__dict__[key], value)
<commit_msg>add require_auth to the user settings test<commit_after>from test_base import MainTestCase
from main.models import UserProfile
from django.core.urlresolvers import reverse
from main.views import profile_settings

class TestUserSettings(MainTestCase):

    def setUp(self):
        MainTestCase.setUp(self)
        self.settings_url = reverse(profile_settings, kwargs={'username': self.user.username})

    def test_render_user_settings(self):
        response = self.client.get(self.settings_url)
        self.assertEqual(response.status_code, 200)

    def test_show_existing_profile_data(self):
        profile, created = UserProfile.objects.get_or_create(user=self.user)
        profile.name = "Bobby"
        profile.save()
        response = self.client.get(self.settings_url)
        self.assertContains(response, profile.name)

    def test_update_user_settings(self):
        post_data = {
            'name': 'Bobby',
            'organization': 'Bob Inc',
            'city': 'Bobville',
            'country': 'BB',
            'twitter': 'bobo',
            'home_page': 'bob.com',
            'require_auth': True,
        }
        response = self.client.post(self.settings_url, post_data)
        self.assertEqual(response.status_code, 302)
        for key, value in post_data.iteritems():
            self.assertEqual(self.user.profile.__dict__[key], value)

{'fraction_non_alphanumeric': 0.10651769087523277, 'fraction_numerical': 0.004469273743016759, 'mean_word_length': 2.932650073206442, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '3723853', 'n_tokens_mistral': 786, 'n_tokens_neox': 761, 'n_words': 150}