Exemplo n.º 1
0
 def index():
     from flask import request
     search = request.args.get('search')
     if search:
         results = search_book(container, search)
         return render_template('in.html', books=results)
     return render_template('in.html', books=container, search=search)
Exemplo n.º 2
0
def test_search_book_by_tags():
    data = [{
        'title': 'Робинзон Крузо',
        'author': 'Даниэль Дефо',
        'price': 1,
        'tags': ['#остров', '#одиночество']
    }, {
        'title': 'Анна Каренина',
        'author': 'Лев Толстой',
        'price': 800,
        'tags': ['#поезд', '#любовь']
    }]
    expected = [{
        'title': 'Анна Каренина',
        'author': 'Лев Толстой',
        'price': 800,
        'tags': ['#поезд', '#любовь']
    }]
    actual = search_book(data, '#любовь')
    assert expected == actual
Exemplo n.º 3
0
def test_search_book_by_title():
    data = [{
        'title': 'Война',
        'author': 'Толстой',
        'price': 1,
        'tags': ['#война', '#дуб']
    }, {
        'title': 'Анна Каренина',
        'author': 'Лев Толстой',
        'price': 800,
        'tags': ['#поезд', '#любовь']
    }]
    expected = [{
        'title': 'Война',
        'author': 'Толстой',
        'price': 1,
        'tags': ['#война', '#дуб']
    }]
    actual = search_book(data, 'Война')
    assert expected == actual
Exemplo n.º 4
0
 def index():
     search = request.args.get('search')
     if search:
         results = search_book(container, search)
         return render_template('index.html', books=results, search=search)
     return render_template('index.html', books=container)