From d52d91327610829525bd176bc8ed9084a2e5f9da Mon Sep 17 00:00:00 2001 From: yackob03 Date: Mon, 6 Jan 2014 13:10:22 -0500 Subject: [PATCH] Update the test endpoint to reflect the new build status. --- endpoints/test.py | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/endpoints/test.py b/endpoints/test.py index ff5e42c37..bbd9e286a 100644 --- a/endpoints/test.py +++ b/endpoints/test.py @@ -1,19 +1,33 @@ +import math + from random import SystemRandom -from flask import jsonify, send_file +from flask import jsonify from app import app +def generate_image_completion(rand_func): + images = {} + for image_id in range(rand_func.randint(1, 11)): + total = int(math.pow(abs(rand_func.gauss(0, 1000)), 2)) + current = rand_func.randint(0, total) + image_id = 'image_id_%s' % image_id + images[image_id] = { + 'total': total, + 'current': current, + } + return images + + @app.route('/test/build/status', methods=['GET']) def generate_random_build_status(): response = { 'id': 1, 'total_commands': None, - 'total_images': None, 'current_command': None, - 'current_image': None, - 'image_completion_percent': None, + 'push_completion': 0.0, 'status': None, 'message': None, + 'image_completion': {}, } random = SystemRandom() @@ -35,9 +49,8 @@ def generate_random_build_status(): 'pushing': { 'total_commands': 7, 'current_command': 7, - 'total_images': 11, - 'current_image': random.randint(1, 11), - 'image_completion_percent': random.randint(0, 100), + 'push_completion': random.random(), + 'image_completion': generate_image_completion(random), }, }