omeroweb.testlib package¶
Module contents¶
Library for Web integration tests
-
class
omeroweb.testlib.IWebTest¶ Bases:
omero.testlib.ITestAbstract class derived from ITest which implements helpers for creating Django clients using django.test
-
import_image_with_metadata(client=None)¶ Imports tinyTest. This should be replaced.
-
classmethod
new_django_client(name, password)¶
-
classmethod
new_django_client_from_session_id(session_id)¶
-
classmethod
setup_class()¶ Returns a logged in Django test client.
-
classmethod
teardown_class()¶
-
-
omeroweb.testlib._csrf_delete_response(django_client, request_url, data, status_code=200, content_type=u'multipart/form-data; boundary=BoUnDaRyStRiNg')¶
-
omeroweb.testlib._csrf_delete_response_json(django_client, request_url, data, status_code=200)¶
-
omeroweb.testlib._csrf_get_response(django_client, request_url, query_string, status_code=200)¶
-
omeroweb.testlib._csrf_post_json(django_client, request_url, data, status_code=200, content_type='application/json')¶
-
omeroweb.testlib._csrf_post_response(django_client, request_url, data, status_code=200, content_type=u'multipart/form-data; boundary=BoUnDaRyStRiNg')¶
-
omeroweb.testlib._csrf_post_response_json(django_client, request_url, query_string, status_code=200)¶
-
omeroweb.testlib._csrf_put_json(django_client, request_url, data, status_code=200, content_type='application/json')¶
-
omeroweb.testlib._delete_response(django_client, request_url, data, status_code=403, content_type=u'multipart/form-data; boundary=BoUnDaRyStRiNg', **extra)¶
-
omeroweb.testlib._get_response(django_client, request_url, query_string, status_code=405)¶
-
omeroweb.testlib._get_response_json(django_client, request_url, query_string, status_code=200)¶
-
omeroweb.testlib._post_response(django_client, request_url, data, status_code=403, content_type=u'multipart/form-data; boundary=BoUnDaRyStRiNg', **extra)¶
-
omeroweb.testlib._post_response_json(django_client, request_url, data, status_code=403, content_type=u'multipart/form-data; boundary=BoUnDaRyStRiNg', **extra)¶
-
omeroweb.testlib._response(django_client, request_url, method, data=None, status_code=200, content_type=u'multipart/form-data; boundary=BoUnDaRyStRiNg', **extra)¶
-
omeroweb.testlib.csrf_response(django_client, request_url, method, data=None, status_code=200, content_type=u'multipart/form-data; boundary=BoUnDaRyStRiNg', test_csrf_required=True)¶ Helper for testing post/put/delete with and without CSRF.
Parameters: - django_client – Django test Client
- request_url – The url to request
- data – A dict of data to include as json content
- status_code – Verify that the response has this status
- content_type – Content type for request
- test_csrf_required – If True (default) check that request fails when CSRF token is not added
Parma method: Http method, e.g. ‘post’
-
omeroweb.testlib.delete_json(django_client, request_url, data=None, status_code=200)¶ Performs a DELETE request, and returns the JSON response as a dict.
Parameters: - django_client – Django test Client
- request_url – The url to request
- data – A dict of data to include as json content
- status_code – Verify that the response has this status
-
omeroweb.testlib.get(django_client, request_url, data=None, status_code=200, csrf=False)¶ Performs a GET request and returns the response.
Parameters: - django_client – Django test Client
- request_url – The url to request
- data – A dictionary of data, used to build a query string
- status_code – Verify that the response has this status
- csrf – If true, add csrf token to query string
-
omeroweb.testlib.get_json(django_client, request_url, data=None, status_code=200, csrf=False)¶ Performs a GET request and returns the JSON response as a dict.
Parameters: - django_client – Django test Client
- request_url – The url to request
- data – A dictionary of data, used to build a query string
- status_code – Verify that the response has this status
- csrf – If true, add csrf token to query string
-
omeroweb.testlib.post(django_client, request_url, data=None, status_code=200, content_type=u'multipart/form-data; boundary=BoUnDaRyStRiNg')¶ Performs a POST request, and returns the response.
Parameters: - django_client – Django test Client
- request_url – The url to request
- data – A dict of data to include as json content
- status_code – Verify that the response has this status
- content_type –
-
omeroweb.testlib.post_json(django_client, request_url, data=None, status_code=200)¶ Performs a POST request, and returns the JSON response as a dict.
Parameters: - django_client – Django test Client
- request_url – The url to request
- data – A dict of data to include as json content
- status_code – Verify that the response has this status
-
omeroweb.testlib.put_json(django_client, request_url, data=None, status_code=200)¶ Performs a PUT request, and returns the JSON response as a dict.
Parameters: - django_client – Django test Client
- request_url – The url to request
- data – A dict of data to include as json content
- status_code – Verify that the response has this status