def run_tests(room, vendor, tags, override): app = create_app() with app.app_context(): test_run = TestRun() db.session.add(test_run) db.session.commit() def on_snapshot(snapshot, plan): test_run.save_snapshot(snapshot, plan) socketio.emit('snapshot', test_run.event, room=room) db.session.commit() try: output = io.StringIO() output_stream = StreamOpener(stream=output) config = Configuration( outputs=[output_stream], format=['json.chunked'], on_snapshot=on_snapshot, vendor=vendor, override=override, command_args=[], tags=[','.join(tags)], ) runner = Runner(config) runner.run() except Exception as err: # pylint: disable=broad-except socketio.emit('global_error', str(err), room=room) finally: socketio.emit('tests_complete', room=room)
def report(test_run_id): room = request.form['room'] run = TestRun.query.get(test_run_id) event = run.event socketio.emit('snapshot', event, room=room) return jsonify(event)
def report(test_run_id): room = request.form['room'] run = TestRun.query.get(test_run_id) try: event = run.event socketio.emit('snapshot', event, room=room) return jsonify(event) except AttributeError: resp = jsonify({'error': 'Test run {} not found.'.format(test_run_id)}) resp.status_code = 404 return resp
def run_tests(room, vendor, tags, override): app = create_app() with app.app_context(): test_run = TestRun(vendor, tags) db.session.add(test_run) db.session.commit() def on_snapshot(snapshot, plan): test_run.save_snapshot(snapshot, plan) socketio.emit('snapshot', test_run.event, room=room) db.session.commit() def on_payload(payload): socketio.emit('payload', payload, room=room) try: output = io.StringIO() output_stream = StreamOpener(stream=output) config = Configuration( outputs=[output_stream], format=['json.chunked'], on_snapshot=on_snapshot, on_payload=on_payload, vendor=vendor, override=override, command_args=[], tags=[','.join(tags)], ) runner = Runner(config) runner.run() except Exception as err: # pylint: disable=broad-except import traceback traceback.print_exc() socketio.emit('global_error', str(err), room=room) finally: socketio.emit('tests_complete', room=room)
def on_payload(payload): socketio.emit('payload', payload, room=room)
def on_snapshot(snapshot, plan): test_run.save_snapshot(snapshot, plan) socketio.emit('snapshot', test_run.event, room=room) db.session.commit()