示例#1
0
def test_get_top_5_books(content):
    books = get_top_books(content=content)
    assert books == [
        'Man’s Search For Meaning',
        ('The 4-Hour Workweek: Escape the 9-5, '
         'Live Anywhere and Join the New Rich'), 'The Fountainhead',
        'Sapiens: A Brief History of Humankind', 'Tao Te Ching'
    ]
示例#2
0
def test_get_top_5_books(content):
    books = get_top_books(content=content)
    assert books == [
        "Man’s Search For Meaning",
        ("The 4-Hour Workweek: Escape the 9-5, "
         "Live Anywhere and Join the New Rich"),
        "The Fountainhead",
        "Sapiens: A Brief History of Humankind",
        "Tao Te Ching",
    ]
示例#3
0
def test_get_top_10_books(content):
    books = get_top_books(content=content, limit=10)
    assert books[5:] == [('The Better Angels of our Nature: Why Violence '
                          'Has Declined'),
                         ('The Beginning of Infinity: Explanations That '
                          'Transform '
                          'the World'),
                         ('The War of Art: Break Through the Blocks and Win '
                          'Your Inner Creative Battles'),
                         'The Hero with a Thousand Faces ',
                         'Poor Charlie’s Almanack']
示例#4
0
def test_get_top_10_books(content):
    books = get_top_books(content=content, limit=10)
    assert books[5:] == [
        ("The Better Angels of our Nature: Why Violence "
         "Has Declined"),
        ("The Beginning of Infinity: Explanations That "
         "Transform "
         "the World"),
        ("The War of Art: Break Through the Blocks and Win "
         "Your Inner Creative Battles"),
        "The Hero with a Thousand Faces ",
        "Poor Charlie’s Almanack",
    ]
示例#5
0
def test_counts(content, title, count):
    books = get_top_books(content=content)
    assert (title, count) in books
示例#6
0
def test_return(content):
    books = get_top_books(content=content)
    assert len(books) == 16
    assert type(books) == list
    assert all(type(book) == tuple for book in books)
示例#7
0
from tribe import load_page, get_top_books

content = load_page()  # make sure we do this once!
books = get_top_books(content=content)


def test_books_6_occurrences():
    assert books[0] == 'Man’s Search For Meaning'


def test_books_5_occurrences():
    assert books[1] == 'Tao Te Ching'


def test_books_4_occurrences():
    assert sorted(books[2:5]) == [
        'Sapiens: A Brief History of Humankind',
        ('The 4-Hour Workweek: Escape the 9-5, Live '
         'Anywhere and Join the New Rich'), 'The Fountainhead'
    ]  # 4x