def test_update_processing_when_done_above_1(add_wall): wall = Wall.query.first() Wall.add_processing(wall.id, year=2020, month="December", done=0.6) processing = wall.processing[0] Wall.edit_processing(processing.id, done=1.35) assert wall.processing[0].done == 1.0 assert wall.left_to_sale == 0.0
def test_add_processing_when_overrun(add_wall): wall = Wall.query.first() Wall.add_processing(wall.id, year=2020, month="December", done=0.4) Wall.add_processing(wall.id, year=2020, month="December", done=0.7) wall = Wall.query.filter_by(id=wall.id).first() assert wall.processing.filter_by(id=1).first().done == 0.4 assert wall.processing.filter_by(id=2).first().done == 0.6 assert wall.left_to_sale == 0.0
def test_add_wall(app_and_db, wall_data): Wall.add_wall(**wall_data) wall = Wall.query.first() Wall.add_hole(wall.id, width=1.2, height=2.0, amount=2) Wall.add_hole(wall.id, width=2.2, height=2.0, amount=1) Wall.add_processing(wall.id, year=2020, month="December", done=0.4) assert wall.wall_height == 3.1 assert wall.gross_wall_area == 32.55 assert wall.wall_area_to_survey == 23.35 assert wall.wall_area_to_sale == 29.15 assert wall.left_to_sale == 0.6
def test_update_processing_when_overrun(add_wall): wall = Wall.query.first() Wall.add_processing(wall.id, year=2020, month="December", done=0.6) Wall.add_processing(wall.id, year=2020, month="December", done=0.3) assert wall.processing.filter_by(id=1).first().done == 0.6 assert wall.processing.filter_by(id=2).first().done == 0.3 assert wall.left_to_sale == 0.1 Wall.edit_processing(2, done=0.5) assert wall.processing.filter_by(id=1).first().done == 0.6 assert wall.processing.filter_by(id=2).first().done == 0.4 assert wall.left_to_sale == 0.0
def add_processing() -> str: wall_id = request.args.get("wall_id") form = ProcessingForm() if form.validate_on_submit(): Wall.add_processing(wall_id, **form.data) flash("You added a new processing.") next_page = request.args.get("next_page") if not next_page: next_page = url_for("masonry_works.modify", wall_id=wall_id) return redirect(next_page) return render_template( "production/masonry_works/forms/processing_form.html", title="Add Processing", form=form, )
def test_update_processing(add_wall): wall = Wall.query.first() Wall.add_processing(wall.id, year=2020, month="December", done=0.3) assert wall.processing[0].year == 2020 assert wall.processing[0].month == "December" assert wall.processing[0].done == 0.3 assert wall.left_to_sale == 0.7 processing = wall.processing[0] Wall.edit_processing(processing.id, year=2021, month="January", done=0.6) assert wall.processing[0].year == 2021 assert wall.processing[0].month == "January" assert wall.processing[0].done == 0.6 assert wall.left_to_sale == 0.4
def add_processing(app_and_db): Wall.add_processing(wall_id=1, year=2020, month="December", done=0.4)
def test_delete_processing(add_wall): Wall.add_processing(wall_id=1, year=2020, month="December", done=0.5) assert Processing.query.filter_by(id=1).first() Wall.delete_processing(1) assert not Processing.query.filter_by(id=1).first()
def test_delete_wall(add_wall): Wall.add_hole(wall_id=1, width=1, height=2, amonunt=1) Wall.add_processing(wall_id=1, year=2020, month="December", done=0.5) assert Wall.query.filter_by(id=1).first() Wall.delete_wall(1) assert not Wall.query.filter_by(id=1).first()
def test_add_processing_when_done_above_1(add_wall): wall = Wall.query.first() Wall.add_processing(wall.id, year=2020, month="December", done=2) wall = Wall.query.filter_by(id=wall.id).first() assert wall.processing[0].done == 1.0 assert wall.left_to_sale == 0.0
def test_add_processing(add_wall): wall = Wall.query.first() assert wall.left_to_sale == 1.0 Wall.add_processing(wall.id, year=2020, month="December", done=0.4) Wall.add_processing(wall.id, year=2020, month="December", done=0.5) assert wall.left_to_sale == 0.1