Update the test endpoint to reflect the new build status.
This commit is contained in:
parent
0ffd23e20e
commit
d52d913276
1 changed files with 20 additions and 7 deletions
|
@ -1,19 +1,33 @@
|
||||||
|
import math
|
||||||
|
|
||||||
from random import SystemRandom
|
from random import SystemRandom
|
||||||
from flask import jsonify, send_file
|
from flask import jsonify
|
||||||
from app import app
|
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'])
|
@app.route('/test/build/status', methods=['GET'])
|
||||||
def generate_random_build_status():
|
def generate_random_build_status():
|
||||||
response = {
|
response = {
|
||||||
'id': 1,
|
'id': 1,
|
||||||
'total_commands': None,
|
'total_commands': None,
|
||||||
'total_images': None,
|
|
||||||
'current_command': None,
|
'current_command': None,
|
||||||
'current_image': None,
|
'push_completion': 0.0,
|
||||||
'image_completion_percent': None,
|
|
||||||
'status': None,
|
'status': None,
|
||||||
'message': None,
|
'message': None,
|
||||||
|
'image_completion': {},
|
||||||
}
|
}
|
||||||
|
|
||||||
random = SystemRandom()
|
random = SystemRandom()
|
||||||
|
@ -35,9 +49,8 @@ def generate_random_build_status():
|
||||||
'pushing': {
|
'pushing': {
|
||||||
'total_commands': 7,
|
'total_commands': 7,
|
||||||
'current_command': 7,
|
'current_command': 7,
|
||||||
'total_images': 11,
|
'push_completion': random.random(),
|
||||||
'current_image': random.randint(1, 11),
|
'image_completion': generate_image_completion(random),
|
||||||
'image_completion_percent': random.randint(0, 100),
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Reference in a new issue