def test_viewed_callback_change_entry():
    enc = Encyclopaedia()

    e = EncEntry(
        parent=enc,
        name="Test Name",
        text=["Test Text"]
    )

    e2 = EncEntry(
        parent=enc,
        name="Test Name",
        text=["Test Text"]
    )

    global i
    i = 0

    def cb(*args):
        global i
        i += 1

    e2.viewed_callback = (cb,)

    assert 0 == i

    enc.SetEntry(e)()
    assert 0 == i

    enc.NextEntry()()

    assert 1 == i
Example #2
0
def test_next_entry():
    """Test Actions through their implementation in Encyclopaedia."""

    enc = Encyclopaedia()

    for x in range(0, 5):
        EncEntry(parent=enc,
                 name="Test Name {}".format(x + 1),
                 text=["Test Text"],
                 locked=False)

    assert 0 == enc.current_position

    enc.NextEntry()()

    assert enc.current_entries[1] == enc.active
    assert enc.current_entries[1].viewed
    assert 1 == enc.current_position
Example #3
0
def test_viewed_callback_change_entry():
    enc = Encyclopaedia()

    e = EncEntry(parent=enc, name="Test Name", text=["Test Text"])

    e2 = EncEntry(parent=enc, name="Test Name", text=["Test Text"])

    global i
    i = 0

    @e2.on("viewed")
    def cb(entry):
        global i
        i += 1

    assert 0 == i

    enc.SetEntry(e)()
    assert 0 == i

    enc.NextEntry()()

    assert 1 == i