Diff for "TestingWebServices"

Not logged in - Log In / Register

Differences between revisions 2 and 4 (spanning 2 versions)
Revision 2 as of 2010-04-12 17:11:39
Size: 1574
Editor: adiroiban
Comment:
Revision 4 as of 2010-04-12 18:12:16
Size: 1914
Editor: adiroiban
Comment:
Deletions are marked like this. Additions are marked like this.
Line 3: Line 3:
= GET = They are more like integration tests, than unit tests.

Unit tests should we added in the model.

= Accessing the webservices =

== GET ==
Line 23: Line 29:
= POST = == POST ==
Line 34: Line 40:
= PATCH = == PATCH ==
Line 43: Line 49:
= Delete = == Delete ==
Line 51: Line 57:

= Security checks =

If the permissions are already checked in the Browser code, there is no need to test them again in the Webservices.

Add only specific Webservices security checks.
Line 61: Line 74:
-- ----

Webservices are testes using doctests.

They are more like integration tests, than unit tests.

Unit tests should we added in the model.

Accessing the webservices

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
    ...

Security checks

If the permissions are already checked in the Browser code, there is no need to test them again in the Webservices.

Add only specific Webservices security checks.

Helping handlers

There are a couple of already configured webservice handlers:

  • webservice - Read access to everything. write access to all writable attributes. Logged in user salgado.

  • public_webservice - salgado-read-nonprivate ?!?!?

  • user_webservice - nopriv-read-noprivate ?!?!?!

  • anon_webservice - read access to all data available for anonymous users.


CategoryTesting

TestingWebServices (last edited 2020-07-17 15:34:39 by doismellburning)