Esempio n. 1
0
def editTestListCommandLineOptions_ajax(request):
    """
    POST from case detail page to change the command line options for one or 
    many planned executions. The data being sent from the server does not 
    include information about browsers, plm, or test/case since multiple planned
    """

    data = handleAjaxRequestJSONData(request)
    pids = data.get('pids', None)
    clpfields = data.get('clpform',None)
    
    if pids is None or clpfields is None:
        return JSONHttpResponse({'msg': 'No planned executions or no command line parameters were sent to the server'}, status=400)

    # Loop through them (same code if there is only one planned execution sent)
    try:
        for pid in pids:
            pidInt = int(pid.split('=')[0].split('_')[-1]) # convert "delete_select_##" to ## integer
            pe = Planned_Exec.objects.get(id=pidInt)
            getOrCreateCommandLineArgsFromPlannedExecution(request.user.username, pe, clpfields)

    except Exception as e:
        return JSONHttpResponse({'msg': 'An unexpected error occurred while attempting to edit the command line parameters. Error was: %s' % e.message}, status=500)
    
    return JSONHttpResponse({'msg':"Successfully edited the command line parameters.",'success':True})
Esempio n. 2
0
def createPlannedExecObject(request, case, plm, country3, country_ignore):
    """ Create the planned execution from the request, case, and plm chosen """
    
    # Planned Execution Params
    browser = request.POST.get('browser','')
    regression = request.POST.get('regression','NA')
    test_script = request.POST.get('test_script','')
    regression_enabled = request.POST.get('regression_enabled','off')
    regression_setup = request.POST.get('regression_setup','on')
    owner = request.POST.get('owner','')       
    planned_for = request.POST.get('planned_for', '')
    
    newTest = Planned_Exec()
    if not country_ignore:
        country = Country.objects.get(iso3code=country3)
        newTest.country = country
    else:
        newTest.country = None
    newTest.case = case
    newTest.protocol = case.protocol
    newTest.plm = plm
    newTest.browser = browser
    newTest.owner = owner
    newTest.creator = request.user.username
    newTest.updater = request.user.username
    newTest.team = case.protocol.team
    newTest.release = case.protocol.release
    newTest.planned_for = ProjectSchedule.objects.get(id=planned_for)
    
    if regression_enabled == 'on' and case.exec_type == "FA":
        newTest.regression = regression
        if regression_setup == 'on':
            newTest.regression_setup = True
        else:
            newTest.regression_setup = False
    else:
        newTest.regression = REGRESSION_OPTIONS[0][0]        
        
    newTest.test_script = test_script

    # Command Line Arguments
    clpfields = {}
    
    if request.POST.get('debug'):
        clpfields['debug'] = 'on'
    else: 
        clpfields['debug'] = 'off'
        
    if request.POST.get('quiet'):
        clpfields['quiet'] = 'on'
    else: 
        clpfields['quiet'] = 'off'
                
    if request.POST.get('komodo_enroll') == "True":
        clpfields['komodo_enroll'] = 'True'
    elif request.POST.get('komodo_enroll') == "False":
        clpfields['komodo_enroll'] = 'False'

    if request.POST.get('komodo_pgsim') == "True":
        clpfields['komodo_pgsim'] = 'True'
    elif request.POST.get('komodo_pgsim') == "False":
        clpfields['komodo_pgsim'] = 'False'
        
    if request.POST.get('user_params'):
        clpfields['user_params'] = request.POST.get('user_params')
        
    # Save the planned execution
    newTest.save()
    
    # Save the command line args object
    cla = getOrCreateCommandLineArgsFromPlannedExecution(request.user.username, newTest, clpfields, False)

    # Update the protocol log
    if newTest.country:
        cname = newTest.country.name
    else:
        cname = "No Country"
    try:
        utils_protocol.logProtocol(request.user,
                                   case.protocol,
                                   LOG_MSG_TYPES[20][0], 
                                   case=case, 
                                   region=plm.geography,
                                   pg_model=plm.pg_model,
                                   comm_model=plm.comm_model,
                                   browser=newTest.get_browser_display(), 
                                   country=cname)
    
    # Could not log it, so delete it and error out
    except:
        newTest.delete()
        raise Exception('Error: The planned execution could not be added to the database. The computer thingy had trouble creating the record of the creation.')
    
    return newTest