def test_nonempty_keys(self): test_parameters = [("title", ""), ("description", ""), ("bug-numbers", [])] for key, empty in test_parameters: definition = self.make_test_features({key: empty}) with self.assertRaises(voluptuous.Error) as context: feature_schema(definition) assert "length of value must be at least" in str(context.exception) assert "['{}']".format(key) in str(context.exception)
def test_required_fields(self): required_keys = [ 'title', 'description', 'bug-numbers', 'restart-required', 'type' ] for key in required_keys: definition = self.make_test_features({'id': 'test-feature'}) del definition['test-feature'][key] with self.assertRaises(voluptuous.Error) as context: feature_schema(definition) assert 'required key not provided' in str(context.exception) assert key in str(context.exception)
def test_required_fields(self): required_keys = [ "title", "description", "bug-numbers", "restart-required", "type", ] for key in required_keys: definition = self.make_test_features({"id": "test-feature"}) del definition["test-feature"][key] with self.assertRaises(voluptuous.Error) as context: feature_schema(definition) assert "required key not provided" in str(context.exception) assert key in str(context.exception)
def test_extra_keys_not_allowed(self): definition = self.make_test_features({'unexpected_key': 'oh no!'}) with self.assertRaises(voluptuous.Error) as context: feature_schema(definition) assert 'extra keys not allowed' in str(context.exception)
def test_minimal_valid(self): definition = self.make_test_features() # should not raise an exception feature_schema(definition)