helper functions for API pagetests

Bug #262038 reported by Edwin Grubbs
6
Affects Status Importance Assigned to Milestone
Launchpad itself
Triaged
Low
Unassigned

Bug Description

cprov suggested that helper functions automatically hide the api version from urls appearing in the responses from webservice.get(). For example:
    def show(thing):
        if isinstance(thing, dict):
            thing = sorted("%s: %s" % (name, value.replace('api.launchpad.dev/beta', '...')
                                   for name, value in thing.iteritems())
        pprint(thing)

One downside to this is that the pagetest won't print out the full url when the actual output doesn't match the expected output.

Revision history for this message
Celso Providelo (cprov) wrote :

We could even inspect the API objects using something more precise than iteritems() and wrap URL values as testable objects lile:

{{{
class ApiUrl:

    def __init__(self, url):
         self.url = url
         (self.scheme, self.host, self.path, params_unused,
          query_unused, fragment_unused) = urlparse(url)

    def __str__(self):
        return str(self.path)

    def __repr__(self):
         return str(self)
}}}

Revision history for this message
Diogo Matsubara (matsubara) wrote :

One thing is not clear in this report, why is it a good thing to hide the api version? Is it causing problems writing pagetests or something?

Changed in launchpad:
status: New → Incomplete
Revision history for this message
Celso Providelo (cprov) wrote :

I believe it's because, both, host and version are not necessarily important for all tests and are extensively repeated in our test-suite compromising its readability.

Changed in launchpad:
status: Incomplete → Triaged
Curtis Hovey (sinzui)
Changed in launchpad-foundations:
importance: Undecided → Low
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.