Example #1
0
 def test_merge(self):
     # Test that the merge() function performs as described in
     # Section 5.2.3 of RFC 3986
     self.assertEqual(merge('', 'foo', has_authority=True), '/foo')
     self.assertEqual(merge('', 'foo', has_authority=False), 'foo')
     self.assertEqual(merge('/a/b/c', 'foo', has_authority=True),
                      '/a/b/foo')
     self.assertEqual(merge('/a/b/', 'foo', has_authority=True), '/a/b/foo')
Example #2
0
 def test_merge(self):
     # Test that the merge() function performs as described in
     # Section 5.2.3 of RFC 3986
     self.assertEqual(merge('', 'foo', has_authority=True), '/foo')
     self.assertEqual(merge('', 'foo', has_authority=False), 'foo')
     self.assertEqual(merge('/a/b/c', 'foo', has_authority=True),
                      '/a/b/foo')
     self.assertEqual(merge('/a/b/', 'foo', has_authority=True),
                      '/a/b/foo')
Example #3
0
    def get_resource_by_path(self, path):
        """Locate one of the resources described by this document.

        :param path: The path to the resource.
        """
        # XXX leonardr 2008-05-27 This method only finds top-level
        # resources. That's all we need for Launchpad because we don't
        # define nested resources yet.
        matching = [resource for resource in self.resources
                    if resource.attrib['path'] == path]
        if len(matching) < 1:
            return None
        if len(matching) > 1:
            raise WADLError("More than one resource defined with path %s"
                            % path)
        return Resource(
            self, merge(self.resource_base, path, True), matching[0])
Example #4
0
    def get_resource_by_path(self, path):
        """Locate one of the resources described by this document.

        :param path: The path to the resource.
        """
        # XXX leonardr 2008-05-27 This method only finds top-level
        # resources. That's all we need for Launchpad because we don't
        # define nested resources yet.
        matching = [resource for resource in self.resources
                    if resource.attrib['path'] == path]
        if len(matching) < 1:
            return None
        if len(matching) > 1:
            raise WADLError("More than one resource defined with path %s"
                            % path)
        return Resource(
            self, merge(self.resource_base, path, True), matching[0])