Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions src/HttpLibrary/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,20 @@ def response_header_should_not_equal(self, header_name, not_expected):
'Response header "%s" was "%s" but should not have been.' % (
header_name, actual)

def response_header_should_contain(self, header_name, should_contain):
"""
Fails if the value of response header `header_name` does not contain
`should_contain`. Also fails if the last response does not have a
`header_name` header.
"""
self.response_should_have_header(header_name)
actual = self.response.headers[header_name]
logger.debug('Testing whether "%s" contains "%s".' % (
actual, should_contain))
assert should_contain in actual, \
'Response header "%s" s value of "%s" should have contained "%s", but did not.' % (
header_name, actual, should_contain)

def log_response_headers(self, log_level='INFO'):
"""
Logs the response headers, line by line.
Expand Down Expand Up @@ -551,6 +565,23 @@ def stringify_json(self, data):
except ValueError, e:
raise ValueError(
"Could not stringify '%r' to JSON: %s" % (data, e))

def minify_json(self, data):
"""
Converts JSON string to a minified JSON String

Example:
| ${data} = | Get Response Body|
| ${json_string}= | Minify JSON | ${data} |

`data` is the json string to convert to json
"""

try:
return json.dumps(data, separators=(',',':'))
except ValueError, e:
raise ValueError(
"Could not minify '%r' to JSON: %s" % (data, e))

@_with_json
def get_json_value(self, json_string, json_pointer):
Expand Down