<commit_before>from __future__ import absolute_import

from django.core.urlresolvers import reverse

from sentry.models import AuthProvider
from sentry.testutils import AuthProviderTestCase


class OrganizationAuthSettingsTest(AuthProviderTestCase):
    def test_renders_basic_login_form(self):
        organization = self.create_organization(name='foo', owner=self.user)
        team = self.create_team(organization=organization)
        project = self.create_project(team=team)

        path = reverse('sentry-auth-organization', args=[organization.slug])

        self.login_as(self.user)

        resp = self.client.get(path)

        assert resp.status_code == 200

        self.assertTemplateUsed(resp, 'sentry/organization-login.html')

        assert resp.context['form']
        assert 'provider_key' not in resp.context
        assert resp.context['CAN_REGISTER']

    def test_renders_auth_provider(self):
        organization = self.create_organization(name='foo', owner=self.user)
        team = self.create_team(organization=organization)
        project = self.create_project(team=team)
        auth_provider = AuthProvider.objects.create(
            organization=organization,
            provider='dummy',
        )

        path = reverse('sentry-auth-organization', args=[organization.slug])

        self.login_as(self.user)

        resp = self.client.get(path)

        self.assertTemplateUsed(resp, 'sentry/organization-login.html')

        assert 'form' not in resp.context
        assert resp.context['provider_key'] == 'dummy'
        assert not resp.context['CAN_REGISTER']<commit_msg>Correct test<commit_after>from __future__ import absolute_import

from django.core.urlresolvers import reverse

from sentry.models import AuthProvider
from sentry.testutils import AuthProviderTestCase


class OrganizationAuthSettingsTest(AuthProviderTestCase):
    def test_renders_basic_login_form(self):
        organization = self.create_organization(name='foo', owner=self.user)
        team = self.create_team(organization=organization)
        project = self.create_project(team=team)

        path = reverse('sentry-auth-organization', args=[organization.slug])

        self.login_as(self.user)

        resp = self.client.get(path)

        assert resp.status_code == 200

        self.assertTemplateUsed(resp, 'sentry/organization-login.html')

        assert resp.context['form']
        assert 'provider_key' not in resp.context
        assert resp.context['CAN_REGISTER']

    def test_renders_auth_provider(self):
        organization = self.create_organization(name='foo', owner=self.user)
        team = self.create_team(organization=organization)
        project = self.create_project(team=team)
        auth_provider = AuthProvider.objects.create(
            organization=organization,
            provider='dummy',
        )

        path = reverse('sentry-auth-organization', args=[organization.slug])

        self.login_as(self.user)

        resp = self.client.get(path)

        self.assertTemplateUsed(resp, 'sentry/organization-login.html')

        assert resp.context['provider_key'] == 'dummy'
        assert not resp.context['CAN_REGISTER']
{'fraction_non_alphanumeric': 0.09952904238618525, 'fraction_numerical': 0.0018838304552590266, 'mean_word_length': 3.412742382271468, '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': '3016673', 'n_tokens_mistral': 900, 'n_tokens_neox': 844, 'n_words': 153}