Ejemplo n.º 1
0
 def get(self, test_type):
     testType = TestTypeCore.get_one({TestTypeCore._test_type: test_type})
     if testType is None:
         abort(404)
     indexes = IndexCore.get_all({IndexCore._test_type: test_type})
     indexes = [prep_index(index) for index in indexes]
     return jsonify(result='Success', indexes=indexes, count=len(indexes))
Ejemplo n.º 2
0
def runlist_get(test_type):
    testType = TestTypeCore.get_one({TestTypeCore._test_type: test_type})
    if testType is None:
        abort(404)
    runs = [] if testType._run is None else [run for run in testType._run]
    runs.append('default')
    runs = {run: run_get(test_type, run) for run in runs}
    return runs
Ejemplo n.º 3
0
 def test_get_one(self):
     from core.TestType import TestType
     from core.Base import Base
     my_type1 = str(uuid.uuid4())
     doc1 = [str(uuid.uuid4()), str(uuid.uuid4()), str(uuid.uuid4())]
     test_type1 = TestType(my_type1, doc1)
     test_type1.save()
     my_type2 = str(uuid.uuid4())
     doc2 = [str(uuid.uuid4()), str(uuid.uuid4()), str(uuid.uuid4())]
     test_type2 = TestType(my_type2, doc2)
     test_type2.save()
     type2 = TestType.get_one({TestType._test_type: my_type2})
     assert type2._doc_fields == doc2
     assert type2._test_type == my_type2
     type1 = TestType.get_one({TestType._test_type: my_type1})
     assert type1._doc_fields == doc1
     assert type1._test_type == my_type1
Ejemplo n.º 4
0
 def get(self, test_type, field):
     testType = TestTypeCore.get_one({TestTypeCore._test_type: test_type})
     if testType is None:
         abort(404)
     index = IndexCore(test_type=test_type, field=field).get()
     if index is None:
         abort(404)
     index = prep_index(index)
     return jsonify(result='Success', index=index)
Ejemplo n.º 5
0
def purge_get(test_type):
    testType = TestTypeCore.get_one({TestTypeCore._test_type: test_type})
    if testType is None:
        abort(404)
    purge = testType.purge()
    purge_dict = {'_links': {}}
    purge_dict['condition'] = purge['condition'].to_dict()
    purge_dict['action'] = purge['action']
    add_link_or_expand(purge_dict, 'self', 'purge', test_type=test_type)
    return purge_dict
Ejemplo n.º 6
0
def run_get(test_type, run_type):
    testType = TestTypeCore.get_one({TestTypeCore._test_type: test_type})
    if testType is None:
        abort(404)
    run = testType.run(run_type)
    if run is None:
        abort(404)
    run_dict = {'_links': {}}
    run_dict['condition'] = run['condition'].to_dict()
    run_dict['modifier'] = run['modifier']
    add_link_or_expand(run_dict, 'self', 'run', test_type=test_type, run_type=run_type)
    return run_dict
Ejemplo n.º 7
0
 def patch(self, test_type):
     testType = TestTypeCore.get_one({TestTypeCore._test_type: test_type})
     if testType is None:
         abort(404)
     parser = reqparse.RequestParser()
     parser.add_argument('doc_fields_to_index', type=str, help='list of the document fields to index', required=False, action='append')
     args = parser.parse_args()
     if args['doc_fields_to_index'] is not None:
         testType._doc_fields_to_index = args['doc_fields_to_index']
     testType.save()
     testType = prep_test_type(testType)
     return jsonify(result='Success', test_type=testType)
Ejemplo n.º 8
0
 def post(self, test_type):
     data = request.get_json()
     action = data['action']
     condition = data['condition']
     testType = TestTypeCore.get_one({TestTypeCore._test_type: test_type})
     if testType is None:
         abort(404)
     if action not in TestTypeCore.actions:
         abort(400)
     if not testType.set_purge(action, condition):
         abort(400)
     purge = purge_get(test_type)
     return jsonify(result='Success', purge=purge)
Ejemplo n.º 9
0
 def post(self, test_type):
     data = request.get_json()
     run_type = data['run_type']
     modifier = data['modifier']
     condition = data['condition']
     testType = TestTypeCore.get_one({TestTypeCore._test_type: test_type})
     if testType is None:
         abort(404)
     if modifier not in TestTypeCore.modifiers:
         abort(400)
     if not testType.add_run_type(run_type, modifier, condition):
         abort(400)
     run = run_get(test_type, run_type)
     return jsonify(result='Success', run=run)
Ejemplo n.º 10
0
def testtype_get(test_type):
    testType = TestTypeCore.get_one({TestTypeCore._test_type: test_type})
    if testType is None:
        abort(404)
    testType = prep_test_type(testType)
    return testType