"""Module for easy mocking inside of tests. It is very easy to use: from owsrequest.utils import mock_request def test_smth(): mock = mock_request.get('ows_features', '/path/to/smth', status=500) do_smth() assert mock.called """ from owsrequest.utils import fixture_plugin def _add_test_signature(method, service, path, response=None, status=200): return fixture_plugin.request_engine[service].add_spec( method, path, response=response, status=status) def get(service, path, response=None, status=200): """Add GET method mock specification.""" return _add_test_signature('GET', service, path, response, status) def head(service, path, response=None, status=200): """Add HEAD method mock specification.""" return _add_test_signature('HEAD', service, path, response, status) def options(service, path, response=None, status=200): """Add OPTIONS method mock specification.""" return _add_test_signature('OPTIONS', service, path, response, status) def post(service, path, response=None, status=200): """Add POST method mock specification.""" return _add_test_signature('POST', service, path, response, status) def put(service, path, response=None, status=200): """Add PUT method mock specification.""" return _add_test_signature('PUT', service, path, response, status) def delete(service, path, response=None, status=200): """Add DELETE method mock specification.""" return _add_test_signature('DELETE', service, path, response, status) def any(service, path, response=None, status=200): """Add specification for any method by path.""" return _add_test_signature('*', service, path, response, status)