1
# Copyright 2012 Canonical Ltd. This software is licensed under the
2
# GNU Affero General Public License version 3 (see the file LICENSE).
4
"""Tests for the exceptions module."""
6
from __future__ import (
17
from maasserver.exceptions import (
21
from maasserver.testing import extract_redirect
22
from maastesting.factory import factory
23
from maastesting.testcase import TestCase
26
class TestExceptions(TestCase):
28
def test_MAASAPIException_produces_http_response(self):
29
error = factory.getRandomString()
30
exception = MAASAPIBadRequest(error)
31
response = exception.make_http_response()
33
(httplib.BAD_REQUEST, error),
34
(response.status_code, response.content))
36
def test_Redirect_produces_redirect_to_given_URL(self):
37
target = factory.getRandomString()
38
exception = Redirect(target)
39
response = exception.make_http_response()
40
self.assertEqual(target, extract_redirect(response))