I'm making a web application using flask framework. To display a web page using flask, I use a render_template() function. For example:
@app.route('/restaurants/<int:restaurant_id>/')
def restaurantMenu(restaurant_id):
try:
# pdb.set_trace()
session = get_session()
restaurant = session.query(Restaurant).filter_by(id=restaurant_id).one()
if restaurant is not None:
menu_items = session.query(MenuItem).filter(
MenuItem.restaurant_id == restaurant.id
)
session.close()
if menu_items is not None:
return render_template('menu.html', restaurant=restaurant, items=menu_items)
except NoResultFound:
return render_template('error.html', error_message='No such restaurant id.')
And
@app.route('/')
def welcomePage():
return render_template('index.html')
How do I write test cases for functions like these? I'm new to testing so I wanted to write test cases for my code.