foiaghost/tests/test_record.py

35 lines
655 B
Python
Raw Normal View History

2023-07-12 04:12:40 +00:00
from beakers.record import Record
import pytest
def test_record_id_autogen():
r = Record()
assert len(r.id) == 36
r2, r3 = Record(), Record()
assert r2.id != r3.id
def test_record_id_assign():
r = Record(id="test")
assert r.id == "test"
def test_record_setattr_good():
r = Record()
r.attrib = "set"
assert r.attrib == "set"
def test_record_setattr_duplicate():
r = Record()
r.attrib = "set"
with pytest.raises(AttributeError):
r.attrib = "changed"
assert r.attrib == "set"
def test_record_setattr_id():
r = Record()
with pytest.raises(AttributeError):
r.id = "changed"