def test_part_validation_missing(): data = { "plugin": "make", "make-parameters": ["-C bar"], } error = r"source\s+field required" with pytest.raises(pydantic.ValidationError, match=error): validate_part(data)
def test_part_validation_extra(): data = { "plugin": "make", "source": "foo", "make-parameters": ["-C bar"], "unexpected-extra": True, } error = r"unexpected-extra\s+extra fields not permitted" with pytest.raises(pydantic.ValidationError, match=error): validate_part(data)
def test_part_validation_immutable(): data = { "plugin": "make", "source": "foo", "make-parameters": ["-C bar"], } data_copy = copy.deepcopy(data) validate_part(data) assert data == data_copy
def test_part_validation_data_type(): with pytest.raises(TypeError) as raised: validate_part("invalid data") # type: ignore assert str(raised.value) == "value must be a dictionary"
def _validate_parts(cls, item): """Verify each part (craft-parts will re-validate this).""" parts_validation.validate_part(item) return item