feat: catalog Record dict conversion
This commit is contained in:
@@ -69,3 +69,26 @@ def test_empty_id_raises():
|
||||
def test_negative_duration_raises():
|
||||
with pytest.raises(CatalogError):
|
||||
validate(make_record(duration_s=-1))
|
||||
|
||||
|
||||
from hef.catalog import record_to_dict, record_from_dict
|
||||
|
||||
|
||||
def test_dict_round_trip():
|
||||
record = make_record()
|
||||
restored = record_from_dict(record_to_dict(record))
|
||||
assert restored == record
|
||||
|
||||
|
||||
def test_record_from_dict_rejects_unknown_field():
|
||||
data = record_to_dict(make_record())
|
||||
data["bogus"] = 1
|
||||
with pytest.raises(CatalogError):
|
||||
record_from_dict(data)
|
||||
|
||||
|
||||
def test_record_from_dict_rejects_missing_required_field():
|
||||
data = record_to_dict(make_record())
|
||||
del data["title"]
|
||||
with pytest.raises(CatalogError):
|
||||
record_from_dict(data)
|
||||
|
||||
Reference in New Issue
Block a user