def test_format_and_validate_response_error_response(self): """ Given - raw xml response When - the response has an error code provided by qualys Then - raise a DemistoException """ with pytest.raises(DemistoException): format_and_validate_response(self.raw_xml_response_failue)
def test_format_and_validate_response_bad_format(self): """ Given - raw xml response When - the xml format is incorrect Then - return empty dictionary """ result = format_and_validate_response(self.bad_format_raw_xml_response) assert not result
def test_format_and_validate_response_bad_json(self): """ Given - raw json response When - the json response is formatted incorrectly Then - return empty result """ raw_json_response = '[{"ip": "1.1.1.1",{"ip": "1.1.1.1"}]' result = format_and_validate_response(raw_json_response) assert not result
def test_format_and_validate_response_json(self): """ Given - raw json response When - the json response is formatted correctly Then - return the raw response """ raw_json_response = '[{"ip": "1.1.1.1"},{"ip": "1.1.1.1"}]' result = format_and_validate_response(raw_json_response) assert len(result) == 2
def test_format_and_validate_response_proper_response(self): """ Given - raw xml response When - the response is valid Then - return the parsed response """ raw_json_response = format_and_validate_response(self.raw_xml_response_success) assert raw_json_response.get('SIMPLE_RETURN').get('RESPONSE') assert not raw_json_response.get('CODE')