<commit_before>"""
Test the views of jurisdiction models
"""

from django.test import TestCase

from nose.tools import eq_, ok_

from muckrock.jurisdiction import factories, views
from muckrock.test_utils import http_get_response

class TestExemptionDetailView(TestCase):
    """The exemption detail view provides information about the exemption at a standalone url."""
    def setUp(self):
        self.exemption = factories.ExemptionFactory()
        self.url = self.exemption.get_absolute_url()
        self.view = views.ExemptionDetailView.as_view()
        self.kwargs = self.exemption.jurisdiction.get_slugs()
        self.kwargs.update({
            'slug': self.exemption.slug,
            'pk': self.exemption.pk,
        })

    def test_ok(self):
        """The view should return a 200 OK status."""
        response = http_get_response(self.url, self.view, **self.kwargs)
        eq_(response.status_code, 200)

    def test_unique_for_jurisdiction(self):
        """Two exemptions may have the same name,
        as long as they belong to different jurisdictions."""
        another_jurisdiction = factories.StateJurisdictionFactory()
        ok_(self.exemption.jurisdiction is not another_jurisdiction)
        another_exemption = factories.ExemptionFactory(jurisdiction=another_jurisdiction)
        response = http_get_response(self.url, self.view, **self.kwargs)
        eq_(response.status_code, 200)

    def test_federal_exemptions(self):
        """An exemption at the federal level should return 200."""
        fed = factories.FederalJurisdictionFactory()
        exemption = factories.ExemptionFactory(jurisdiction=fed)
        response =http_get_response(self.url, self.view, **self.kwargs)
        eq_(response.status_code, 200)<commit_msg>pylint<commit_after>"""
Test the views of jurisdiction models
"""

from django.test import TestCase

from nose.tools import eq_, ok_

from muckrock.jurisdiction import factories, views
from muckrock.test_utils import http_get_response

class TestExemptionDetailView(TestCase):
    """The exemption detail view provides information about the exemption at a standalone url."""
    def setUp(self):
        self.exemption = factories.ExemptionFactory()
        self.url = self.exemption.get_absolute_url()
        self.view = views.ExemptionDetailView.as_view()
        self.kwargs = self.exemption.jurisdiction.get_slugs()
        self.kwargs.update({
            'slug': self.exemption.slug,
            'pk': self.exemption.pk,
        })

    def test_ok(self):
        """The view should return a 200 OK status."""
        response = http_get_response(self.url, self.view, **self.kwargs)
        eq_(response.status_code, 200)

    def test_unique_for_jurisdiction(self):
        """Two exemptions may have the same name,
        as long as they belong to different jurisdictions."""
        another_jurisdiction = factories.StateJurisdictionFactory()
        ok_(self.exemption.jurisdiction is not another_jurisdiction)
        factories.ExemptionFactory(jurisdiction=another_jurisdiction)
        response = http_get_response(self.url, self.view, **self.kwargs)
        eq_(response.status_code, 200)

    def test_federal_exemptions(self):
        """An exemption at the federal level should return 200."""
        fed = factories.FederalJurisdictionFactory()
        exemption = factories.ExemptionFactory(jurisdiction=fed)
        url = exemption.get_absolute_url()
        kwargs = exemption.jurisdiction.get_slugs()
        kwargs.update({
            'slug': exemption.slug,
            'pk': exemption.pk,
        })
        response = http_get_response(url, self.view, **kwargs)
        eq_(response.status_code, 200)
{'fraction_non_alphanumeric': 0.09496753246753246, 'fraction_numerical': 0.008116883116883116, 'mean_word_length': 3.26905311778291, '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': '120065', 'n_tokens_mistral': 1131, 'n_tokens_neox': 994, 'n_words': 253}