TestingWebServices

Not logged in - Log In / Register

Revision 2 as of 2010-04-12 17:11:39

Clear message

Webservices are testes using doctests.

GET

Default get method data can be retrieved using webservice.get(URL).jsonBody()

    >>> es = anon_webservice.get('/+languages/es').jsonBody()
    >>> es['resource_type_link']
    u'http.../#language'
    >>> print es['text_direction']
    Left to Right
    >>> print es['code']
    es

Custom get methods:

    >>> permissions = user_webservice.named_get(
    ...     URL, METHODNAME, PARAMETER1=VALUE1,...).jsonBody()

POST

For post we have webservice.post and webservice.named_post

  >>> print webservice.named_post(
  ...     URL, METHODNAME, PARAMETER1=VALUE1,...)
  HTTP/1.1 201 Created
  ...

PATCH

  >>> patch = {u'milestone_link': webservice.getAbsoluteUrl(
  ...                                 '/debian/+milestone/3.1')}
  >>> print webservice.patch(bugtask_path, 'application/json', dumps(patch))
  HTTP/1.1 209 Content Returned...

Delete

    >>> response = webservice.delete('/~eric/fooix/feature-branch')
    >>> print response
    HTTP/1.1 200 Ok
    ...

Helping handlers

There are a couple of already configured webservice handlers:

--

CategoryTesting