Exemple #1
0
def _validate_allowed_keys(keys, available_keys, scope):
    """Private function that checks if the spec keys are allowed.

    Args:
        keys [list of strings]: the specification keys
        available_keys [tuple of string]: the available keys for that scope
        scope [string]: the scope of the current node: 'root', 'endpoint',
        'request' or 'test'

    """
    for key in keys:
        if key not in available_keys:
            raise InvalidKeyError(key, scope, available_keys)
Exemple #2
0
    def options(self):
        endpoint_options = self.endpoint.options
        options = self.spec.get(OPTIONS_KEY, {})

        for option in options:
            if option not in self.ALLOWED_OPTIONS:
                raise InvalidKeyError(option, OPTIONS_KEY,
                                      self.ALLOWED_OPTIONS)

        return self.endpoint.spec_vars.evaluate({
            **endpoint_options,
            **options
        })
Exemple #3
0
    def options(self):
        """Get the keywords arguments used in the endpoint call.
        The options of the call include the parent's options.

        Returns:
            [dict]: the keyword used in the endpoint call.
        """
        options = self._get_specs(OPTIONS_KEY)
        for option in options:
            if option not in self.ALLOWED_OPTIONS:
                raise InvalidKeyError(option, OPTIONS_KEY,
                                      self.ALLOWED_OPTIONS)

        return options
Exemple #4
0
def validate_keys(keys, available_keys, scope):
    for key in keys:
        if not key in available_keys:
            raise InvalidKeyError(key, scope, available_keys)
Exemple #5
0
def invalid_key(*args, **kwargs):
    raise InvalidKeyError("foo", "endpoint", ["bar", "other"])
Exemple #6
0
def _validate_allowed_keys(keys, available_keys, scope):
    """ Private function that checks validation of allowed keys. """
    for key in keys:
        if key not in available_keys:
            raise InvalidKeyError(key, scope, available_keys)