Exemple #1
0
    def all_pets():
        user_login = user()
        all_ads_count_result = db.all_ads_count(db.open_db(db_url))
        number_of_ads = all_ads_count_result['count_ads']
        number_of_pages = math.ceil(number_of_ads / ADDS_PER_PAGE)
        all_pets_result = db.all_pets(db.open_db(db_url),
                                      ADDS_PER_PAGE,
                                      pages_offset=0)
        if 'pages_offset' in request.args.keys():
            pages_offset = request.args.get('pages_offset')
            all_pets_result = db.all_pets(db.open_db(db_url), ADDS_PER_PAGE,
                                          pages_offset)

        return render_template('index.html',
                               pets=all_pets_result,
                               active_index='all_pets',
                               user_login=user_login,
                               number_of_pages=number_of_pages,
                               limit=ADDS_PER_PAGE)
Exemple #2
0
def test_all_ads_count_another():
    expected = 1
    actual_1 = db.all_ads_count(open_db(db_url), category='Прочие')
    actual = actual_1['count_ads']
    assert expected == actual
Exemple #3
0
def test_all_ads_count_cats():
    expected = 2
    actual_1 = db.all_ads_count(open_db(db_url), category='Кошка')
    actual = actual_1['count_ads']
    assert expected == actual
Exemple #4
0
def test_all_ads_count():
    expected = 5
    actual_1 = db.all_ads_count(open_db(db_url), category=None)
    actual = actual_1['count_ads']
    assert expected == actual