def test_parent_overrides_subresource_state(): doc = perch.SubResource( state=perch.State.approved.name, parent=perch.Document(state=perch.State.rejected.name)) assert doc.state == perch.State.rejected doc = perch.SubResource( state=perch.State.pending.name, parent=perch.Document(state=perch.State.approved.name)) assert doc.state == perch.State.pending
def test_state_transition_with_approval(start, end, valid): user = perch.User() doc = perch.Document(state=start) perch.Document.can_approve = MagicMock(return_value=make_future(True)) func = partial(doc.validate_state_transition, user, start, end) result = IOLoop.instance().run_sync(func) assert result == valid
def test_subresource_with_state_object(): """Accept a state object in __init__""" doc = perch.SubResource(state=perch.State.approved, parent=perch.Document(state=perch.State.approved)) assert doc.state == perch.State.approved
def test_subresource_default_state(): doc = perch.SubResource(parent=perch.Document()) assert doc.state == perch.SubResource.default_state
def test_subresource_state(): doc = perch.SubResource( state=perch.State.approved.name, parent=perch.Document(state=perch.State.approved.name)) assert doc.state == perch.State.approved
def test_document_with_state_object(): """Accept a state object in __init__""" doc = perch.Document(state=perch.State.approved) assert doc.state == perch.State.approved
def test_document_default_state(): doc = perch.Document() assert doc.state == perch.Document.default_state
def test_document_state(): doc = perch.Document(state=perch.State.approved.name) assert doc.state == perch.State.approved
def test_falsey_attr(): doc = perch.Document(x=0, y=[]) assert doc.x == 0 assert doc.y == []
def test_attributeerror(): with pytest.raises(AttributeError): perch.Document().x
def test_getattr(): doc = perch.Document(x=1, y=2) assert doc.x == 1 assert doc.y == 2