Library version: | 1.0.1 |
---|---|
Library scope: | global |
Named arguments: | supported |
Robot Framework library for interacting with WireMock
The purpose of this library is to provide a keyword-based API towards WireMock to be used in robot tests. The project is hosted in GitHub, and packages are released to PyPI.
pip install robotframework-wiremock
The library does not currently support any import arguments, so use the following setting to take the library into use:
Library | WireMockLibrary |
Keyword | Arguments | Documentation |
---|---|---|
Create Default Mock Mapping | method, url, status=200, status_message=None, response_headers=None, response_body=None, template=False | Creates a default expectation to be used by wiremock. method is the HTTP method of the mocked endpoint url is the url pattern of the mocked endpoint(s), e.g. /.*api.* status is the HTTP status code of the response status_message is the HTTP status message of the response response_headers is a dictionary of headers to be added to the response response_body is a dictonary of JSON attribute(s) to be added to the response body template is a boolean value which specifies whether to use templating in the response, e.g. for copying a parameter, header or body value from the request to the response |
Create Mock Mapping | request, response | Creates an mapping to be used by wiremock. request is a mock request matcher in a dictionary format. response is a mock response in a dictionary format. |
Create Mock Mapping With Data | data | Creates a mapping with defined data to be used by wiremock. data is a dictionary or JSON string with mapping data. Please see WireMock documentation for the detailed API reference. |
Create Mock Request Matcher | method, url, url_match_type=urlPath, query_parameters=None, headers=None, cookies=None, json_body=None, regex_matching=False | Creates a mock request matcher to be used by wiremock. Returns the request matcher in a dictionary format. method is the HTTP method of the mocked endpoint url is the url or url pattern of the mocked endpoint, e.g. /api or /api.* url_match_type is the wiremock url match pattern to use. Applicable values are:
query_parameters is a dictionary of query parameters to match headers is a dictionary containing headers to match (case-insensitive matching) cookies is a dictionary containing cookies to match json_body is a dictionary of the json attribute(s) to match regex_matching is a boolean value which, if enabled, uses regex to match query parameter and header values |
Create Mock Response | status, status_message=None, headers=None, json_body=None, template=False | Creates a mock response to be used by wiremock. Returns the response in a dictionary format. status is the HTTP status code of the response status_message is the HTTP status message of the response headers is a dictionary of headers to be added to the response json_body is a dictonary of JSON attribute(s) to be added to the response body template is a boolean value which specifies whether to use templating in the response, e.g. for copying a parameter, header or body value from the request to the response |
Create Mock Session | base_url | Creates an HTTP session towards wiremock. base_url is the full url (including port, if applicable) of the WireMock server, e.g. http://localhost:8080. |
Get Previous Request | url, method=None | Returns the last request received by wiremock for a given url pattern. url is the url pattern of the endpoint(s), e.g. /.*api.* method is the HTTP method of the request |
Get Previous Request Body | url, method=None | Returns the body of the last request received by wiremock for a given url pattern in dictionary form. url is the url pattern of the endpoint(s), e.g. /.*api.* method is the HTTP method of the request |
Get Requests | url, method=None | Returns an array containing all requests received by wiremock for a given url pattern. url is the url pattern of the endpoint(s), e.g. /.*api.* method is the HTTP method of the requests |
Reset Mock Mappings | Resets all mock mappings on the wiremock server. | |
Reset Request Log | Resets all logged requests on the wiremock server. |