コード例 #1
0
def get_search_data():
    """
        Description : Constructs the SQL search query based on the
                      given form data
        
        input_param :
        input_type :
        
        out_param : tests - mached HttpTest rows
        out_type : HttpTest
       
    """
    tests = []
    form_data = request.json if request.json else request.form
    query = session.query(HttpTest)
    if form_data.get('test_name'):
        query = query.filter( HttpTest.name==form_data.get('test_name') )
    if form_data.get('user_name'):
        query = query.filter( HttpTest.scheduled_by==form_data.get('user_name') )
    if form_data.get('category_ids'):
        query = query.filter( HttpTest.category_id.in_(form_data.get('category_ids') ))

    for test in query.all():
        tests.append(format_test_data(test))
    return tests
コード例 #2
0
def load_all_tests():
    """
        Description : View function to render all the test details
        
    """
    tests = [ format_test_data(test)    for test in session.query(HttpTest).all() ]
    response_data = { 'form' : render_template('all_test_status.html'),
                          'response_data' : {'tests': tests}
                          }
    resp = make_response(jsonify(response_data), 200)
    return resp
コード例 #3
0
def load_test_details(test_id=0):
    """
        Description : View function for loading the specific test details
        
    """
    test = session.query(HttpTest).get(test_id)
    if request.method == 'GET':
        response_data = {  'form' : render_template('test_details.html'),
                              'response_data' : {'test_details': {}}
                        }
        if test:
            response_data['response_data']['test_details'] = format_test_data(test)
        resp = make_response(jsonify(response_data), 200)
        return resp
    else:
        form_data = request.json if request.json else request.form
        test.paused = form_data.get('pause')
        test.running = not form_data.get('pause')
        session.commit()
        response_data = { 'post_response': { 'test_details' : format_test_data(test) }}
        resp = make_response(jsonify(response_data), 200)
        return resp