assertkapacitor_response.status_code==200,"Handler with ID {0} for topic with ID {1} doesn't exist - test file {2}".format(handler_id,topic_id,test_file_path)
kapacitor_response_json=kapacitor_response.json()
assertkapacitor_response_json["id"]==handler_id,"Incorrect ID of handler {0} in the Kapacitor response - test file {1}".format(handler_id,test_file_path)
assertkapacitor_response_json["kind"]=="post","Incorrect kind of handler {0} in the Kapacitor response - test file {1}".format(handler_id,test_file_path)
assertkapacitor_response_json["options"]["url"],"Incorrect url of handler {0} in the Kapacitor response - test file {1}".format(handler_id,test_file_path)
break
clear_kapacitor_alerts(alert_ids,topic_handlers)
classFieldStorageMock(object):
...
...
@@ -164,3 +205,59 @@ class FieldStorageMock(object):
self.filename=filename
self.file=file
defextract_alert_spec_data(alert_spec):
"""
A utility function to extract the expected alert, handler and topic identifiers from a given alert specification.
:param alert_spec: the alert specification file (file object)
:return: a tuple containing sfc_id and sfc_instance_id along with a list and a dictionary of generated IDs (alert IDs (list), topic IDs linked to handler IDs (dict))
topic_handlers={}# saves all topics in a dictionary, each topic is linked to a list of handler pairs (a handler pair consists of handler id and handler url)