def _check_command_status(root: etree.Element): status = root.get("status") if status is None: raise GvmServerError("No status in response.", root) if status[0] == "4": raise GvmResponseError(status=status, message=root.get("status_text")) elif status[0] == "5": raise GvmServerError(status=status, message=root.get("status_text")) elif status[0] != "2": raise GvmError( "Error in response. {0}".format(root.get("status_text")), root)
def test_is_gvm_error(self): with self.assertRaises(GvmError): raise GvmServerError("foo", "bar")
def test_raise_with_message_and_status(self): with self.assertRaisesRegex(GvmServerError, "^Server Error foo. bar$"): raise GvmServerError("foo", "bar")
def test_is_gvm_error(self): with self.assertRaises(GvmError): raise GvmServerError('foo', 'bar')
def test_raise_with_message_and_status(self): with self.assertRaisesRegex(GvmServerError, '^GvmServerError: foo - bar$'): raise GvmServerError('foo', 'bar')