def test_should_not_raise_an_exception(self): keys = ["key1"] available_keys = ("key1", "key3") mandatory_keys = ("key1", ) scope = "endpoint" validate_keys(keys, available_keys, mandatory_keys, scope)
def _validate(self): if self.is_root: return validate_keys(self.spec.keys(), self.ALLOWED_KEYS, self.ROOT_REQUIRED_KEYS, ROOT_SCOPE) validate_keys(self.spec.keys(), self.ALLOWED_KEYS, self.REQUIRED_KEYS, self.SCOPE)
def _validate(self): """Validate spec keys. Returns: None """ validate_keys(self.spec.keys(), self.ALLOWED_KEYS, self.REQUIRED_KEYS, self.SCOPE)
def _validate(self): """Private method that checks if the specification has any invalid key or if there is any required key missing. """ required_keys = (self.ROOT_REQUIRED_KEYS if self.is_root else self.REQUIRED_KEYS) scope = ROOT_SCOPE if self.is_root else self.SCOPE validate_keys(self.spec.keys(), self.ALLOWED_KEYS, required_keys, scope)
def test_should_raise_an_exception(self): keys = ["key1"] available_keys = ("key1", "key3") mandatory_keys = ("key1", "key2") scope = "endpoint" with pytest.raises(MissingMandatoryKeyError) as excinfo: validate_keys(keys, available_keys, mandatory_keys, scope) assert str(excinfo.value) == "Missing 'key2' key(s) at 'endpoint' scope"
def test_should_raise_an_exception(self): keys = ["key1", "key2"] available_keys = ("key1", "key3") scope = "endpoint" with pytest.raises(InvalidKeyError) as excinfo: validate_keys(keys, available_keys, scope) assert ( str(excinfo.value) == "Invalid key 'key2' at 'endpoint' scope. Available keys are: ('key1', 'key3')" )
def _validate(self): validate_keys(self.spec.keys(), self.ALLOWED_KEYS, self.REQUIRED_KEYS, self.SCOPE)