Exemple #1
0
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
Exemple #2
0
def test_subresource_state_without_parent():
    doc = perch.SubResource()

    with pytest.raises(Exception):
        doc.state
Exemple #3
0
def test_subresource_default_state():
    doc = perch.SubResource(parent=perch.Document())
    assert doc.state == perch.SubResource.default_state
Exemple #4
0
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
Exemple #5
0
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