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)
def test_create_quick_sale(self, test_app): with test_app.app_context(): item = ItemDB.create(**TEST_ITEM) user = UserDB.create(**TEST_USER) sale = SaleDB.create_quick(quantity=1, item_id=item.id, user_id=user.id) for (key, value) in TEST_SALE.items( ): # Make sure all fields are stored correctly assert sale.__getattribute__(key) == value assert sale.id == 1 # The ID autoincrements, starting at 1 assert sale.status == Sale.STATUS_NOT_POSTED # Test the status assert sale.api_id is None and sale.api_created is None and sale.error_msg is None # Test None fields