11128.5.7
by Michael Hudson
add unit test for code domain tests being served by correct request types, and fix the bug that broke half the windmill tests |
1 |
# Copyright 2010 Canonical Ltd. This software is licensed under the
|
2 |
# GNU Affero General Public License version 3 (see the file LICENSE).
|
|
3 |
||
4 |
"""Tests for code's custom publications."""
|
|
5 |
||
6 |
__metaclass__ = type |
|
7 |
||
8 |
from canonical.config import config |
|
9 |
from canonical.launchpad.layers import WebServiceLayer |
|
11128.5.9
by Michael Hudson
remove accidental enlargening of test layer |
10 |
from canonical.testing.layers import FunctionalLayer |
11403.1.4
by Henning Eggers
Reformatted imports using format-imports script r32. |
11 |
from lp.code.publisher import CodeLayer |
11128.5.7
by Michael Hudson
add unit test for code domain tests being served by correct request types, and fix the bug that broke half the windmill tests |
12 |
from lp.testing import TestCase |
13 |
from lp.testing.publication import get_request_and_publication |
|
14 |
||
15 |
||
16 |
class TestRegistration(TestCase): |
|
17 |
"""Code's publication customizations are installed correctly."""
|
|
18 |
||
11128.5.9
by Michael Hudson
remove accidental enlargening of test layer |
19 |
layer = FunctionalLayer |
11128.5.7
by Michael Hudson
add unit test for code domain tests being served by correct request types, and fix the bug that broke half the windmill tests |
20 |
|
21 |
def test_code_request_provides_code_layer(self): |
|
22 |
# The request constructed for requests to the code hostname provides
|
|
23 |
# CodeLayer.
|
|
24 |
request, publication = get_request_and_publication( |
|
25 |
host=config.vhost.code.hostname) |
|
26 |
self.assertProvides(request, CodeLayer) |
|
27 |
||
28 |
def test_code_host_has_api(self): |
|
29 |
# Requests to /api on the code domain are treated as web service
|
|
30 |
# requests.
|
|
31 |
request, publication = get_request_and_publication( |
|
32 |
host=config.vhost.code.hostname, |
|
33 |
extra_environment={'PATH_INFO': '/api/1.0'}) |
|
34 |
# XXX MichaelHudson, 2010-07-20, bug=607664: WebServiceLayer only
|
|
35 |
# actually provides WebServiceLayer in the sense of verifyObject after
|
|
36 |
# traversal has started.
|
|
37 |
self.assertTrue(WebServiceLayer.providedBy(request)) |