How to use the scanapi.errors.MalformedSpecError function in scanapi

To help you get started, we’ve selected a few scanapi examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github camilamaia / scanapi / scanapi / errors.py View on Github external
"""Raised when 'api' key is not specified at root scope in the API spec"""

    def __init__(self, *args):
        message = "Missing api 'key' at root scope in the API spec"
        super(APIKeyMissingError, self).__init__(message, *args)


class InvalidKeyError(MalformedSpecError):
    """Raised when an invalid key is specified in the API spec"""

    def __init__(self, key, scope, available_keys, *args):
        message = f"Invalid key '{key}' at '{scope}' scope. Available keys are: {available_keys}"
        super(InvalidKeyError, self).__init__(message, *args)


class MissingMandatoryKeyError(MalformedSpecError):
    """Raised when one or more mandatory keys are missing"""

    def __init__(self, missing_keys, scope, *args):
        missing_keys_str = ", ".join(f"'{k}'" for k in sorted(missing_keys))
        message = f"Missing {missing_keys_str} key(s) at '{scope}' scope"
        super(MissingMandatoryKeyError, self).__init__(message, *args)


class InvalidPythonCodeError(MalformedSpecError):
    """Raised when python code defined in the API spec raises an error"""

    def __init__(self, error_message, code, *args):
        error_message = (
            f"Invalid Python code defined in the API spec. "
            f"Exception: {error_message}. "
            f"Code: {code}."
github camilamaia / scanapi / scanapi / errors.py View on Github external
class MalformedSpecError(Exception):
    pass


class HTTPMethodNotAllowedError(MalformedSpecError):
    """Raised when the HTTP method in the API spec is invalid"""

    def __init__(self, method, allowed_methos, *args):
        message = (
            f"HTTP method not supported: {method}. Supported methods: {allowed_methos}."
        )
        super(HTTPMethodNotAllowedError, self).__init__(message, *args)


class APIKeyMissingError(MalformedSpecError):
    """Raised when 'api' key is not specified at root scope in the API spec"""

    def __init__(self, *args):
        message = "Missing api 'key' at root scope in the API spec"
        super(APIKeyMissingError, self).__init__(message, *args)


class InvalidKeyError(MalformedSpecError):
    """Raised when an invalid key is specified in the API spec"""

    def __init__(self, key, scope, available_keys, *args):
        message = f"Invalid key '{key}' at '{scope}' scope. Available keys are: {available_keys}"
        super(InvalidKeyError, self).__init__(message, *args)


class MissingMandatoryKeyError(MalformedSpecError):
github camilamaia / scanapi / scanapi / errors.py View on Github external
def __init__(self, key, scope, available_keys, *args):
        message = f"Invalid key '{key}' at '{scope}' scope. Available keys are: {available_keys}"
        super(InvalidKeyError, self).__init__(message, *args)


class MissingMandatoryKeyError(MalformedSpecError):
    """Raised when one or more mandatory keys are missing"""

    def __init__(self, missing_keys, scope, *args):
        missing_keys_str = ", ".join(f"'{k}'" for k in sorted(missing_keys))
        message = f"Missing {missing_keys_str} key(s) at '{scope}' scope"
        super(MissingMandatoryKeyError, self).__init__(message, *args)


class InvalidPythonCodeError(MalformedSpecError):
    """Raised when python code defined in the API spec raises an error"""

    def __init__(self, error_message, code, *args):
        error_message = (
            f"Invalid Python code defined in the API spec. "
            f"Exception: {error_message}. "
            f"Code: {code}."
        )
        super(InvalidPythonCodeError, self).__init__(error_message, *args)


class BadConfigurationError(Exception):
    """Raised when an environment variable was not set or was badly configured"""

    def __init__(self, env_var, *args):
        super(BadConfigurationError, self).__init__(
github camilamaia / scanapi / scanapi / errors.py View on Github external
class MalformedSpecError(Exception):
    pass


class HTTPMethodNotAllowedError(MalformedSpecError):
    """Raised when the HTTP method in the API spec is invalid"""

    def __init__(self, method, allowed_methos, *args):
        message = (
            f"HTTP method not supported: {method}. Supported methods: {allowed_methos}."
        )
        super(HTTPMethodNotAllowedError, self).__init__(message, *args)


class APIKeyMissingError(MalformedSpecError):
    """Raised when 'api' key is not specified at root scope in the API spec"""

    def __init__(self, *args):
        message = "Missing api 'key' at root scope in the API spec"
        super(APIKeyMissingError, self).__init__(message, *args)
github camilamaia / scanapi / scanapi / errors.py View on Github external
def __init__(self, method, allowed_methos, *args):
        message = (
            f"HTTP method not supported: {method}. Supported methods: {allowed_methos}."
        )
        super(HTTPMethodNotAllowedError, self).__init__(message, *args)


class APIKeyMissingError(MalformedSpecError):
    """Raised when 'api' key is not specified at root scope in the API spec"""

    def __init__(self, *args):
        message = "Missing api 'key' at root scope in the API spec"
        super(APIKeyMissingError, self).__init__(message, *args)


class InvalidKeyError(MalformedSpecError):
    """Raised when an invalid key is specified in the API spec"""

    def __init__(self, key, scope, available_keys, *args):
        message = f"Invalid key '{key}' at '{scope}' scope. Available keys are: {available_keys}"
        super(InvalidKeyError, self).__init__(message, *args)


class MissingMandatoryKeyError(MalformedSpecError):
    """Raised when one or more mandatory keys are missing"""

    def __init__(self, missing_keys, scope, *args):
        missing_keys_str = ", ".join(f"'{k}'" for k in sorted(missing_keys))
        message = f"Missing {missing_keys_str} key(s) at '{scope}' scope"
        super(MissingMandatoryKeyError, self).__init__(message, *args)