def post(self): parser = reqparse.RequestParser() parser.add_argument('type', type=str) parser.add_argument('size_g', type=int) parser.add_argument('fat_100', type=float) parser.add_argument('fat_serving', type=float) parser.add_argument('sat_100', type=float) parser.add_argument('sat_serving', type=float) parser.add_argument('sugar_100', type=float) parser.add_argument('sugar_serving', type=float) parser.add_argument('salt_100', type=float) parser.add_argument('salt_serving', type=float) # Get arguments / data from the API call args = parser.parse_args() # Create new data structure to hold traffic light nutrition data food_data = self.create_data_structure(args) # Define trafficlight limits (perhaps move to TL ) nutrition_data = tl.define_limits() # Generate traffic light colour data colours = tl.generate_tl(nutrition_data, food_data) return {'tl_data': colours}
def main(): nutrition_data = tl.define_limits() food_data = generate_food_data() tl.generate_tl(nutrition_data, food_data) print "\nFinished\n"
def test_limit_data_content(): limit_data = tl.define_limits() assert limit_data['food']['fat']['serving'] == 21 assert limit_data['food']['sugar']['lower'] == 5 assert limit_data['food']['salt']['upper'] == 1.5 assert limit_data['drink']['fat']['serving'] == 10.5 assert limit_data['drink']['fat']['upper'] == 8.75 assert limit_data['drink']['fat']['lower'] == 1.5
def test_limit_datatypes(): limit_data = tl.define_limits() assert isinstance(limit_data, dict) assert isinstance(limit_data['food'], dict)
def test_limit_datasizes(): limit_data = tl.define_limits() assert len(limit_data['food']) == 4