Add a test endpoint that allows us to manually create builds. Add access tokens to the build data.
This commit is contained in:
parent
c5ff08e57d
commit
78d2d6cad0
7 changed files with 99 additions and 14 deletions
53
endpoints/test.py
Normal file
53
endpoints/test.py
Normal file
|
@ -0,0 +1,53 @@
|
|||
from random import SystemRandom
|
||||
from flask import jsonify, send_file
|
||||
from app import app
|
||||
|
||||
|
||||
@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,
|
||||
'status': None,
|
||||
'message': None,
|
||||
}
|
||||
|
||||
random = SystemRandom()
|
||||
phases = {
|
||||
'waiting': {},
|
||||
'starting': {
|
||||
'total_commands': 7,
|
||||
'current_command': 0,
|
||||
},
|
||||
'initializing': {},
|
||||
'error': {
|
||||
'message': 'Oops!'
|
||||
},
|
||||
'complete': {},
|
||||
'building': {
|
||||
'total_commands': 7,
|
||||
'current_command': random.randint(1, 7),
|
||||
},
|
||||
'pushing': {
|
||||
'total_commands': 7,
|
||||
'current_command': 7,
|
||||
'total_images': 11,
|
||||
'current_image': random.randint(1, 11),
|
||||
'image_completion_percent': random.randint(0, 100),
|
||||
},
|
||||
}
|
||||
|
||||
phase = random.choice(phases.keys())
|
||||
response['status'] = phase
|
||||
response.update(phases[phase])
|
||||
|
||||
return jsonify(response)
|
||||
|
||||
|
||||
@app.route('/test/build', methods=['GET'])
|
||||
def create_build():
|
||||
return send_file('templates/testbuild.html')
|
Reference in a new issue