Comment 0 for bug 605635

Revision history for this message
James Westby (james-w) wrote : Test failures in trunk

Hi,

While trying to land the launchpadlib update in to Launchpad itself, I ran in to test failures
with the latest release.

Confused I went to try and reproduce in lp:launchpadlib.

I ran python bootstrap.py && ./bin/buildout && ./bin/test and found that test_no_credentials_calls_get_token_and_login
was failing, as it was expecting the "beta" webservice, when 1.0 is default. This is bug 488448.

I didn't see the failures I was seeing when using in launchpad, and so dicsovered
that ./bin/test doesn't run any of the doctests, and I think this may mean that the tests
haven't been getting exercised.

Writing a small test_docs.py to load the doctests I was able to run them.

This led to lots of problems.

Lots of this:

    Traceback (most recent call last):
      File "/usr/lib/python2.6/doctest.py", line 1248, in __run
        compileflags, 1) in test.globs
      File "<doctest people.txt[6]>", line 1, in <module>
        me = launchpad.me
      File "/home/jw2328/devel/launchpadlib/launchpadlib/launchpadlib/eggs/lazr.restfulclient-0.9.20-py2.6.egg/lazr/restfulclient/resource.py", line 305, in __getattr__
        return self.lp_get_parameter(attr)
      File "/home/jw2328/devel/launchpadlib/launchpadlib/launchpadlib/eggs/lazr.restfulclient-0.9.20-py2.6.egg/lazr/restfulclient/resource.py", line 206, in lp_get_parameter
        linked_resource = param.linked_resource
      File "/home/jw2328/devel/launchpadlib/launchpadlib/launchpadlib/eggs/wadllib-1.1.4-py2.6.egg/wadllib/application.py", line 928, in linked_resource
        return Link(self, link_tag).resolve_definition()
      File "/home/jw2328/devel/launchpadlib/launchpadlib/launchpadlib/eggs/wadllib-1.1.4-py2.6.egg/wadllib/application.py", line 217, in resolve_definition
        xml_id = self.application.lookup_xml_id(object_url)
      File "/home/jw2328/devel/launchpadlib/launchpadlib/launchpadlib/eggs/wadllib-1.1.4-py2.6.egg/wadllib/application.py", line 1080, in lookup_xml_id
        "url (%s) are: %s requested: %s" % (url, this_uri, markup_uri))
    NotImplementedError: Can't look up definition in another url (https://api.launchpad.dev/1.0/#person)

because it is comparing a https scheme with no port with a http scheme with a port.

Then this:

    len(mugshot.open().read())
Expected:
    send: ...
    reply: 'HTTP/1.1 303 See Other...
    header: Location: http://localhost:58000/.../image.png
    ...
    header: Content-Type: text/plain
    2260
Got:
    send: 'GET /1.0/~salgado/mugshot HTTP/1.1\r\nHost: api.launchpad.dev\r\nAuthorization: OAuth realm="OAuth", oauth_nonce="66322799", oauth_timestamp="1279141663", oauth_consumer_key="launchpad-library", oauth_signature_method="PLAINTEXT", oauth_version="1.0", oauth_token="salgado-change-anything", oauth_signature="%26test"\r\naccept-encoding: gzip, deflate\r\naccept: application/json\r\nuser-agent: lazr.restfulclient 0.9.20; oauth_consumer="launchpad-library"\r\n\r\n'
    reply: 'HTTP/1.1 303 See Other\r\n'
    header: Date: Wed, 14 Jul 2010 21:07:43 GMT
    header: Server: zope.server.http (DebugLayerHTTP)
    header: X-Powered-By: Zope (www.zope.org), Python (www.python.org)
    header: X-Content-Type-Warning: guessed from content
    header: Location: http://launchpad.dev:58080/94/image.png
    header: Vary: Accept,Accept-Encoding
    header: Content-Type: text/plain
    header: Via: 1.1 launchpad.dev
    header: Content-Encoding: gzip
    header: Content-Length: 20
    2260

which is apparently because the librarian now sits on launchpad.dev:58080 rather than
localhost:58000

Then this:

File "/home/jw2328/devel/launchpadlib/launchpadlib/launchpadlib/src/launchpadlib/tests/../docs/people.txt", line 49, in people.txt
Failed example:
    launchpad.people['not-a-registered-person']
Expected:
    Traceback (most recent call last):
    ...
    KeyError: 'not-a-registered-person'
Got:
    Traceback (most recent call last):
      File "/usr/lib/python2.6/doctest.py", line 1248, in __run
        compileflags, 1) in test.globs
      File "<doctest people.txt[12]>", line 1, in <module>
        launchpad.people['not-a-registered-person']
      File "/home/jw2328/devel/launchpadlib/launchpadlib/launchpadlib/eggs/lazr.restfulclient-0.9.20-py2.6.egg/lazr/restfulclient/resource.py", line 628, in __repr__
        URI(self.resource_type_link).fragment, self.self_link)
      File "/home/jw2328/devel/launchpadlib/launchpadlib/launchpadlib/eggs/lazr.restfulclient-0.9.20-py2.6.egg/lazr/restfulclient/resource.py", line 643, in __getattr__
        return super(Entry, self).__getattr__(name)
      File "/home/jw2328/devel/launchpadlib/launchpadlib/launchpadlib/eggs/lazr.restfulclient-0.9.20-py2.6.egg/lazr/restfulclient/resource.py", line 305, in __getattr__
        return self.lp_get_parameter(attr)
      File "/home/jw2328/devel/launchpadlib/launchpadlib/launchpadlib/eggs/lazr.restfulclient-0.9.20-py2.6.egg/lazr/restfulclient/resource.py", line 196, in lp_get_parameter
        self._ensure_representation()
      File "/home/jw2328/devel/launchpadlib/launchpadlib/launchpadlib/eggs/lazr.restfulclient-0.9.20-py2.6.egg/lazr/restfulclient/resource.py", line 331, in _ensure_representation
        representation = self._root._browser.get(self._wadl_resource)
      File "/home/jw2328/devel/launchpadlib/launchpadlib/launchpadlib/eggs/lazr.restfulclient-0.9.20-py2.6.egg/lazr/restfulclient/_browser.py", line 287, in get
        response, content = self._request(url, extra_headers=headers)
      File "/home/jw2328/devel/launchpadlib/launchpadlib/launchpadlib/eggs/lazr.restfulclient-0.9.20-py2.6.egg/lazr/restfulclient/_browser.py", line 277, in _request
        raise HTTPError(response, content)
    HTTPError: HTTP Error 404: Not Found
    Response headers:
    ---
    content-length: 2255
    content-type: text/plain
    date: Wed, 14 Jul 2010 21:08:01 GMT
    server: zope.server.http (HTTP)
    status: 404
    x-lazr-oopsid: OOPS-1656X28
    x-powered-by: Zope (www.zope.org), Python (www.python.org)
    ---
    Response body:
    ---
    Object: <canonical.launchpad.systemhomes.WebServiceApplication object at 0xc3a806c>, name: u'~not-a-registered-person'
    <BLANKLINE>
    Traceback (most recent call last):
      File "/home/jw2328/devel/lp-sourcedeps/eggs/zope.publisher-3.10.0-py2.6.egg/zope/publisher/publish.py", line 131, in publish
        obj = request.traverse(obj)
      File "/home/jw2328/devel/lp-sourcedeps/eggs/lazr.restful-0.9.29-py2.6.egg/lazr/restful/publisher.py", line 227, in traverse
        result = super(WebServiceRequestTraversal, self).traverse(ob)
      File "/home/jw2328/devel/lp-sourcedeps/eggs/zope.publisher-3.10.0-py2.6.egg/zope/publisher/browser.py", line 542, in traverse
        ob = super(BrowserRequest, self).traverse(obj)
      File "/home/jw2328/devel/lp-sourcedeps/eggs/zope.publisher-3.10.0-py2.6.egg/zope/publisher/http.py", line 456, in traverse
        ob = super(HTTPRequest, self).traverse(obj)
      File "/home/jw2328/devel/lp-sourcedeps/eggs/zope.publisher-3.10.0-py2.6.egg/zope/publisher/base.py", line 261, in traverse
        obj = publication.traverseName(self, obj, entry_name)
      File "/home/jw2328/devel/lp-sourcedeps/eggs/lazr.restful-0.9.29-py2.6.egg/lazr/restful/publisher.py", line 97, in traverseName
        request, ob, name)
      File "/home/jw2328/devel/lp-sourcedeps/eggs/zope.app.publication-3.9.0-py2.6.egg/zope/app/publication/zopepublication.py", line 197, in traverseName
        ob2 = adapter.publishTraverse(request, nm)
      File "/home/jw2328/devel/launchpad/expose-blueprints/lib/canonical/launchpad/browser/launchpad.py", line 735, in publishTraverse
        return Navigation.publishTraverse(self, request, name)
      File "/home/jw2328/devel/launchpad/expose-blueprints/lib/canonical/launchpad/webapp/publisher.py", line 615, in publishTraverse
        nextobj = self._publishTraverse(request, name)
      File "/home/jw2328/devel/launchpad/expose-blueprints/lib/canonical/launchpad/webapp/publisher.py", line 739, in _publishTraverse
        return self._handle_next_object(nextobj, request, name)
      File "/home/jw2328/devel/launchpad/expose-blueprints/lib/canonical/launchpad/webapp/publisher.py", line 645, in _handle_next_object
        raise NotFound(self.context, name)
    NotFound: Object: <canonical.launchpad.systemhomes.WebServiceApplication object at 0xc3a806c>, name: u'~not-a-registered-person'
    <BLANKLINE>
    ---
    <BLANKLINE>

and then finally this:

File "/home/jw2328/devel/launchpadlib/launchpadlib/launchpadlib/src/launchpadlib/tests/../docs/people.txt", line 34, in people.txt
Failed example:
    me.name
Expected:
    u'salgado'
Got:
    'salgado'

which is what was failing when I tried to upgrade launchpad's copy.

This one is caused by the

  332 representation = simplejson.loads(representation)

in lazr.restfulclient.resource. If we want unicode strings then pass unicode to
simplejson.

Thanks,

James