Esempio n. 1
0
def test_filter_by_subject():
    """Test Actions through their implementation in Encyclopaedia."""

    enc = Encyclopaedia()

    expected_entries = []

    for x in range(5):
        e = EncEntry(
            parent=enc,
            name="Test Name",
            text=["Test Text"],
            subject="Robots"
        )

        expected_entries.append(e)

    for x in range(5):
        EncEntry(
            parent=enc,
            name="Test Name",
            text=["Test Text"],
            subject="Humans"
        )

    enc.FilterBySubject("Robots")()

    assert "Robots" == enc.filtering
    assert expected_entries == enc.filtered_entries
def test_filtering():
    enc = Encyclopaedia()

    apple = EncEntry(
        parent=enc,
        name="Apple",
        text=["Test Text"],
        subject="Fruits"
    )

    banana = EncEntry(
        parent=enc,
        name="Banana",
        text=["Test Text"],
        subject="Fruits"
    )

    cantaloupe = EncEntry(
        parent=enc,
        name="Cantaloupe",
        text=["Test Text"],
        subject="Fruits"
    )

    cucumber = EncEntry(
        parent=enc,
        name="Cucumber",
        text=["Test Text"],
        subject="Vegetables"
    )

    enc.FilterBySubject("Fruits")()

    assert "Fruits" == enc.filtering
    assert [apple, banana, cantaloupe] == enc.current_entries