def test_add_hole_without_height(add_wall): wall = Wall.query.first() Wall.add_hole(wall.id, width=1.2, amount=2) hole = Hole.query.first() assert hole.height == None with pytest.raises(ValueError): assert hole.area
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_hole(add_wall): wall = Wall.query.first() Wall.add_hole(wall.id, width=1.2, height=2.0, amount=2) assert wall.holes[0].width == 1.2 assert wall.holes[0].height == 2.0 assert wall.holes[0].amount == 2 assert wall.wall_area_to_survey == 27.75 hole = wall.holes[0] Wall.edit_hole(hole.id, width=1.5, height=2.5, amount=1) assert wall.holes[0].width == 1.5 assert wall.holes[0].height == 2.5 assert wall.holes[0].amount == 1 assert wall.wall_area_to_survey == 28.8
def add_hole() -> str: wall_id = request.args.get("wall_id") form = HoleForm() if form.validate_on_submit(): Wall.add_hole(wall_id, **form.data) flash("You added a new hole.") 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/hole_form.html", title="Add Hole", form=form)
def add_hole(app_and_db): Wall.add_hole(wall_id=1, width=1.2, height=2.25, amount=2)
def test_delete_hole(add_wall): Wall.add_hole(wall_id=1, width=1, height=2, amonunt=1) assert Hole.query.filter_by(id=1).first() Wall.delete_hole(1) assert not Hole.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()