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