def calc_times(): """ Calculates open/close times from miles, using rules described at http://www.rusa.org/octime_alg.html. Expects one URL-encoded argument, the number of miles. """ app.logger.debug("Got a JSON request"); x = brevet_calculator() leng = request.args.get('brevet_len', 0, type=int) controle = request.args.get('miles', 0, type=float) base = request.args.get('begin', 0, type=str) message= x.message(leng,controle,base) print("TESTING") return jsonify(result={"message":message})
def test_fixed(): x=brevet_calculator() y=x.controle_times(200,200) assert(y[0]==5 and y[1]==53 and y[2]==13 and y[3]==30)
def test_variable(): x=brevet_calculator() y=x.controle_times(600,500) assert(y[0]==15 and y[1]==28 and y[2]==33 and y[3]==20)
def test_over_err(): x=brevet_calculator() assert (x.message(1000,1300,"2001-01-01 00:00")=="Error: Exceeded Maximum Brevet Length!")