Esempio n. 1
0
 def test_post_sale_timeout(self, test_app):
     with test_app.app_context():
         with test_app.app_context():
             sale = SaleDB.create(**TEST_SALE)
             with pytest.raises(Timeout) as err:
                 SaleDB.post_sale(sale.id, timeout=0.001)
             assert sale.status == Sale.STATUS_TIMEOUT
             assert str(err.value) == sale.error_msg
Esempio n. 2
0
 def test_post_sale_incorrect_item(self, test_app):
     with test_app.app_context():
         sale = SaleDB.create(**TEST_SALE)
         SaleDB.update(id=sale.id, item_id=1)  # Set to nonexistent item id
         with pytest.raises(HTTPError) as err:
             SaleDB.post_sale(sale.id)
         assert '404' in str(err.value)
         assert sale.status == Sale.STATUS_HTTP_ERROR
         assert str(err.value) == sale.error_msg
Esempio n. 3
0
 def test_post_sale_no_sdd(self, test_app):
     with test_app.app_context():
         sale = SaleDB.create(**TEST_SALE)
         SaleDB.update(
             id=sale.id,
             user_id=TEST_USER_NO_SDD['id'])  # Set to no sdd user id
         with pytest.raises(api.UserNotSignedException) as err:
             SaleDB.post_sale(sale.id)
         assert '403' in str(err.value) and 'mandate' in str(err.value)
         assert sale.status == Sale.STATUS_SDD_NOT_SIGNED
         assert str(err.value) == sale.error_msg
Esempio n. 4
0
def sale():
    # quantity = request.form['quantity']
    # item_id = request.form['item-id']
    # user_id = session['user_id']

    # TODO: remove the following test parameters and uncomment the block above
    quantity = 1
    item_id = 13591
    user_id = 347980

    item = ItemDB.get(item_id)
    user = UserDB.get(user_id)
    sale = SaleDB.create_quick(quantity=quantity,
                               item_id=item_id,
                               user_id=user_id)

    try:
        sale = SaleDB.post_sale(sale.id)
    except Streeplijst2Warning as err:
        flash(str(err))

    meta_folders = FOLDERS  # The folder metas for all folders are loaded to display at top of the screen
    return render_template('checkout.jinja2',
                           meta_folders=meta_folders,
                           sale=sale,
                           item=item,
                           user=user)
Esempio n. 5
0
 def test_post_sale(self, test_app):
     with test_app.app_context():
         sale = SaleDB.create(**TEST_SALE)
         SaleDB.post_sale(sale.id)