コード例 #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
コード例 #2
0
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
コード例 #3
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
コード例 #4
0
def test_subresource_default_state():
    doc = perch.SubResource(parent=perch.Document())
    assert doc.state == perch.SubResource.default_state
コード例 #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
コード例 #6
0
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
コード例 #7
0
def test_document_default_state():
    doc = perch.Document()
    assert doc.state == perch.Document.default_state
コード例 #8
0
def test_document_state():
    doc = perch.Document(state=perch.State.approved.name)
    assert doc.state == perch.State.approved
コード例 #9
0
def test_falsey_attr():
    doc = perch.Document(x=0, y=[])

    assert doc.x == 0
    assert doc.y == []
コード例 #10
0
def test_attributeerror():
    with pytest.raises(AttributeError):
        perch.Document().x
コード例 #11
0
def test_getattr():
    doc = perch.Document(x=1, y=2)

    assert doc.x == 1
    assert doc.y == 2