<commit_before>"""Unit test for exceptions."""
from unittest import TestCase
from speedcurve.exceptions import get_error_for
from speedcurve.exceptions import AuthenticationFailed
import mock


class TestExceptions(TestCase):

    def test_get_error_for(self):
        """Test that an AuthenticationFailed is returned."""
        response = mock.Mock(status_code=401, content='')
        error = get_error_for(response)
        assert isinstance(error, AuthenticationFailed)
        response.json.side_effect = Exception
        error = get_error_for(response)
        assert error.msg == '[No Message]'<commit_msg>Added unit test for exceptions<commit_after>"""Unit test for exceptions."""
from unittest import TestCase
from speedcurve.exceptions import get_error_for
from speedcurve.exceptions import AuthenticationFailed
from speedcurve.exceptions import BadRequest
from speedcurve.exceptions import ForbiddenError
from speedcurve.exceptions import NotFoundError
import mock


class TestExceptions(TestCase):
    """Exception unit test."""

    def test_get_error_for(self):
        """Test that an AuthenticationFailed is returned."""
        response = mock.Mock(status_code=401, content='')
        error = get_error_for(response)
        assert isinstance(error, AuthenticationFailed)
        response.json.side_effect = Exception
        error = get_error_for(response)
        assert error.msg == '[No Message]'

    def test_forbidden_error(self):
        """Test that a ForbiddenError is raised."""
        response = mock.Mock(status_code=403)
        error = get_error_for(response)
        assert isinstance(error, ForbiddenError)

    def test_bad_request_error(self):
        """Test that a BadRequest error is raised."""
        response = mock.Mock(status_code=400)
        error = get_error_for(response)
        assert isinstance(error, BadRequest)

    def test_not_found_error(self):
        """Test that a NotFoundError is raised."""
        response = mock.Mock(status_code=404)
        error = get_error_for(response)
        assert isinstance(error, NotFoundError)
{'fraction_non_alphanumeric': 0.08564593301435407, 'fraction_numerical': 0.007177033492822967, 'mean_word_length': 3.806896551724138, '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': '5874813', 'n_tokens_mistral': 566, 'n_tokens_neox': 543, 'n_words': 152}