Ejemplo n.º 1
0
def switch_to_app(app_name):
    """Switch context to the given app, to act in its process."""
    # in case of multi process not needed
    if not settings.G_MULTI_PROCESS:
        return True

    # do this always upfront, because an app
    # might have been connected in the meanwhile
    # and must be updated before trying to possibly
    # change to it.
    update_all_contexts()

    good = False
    if app_name in settings.G_APP_HANDLE.keys():
        switch_to_app = settings.G_APP_HANDLE[app_name]
        if switch_to_app is not None:
            test.log("Trying to switch to registered app '" + app_name + "'!")
            squish.snooze(settings.G_WAIT_SWITCH_APP_CONTEXT)
            squish.setApplicationContext(switch_to_app)
            test.log("Switched to registered app '" + app_name + "'!")
            good = True
        else:
            test.fail("App '" + app_name + "' is known but yet not registered")
    else:
        test.fail("App '" + app_name + "' is not known!")
    return good
Ejemplo n.º 2
0
def main():
    
    test.log("Test Case Name: tst_start_bulk_revert_delivery")
    
    data = testData.dataset("s_list_of_webservices.tsv")[0]
    get_delivery_status_url = testData.field(data, "get_delivery_status_url")
    revert_all_deliveries_get_call = testData.field(data, "revert_all_deliveries_get_call")

    data = testData.dataset("delivery_ids_for_bulk_reverting.tsv")[0]
    parent_delivery_id = testData.field(data, "delivery_id")  
    videoISRC = testData.field(data, "videoISRC")
    
    test.log(" get_delivery_status_url : " + get_delivery_status_url)  
    test.log(" revert_all_deliveries_get_call : " + revert_all_deliveries_get_call) 
    test.log(" delivery_id : " + parent_delivery_id)
    test.log(" videoISRC: " + videoISRC)
    
    data = testData.dataset("ftp_login_details.tsv")[0]
    ftp_vevo_host = testData.field(data, "ftp_vevo_host")  
    ftp_vevo_user = testData.field(data, "ftp_vevo_user")  
    ftp_vevo_password = testData.field(data, "ftp_vevo_password")  
    
    manifest_parse_success_replace_success = findFile("testdata", "vevo_status\\parse_success_replace_success\\status-manifest.xml")
    
    squish.snooze(40)

    # latest_revert_id = "ff80808147da5cc80147e9c872f00172"
    latest_revert_id = bulk_revert_delivery(revert_all_deliveries_get_call,get_delivery_status_url,parent_delivery_id)
    if(latest_revert_id and latest_revert_id != None):
        delivery_stage = check_delivery_status_until_waiting_on_confirmation(get_delivery_status_url, latest_revert_id)
        ftp_transfer(get_delivery_status_url, parent_delivery_id, latest_revert_id, delivery_stage, ftp_vevo_host, ftp_vevo_user, ftp_vevo_password, manifest_parse_success_replace_success)
    else:
        test.fail("latest revert id is null or doesn't exist")
def get_list_of_files_folders_from_hub(url, hub):
    test.log("get_list_of_files_folders_from_hub")
    test.log("url : " + url)
    complete_url = url + hub
    print complete_url
    data = None

    try:
        dict = post_url_data(complete_url, data)
        #pprint(dict)
        files = dict['files']
        #pprint(files)
        new_data_dict = None
        if (len(files) > 0):
            print len(files)
            for i in range(len(files)):
                new_data_dict = dict['files'][i]
                folder = new_data_dict['folder']
                if (folder):
                    print folder
                    print new_data_dict
                    break
            if (new_data_dict and new_data_dict != None):
                dict = post_url_data(complete_url, new_data_dict)
                print dict
                return new_data_dict
        else:
            test.fail("No folders or files exist")

    except Exception as e:
        test.fail("get_list_of_files_folders_from_hub")
        print e
        s = str(e)
        print sys.exc_info()
        test.log(s)
Ejemplo n.º 4
0
def revert_delivery(url, get_delivery_status_url, delivery_id):
    
    test.log("revert_delivery : " + url + delivery_id)

    squish.snooze(10)
    response = requests.put(url + delivery_id)
    squish.snooze(30)

    print response.status_code
    test.log("response code : " + str(response.status_code))
    if(response.status_code == 200):
        test.passes("Revert delivery initiated: ")
    else:
        test.fail("Revert delivery initiating failed")
   
    snooze(40)
    
    complete_url = get_delivery_status_url + delivery_id

    source(findFile("scripts", "deliverywebservices.py"))
    revert_stage = check_revert_status_with_complete_url(complete_url)
    latest_revert_id = get_latest_revert_id_with_complete_url(complete_url)

    if(revert_stage == "REVERTING" and latest_revert_id != None and latest_revert_id):
        test.log("Reverting the delivery")
        return latest_revert_id
    else:
        test.fail("Failed to Revert the delivery")
Ejemplo n.º 5
0
def ftp_transfer(get_delivery_status_url, delivery_id, delivery_stage,
                 ftp_vevo_host, ftp_vevo_user, ftp_vevo_password,
                 local_manifest_file_path):

    test.log("ftp_transfer : ")
    test.log("get_delivery_status_url : " + get_delivery_status_url)
    test.log("delivery_id : " + delivery_id)
    test.log("delivery_stage : " + delivery_stage)
    test.log("local_manifest_file_path : " + local_manifest_file_path)

    if (delivery_stage == "WAITING_ON_CONFIRMATION"):
        # get the ftp path and transfer parse success replace success file
        source(findFile("scripts", "connect_to_ftpserver.py"))
        complete_url = get_delivery_status_url + delivery_id

        ftp_delivery_path = get_delivery_ftp_path_complete_url(complete_url)
        check_contents_in_ftp_server_and_download_manifest(
            ftp_delivery_path, ftp_vevo_host, ftp_vevo_user, ftp_vevo_password)
        squish.snooze(30)
        copy_to_ftp_server(local_manifest_file_path, ftp_delivery_path,
                           ftp_vevo_host, ftp_vevo_user, ftp_vevo_password)
        squish.snooze(90)
        delivery_stage = check_delivery_status_with_complete_url(complete_url)
        if (delivery_stage == "COMPLETE"):
            # change the flight end date to 30 seconds from now
            os.system("C:\\utils\\run_update_campaign_end_dates.bat 12735523")
            test.passes("Delivery successfully completed")
        else:
            test.log("Delivery failed : " + complete_url)
            test.fail("Delivery failed : " + delivery_stage)
    else:
        test.fail("delivery has failed to complete the delivery")
def get_list_of_files_folders_from_hub(url, hub):
    test.log("get_list_of_files_folders_from_hub")
    test.log("url : " + url)
    complete_url = url + hub
    print complete_url 
    data = None  
    
    try:
        dict = post_url_data(complete_url, data)
        #pprint(dict)
        files = dict['files']
        #pprint(files)
        new_data_dict = None
        if(len(files) > 0):
            print len(files)
            for i in range(len(files)):
                new_data_dict = dict['files'][i]
                folder = new_data_dict['folder']
                if(folder):
                    print folder
                    print new_data_dict
                    break
            if(new_data_dict and new_data_dict != None):
                dict = post_url_data(complete_url, new_data_dict)
                print dict
                return new_data_dict
        else:
            test.fail("No folders or files exist")

    except Exception as e:
        test.fail("get_list_of_files_folders_from_hub")
        print e
        s = str(e)
        print sys.exc_info()
        test.log(s)
def cancelling_delivery(check_delivery_status_url, cancel_delivery_url, delivery_id, ftp_vevo_host, ftp_vevo_user, ftp_vevo_password):
    test.log("cancelling delivery")
    files_on_ftp = False
    delivery_stage = check_delivery_status(check_delivery_status_url, delivery_id)
    if(delivery_stage == "CREATED" or delivery_stage == "SUBMITTED" or delivery_stage == "STARTED" or delivery_stage == "IN_PROGRESS"):
       test.log("Delivery successfully cancelled")
    #cancel the delivery
       print delivery_stage
       source(findFile("scripts", "stop_cancel_delivery.py"))
       delivery_stage = stop_delivery(cancel_delivery_url, delivery_id)
       squish.snooze(30)
       delivery_stage = check_delivery_status_until_cancelled(check_delivery_status_url, delivery_id)
        
       source(findFile("scripts", "check_contents_on_ftp_after_cancel.py"))

       delivery_ftp_path = get_delivery_ftp_path(check_delivery_status_url, delivery_id)
       if(delivery_ftp_path or delivery_ftp_path != None):
           files_on_ftp = check_contents_in_ftp_server(delivery_ftp_path, ftp_vevo_host, ftp_vevo_user, ftp_vevo_password)
           if(files_on_ftp):
               test.passes("File transfer has been successfully cancelled and contents has been checked on FTP")
       elif(delivery_stage == "CANCELLED"):
           test.log("Delivery Cancelled")
           test.passes("Delivery has been successfully cancelled")
       else:
           test.fail("Failed to cancel delivery")
    return
def get_delivery_config_get_url(url):
        
        test.log("get_delivery_config_get_url : " + url)
        open = urllib2.urlopen(url)
        dict = json.load(open)
        #pprint(dict)
        
        list_of_hubs = dict['availableHubs']
        
        if(len(list_of_hubs) > 0):
            for hub in list_of_hubs:
                test.log("hub :", hub)
                if(hub == "hub-t1"):
                    test.log("hub exists", hub)
        else:
            test.fail("No Hubs available ")
            
        list_of_delivery_targets = dict['deliveryTargets']
        if(len(list_of_delivery_targets) > 0):
            for delivery_target in list_of_delivery_targets:
                test.log("delivery delivery_target : ", delivery_target)
                if(delivery_target == "VEVO"):
                    test.log("delivery_target exists", delivery_target)
        else:
            test.fail("No Delivery targets available ")
Ejemplo n.º 9
0
def ftp_transfer(get_delivery_status_url, delivery_id,delivery_stage, ftp_vevo_host, ftp_vevo_user, ftp_vevo_password, local_manifest_file_path):
    
    test.log("ftp_transfer : ")
    test.log("get_delivery_status_url : " + get_delivery_status_url)
    test.log("delivery_id : " + delivery_id)
    test.log("delivery_stage : " + delivery_stage)
    test.log("delivery_stage : " + local_manifest_file_path)
    
    
    if(delivery_stage == "WAITING_ON_CONFIRMATION"):
        # get the ftp path and transfer parse success replace success file
        source(findFile("scripts", "connect_to_ftpserver.py"))
        complete_url = get_delivery_status_url + delivery_id

        ftp_delivery_path = get_delivery_ftp_path_complete_url(complete_url)
        check_contents_in_ftp_server_and_download_manifest(ftp_delivery_path, ftp_vevo_host, ftp_vevo_user, ftp_vevo_password)
        squish.snooze(30)
        copy_to_ftp_server(local_manifest_file_path, ftp_delivery_path, ftp_vevo_host, ftp_vevo_user, ftp_vevo_password)
        squish.snooze(90)
        delivery_stage = check_delivery_status_with_complete_url(complete_url)
        if(delivery_stage == "COMPLETE"):
            test.passes("Queued Delivery successfully completed")
            #change the flight end date to 30 seconds from now
            os.system("C:\\utils\\run_update_campaign_end_dates.bat 84062112")

        else:
            test.log("Queued Delivery failed : " + complete_url)
            test.fail("Queued Delivery failed : " + delivery_stage)
    else:
        test.fail("queued delivery has failed to complete the delivery")
Ejemplo n.º 10
0
def create_restart_remove_delivery(create_delivery_url,
                                   create_failed_delivery_data,
                                   check_delivery_status_url, restart_url,
                                   remove_delivery_url, success):
    test.log("create_restart_remove_delivery()")
    test.log("create_delivery_url : " + create_delivery_url)
    test.log("check_delivery_status_url : " + check_delivery_status_url)
    test.log("restart_url : " + restart_url)
    test.log("remove_delivery_url : " + remove_delivery_url)

    delivery_id = None
    delivery_stage = None

    source(findFile("scripts", "deliverywebservices.py"))

    delivery_id = create_save_delivery_using_post_url(
        create_delivery_url, create_failed_delivery_data)
    squish.snooze(30)
    if (delivery_id or delivery_id != None):
        delivery_stage = restarting_delivery(check_delivery_status_url,
                                             restart_url, delivery_id)
        source(findFile("scripts", "remove_delete_delivery.py"))
        squish.snooze(30)
        success = remove_delivery(remove_delivery_url, delivery_id, success)
        return success
    else:
        test.fail("delivery id is not created")
def create_cancel_remove_delivery(create_delivery_url,
                                  create_delivery_data_success,
                                  check_delivery_status_url,
                                  cancel_delivery_url, remove_delivery_url,
                                  ftp_vevo_host, ftp_vevo_user,
                                  ftp_vevo_password, success):
    test.log("create_cancel_remove_delivery")
    test.log("create_delivery_url : " + create_delivery_url)
    test.log("check_delivery_status_url : " + check_delivery_status_url)
    test.log("cancel_delivery_url : " + cancel_delivery_url)
    test.log("remove_delivery_url : " + remove_delivery_url)

    delivery_id = None
    delivery_stage = None
    source(findFile("scripts", "deliverywebservices.py"))
    delivery_id = create_save_delivery_using_post_url(
        create_delivery_url, create_delivery_data_success)
    source(findFile("scripts", "remove_delete_delivery.py"))
    squish.snooze(10)
    if (delivery_id or delivery_id != None):
        cancelling_delivery(check_delivery_status_url, cancel_delivery_url,
                            delivery_id, ftp_vevo_host, ftp_vevo_user,
                            ftp_vevo_password)
        success = remove_delivery(remove_delivery_url, delivery_id, success)
        test.log("delivery removed so returning success : ")
        return success
    else:
        test.fail("delivery id is not created")
        return success
Ejemplo n.º 12
0
def revert_delivery(url, get_delivery_status_url, delivery_id):

    test.log("revert_delivery : " + url + delivery_id)

    squish.snooze(10)
    response = requests.put(url + delivery_id)
    squish.snooze(30)

    print response.status_code
    test.log("response code : " + str(response.status_code))
    if (response.status_code == 200):
        test.passes("Revert delivery initiated: ")
    else:
        test.fail("Revert delivery initiating failed")

    snooze(40)

    complete_url = get_delivery_status_url + delivery_id

    source(findFile("scripts", "deliverywebservices.py"))
    revert_stage = check_revert_status_with_complete_url(complete_url)
    latest_revert_id = get_latest_revert_id_with_complete_url(complete_url)

    if (revert_stage == "REVERTING" and latest_revert_id != None
            and latest_revert_id):
        test.log("Reverting the delivery")
        return latest_revert_id
    else:
        test.fail("Failed to Revert the delivery")
Ejemplo n.º 13
0
def get_middle_of_object(obj):
    try:
        posx = obj.x
        posy = obj.y
    except Exception as e:
        test.fail("Fail due to: " + str(e))
        return False, QPoint(0, 0)
    else:
        return True, QPoint(posx, posy)
def copy_local_manifest_to_ftp(delivery_ftp_path, local_manifest_file_path_parse_success, local_manifest_file_path, get_delivery_status_url, delivery_id, count, ftp_vevo_host, ftp_vevo_user, ftp_vevo_password):
        
    test.log("copy_local_manifest_to_ftp")
    test.log("delivery_ftp_path : " + delivery_ftp_path)
    test.log("local_manifest_file_path : " + local_manifest_file_path)
    test.log("get_delivery_status_url : " + get_delivery_status_url)
    test.log("delivery_id : " + delivery_id)

    local_manifest_file_path = findFile("testdata", local_manifest_file_path)
    if(local_manifest_file_path_parse_success != None):
        local_manifest_file_path_parse_success = findFile("testdata", local_manifest_file_path_parse_success)
        
    #manifest_parse_success = findFile("testdata", "vevo_status\\parse_success\\status-manifest.xml")
    
    while(True):
        squish.snooze(60)
        complete_url = get_delivery_status_url + delivery_id
        print complete_url 
        open = urllib2.urlopen(complete_url)
        dict = json.load(open)
        delivery_stage = dict['deliveryStage']
        test.log("delivery_stage : " + delivery_stage)
        if(delivery_stage == "WAITING_ON_CONFIRMATION"):
            test.log("status is waiting on confirmation so copy the status-manifest.xml")
            if(count == 1):
                copy_to_ftp_server(local_manifest_file_path_parse_success, delivery_ftp_path, ftp_vevo_host, ftp_vevo_user, ftp_vevo_password)
                squish.snooze(10)
                open = urllib2.urlopen(complete_url)
                dict = json.load(open)
                delivery_stage = dict['deliveryStage']
                if(delivery_stage == "WAITING_ON_CONFIRMATION"):
                    copy_to_ftp_server(local_manifest_file_path, delivery_ftp_path, ftp_vevo_host, ftp_vevo_user, ftp_vevo_password)
                elif(delivery_stage == "FAILED"):
                    test.fail("Delivery stage is failed after copying parse success file")
                else:
                    test.fail("Delivery completed after transferring parse success file but not before transfer of parse success replace success manifest file")
            elif(count == 2):
                copy_to_ftp_server(local_manifest_file_path_parse_success, delivery_ftp_path, ftp_vevo_host, ftp_vevo_user, ftp_vevo_password)
                squish.snooze(10)
                open = urllib2.urlopen(complete_url)
                dict = json.load(open)
                delivery_stage = dict['deliveryStage']
                if(delivery_stage == "WAITING_ON_CONFIRMATION"):
                    copy_to_ftp_server(local_manifest_file_path, delivery_ftp_path, ftp_vevo_host, ftp_vevo_user, ftp_vevo_password)
                elif(delivery_stage == "FAILED"):
                    test.fail("Delivery stage is failed after copying parse success file")
                else:
                    test.fail("Delivery completed after transferring parse success file but not before transfer of parse success replace success manifest file")
            elif(count == 3):
                copy_to_ftp_server(local_manifest_file_path, delivery_ftp_path, ftp_vevo_host, ftp_vevo_user, ftp_vevo_password)
            elif(count == 4):
                copy_to_ftp_server(local_manifest_file_path_parse_success, delivery_ftp_path, ftp_vevo_host, ftp_vevo_user, ftp_vevo_password)
        else:
            test.fail("Delivery Stage failed before transferring status-manifest file, need not copy manifest files : " + delivery_stage)     
        
        return delivery_id
Ejemplo n.º 15
0
def fail(text):
    """ calls Squish's fail but switch back
    to main app before.
    The problem is when Squish fails, that if
    not done manually before in the according fail
    branch of the compare, any later switch_to_main_app()
    will not happen. This is a thin wrapper, that does it.
    """
    switch_to_main_app()
    test.fail(text)
Ejemplo n.º 16
0
def main():

    test.log("Test Case Name: test_create_cancel_remove")

    data = testData.dataset("s_list_of_webservices.tsv")[0]

    create_delivery_data_success = {
        "serviceOriginName": "Dove UI",
        "callBackEndPoint": None,
        "callBackReferenceId": None,
        "requestTime": None,
        "sourceFile":
        'hub://hub-t1/mirriad/storage/QA/GBUV71000779_I_AM_ARROWS_Another Picture Of You_no_P_logo_v2.mov',
        "deliveryFile":
        'hub://hub-t1/mirriad/storage/QA/GBUV71000779_I_AM_ARROWS_Another Picture Of You_with_P_logo_v2.mov',
        "assetId": '12230',
        "campaignId": '27120900',
        "deliveryTargetService": 'VEVO',
        "revertOperation": False
    }

    create_delivery_url = testData.field(
        data, "create_save_delivery_using_post_url")
    get_delivery_status_url = testData.field(data, "get_delivery_status_url")
    cancel_delivery_url = testData.field(data,
                                         "cancel_delivery_using_post_url")
    remove_delivery_url = testData.field(data,
                                         "delete_delivery_using_delete_url")
    success = False
    '''t01 ftp connection login details'''
    ftp_vevo_host = "ftp.uk.mirriad.com"
    ftp_vevo_user = "******"
    ftp_vevo_password = "******"
    ftp_vevo_port = 21
    ftp_vevo_vevo_user = "******"

    source(findFile("scripts", "test_create_cancel_remove.py"))

    success = create_cancel_remove_delivery(
        create_delivery_url, create_delivery_data_success,
        get_delivery_status_url, cancel_delivery_url, remove_delivery_url,
        ftp_vevo_host, ftp_vevo_user, ftp_vevo_password, success)
    if (success):
        test.passes("test_create_cancel_remove passed")
    else:
        test.fail("test_create_cancel_remove failed")
        testdata = testData.create("shared", "status.failed")
        try:
            with open(testdata, "w+") as f:
                test.log("Failed so create a status file")
        except Exception as e:
            print e
            s = str(e)
            test.log(s)
Ejemplo n.º 17
0
def get_info(obj):
    try:
        posx = obj.x
        posy = obj.y
        width = obj.width
        height = obj.height
    except Exception as e:
        test.fail("Fail due to: " + str(e))
    else:
        test.log("(" + str(posx) + "," + str(posy) + ") size [" + str(width) +
                 "," + str(height) + "]")
def check_delivery_status_until_cancelled(check_delivery_status_url, delivery_id):
        test.log("check_delivery_status_until_cancelled")
        source(findFile("scripts", "deliverywebservices.py"))

        while(True):
            delivery_stage = check_delivery_status(check_delivery_status_url, delivery_id)
            test.log(delivery_stage)
            if(delivery_stage == "CANCELLED"):
                return delivery_stage
            elif (delivery_stage == "FAILED"):
                test.fail("Delivery cancel failed")
                return delivery_stage
def get_list_of_files_folders_from_parent_folder_in_hub(url, hub, json_data):
    test.log("get_list_of_files_folders_from_parent_folder_in_hub")
    test.log("url : " + url)
    complete_url = url + hub + "/parent"
    print complete_url
    dict = post_url_data(complete_url, json_data)
    files = dict['files']
    new_data_dict = None
    if (len(files) > 0):
        print len(files)
    else:
        test.fail("no files exist in parent folder including the child file")
def get_list_of_files_folders_from_parent_folder_in_hub(url, hub, json_data):
    test.log("get_list_of_files_folders_from_parent_folder_in_hub")
    test.log("url : " + url)
    complete_url = url + hub + "/parent"
    print complete_url 
    dict = post_url_data(complete_url, json_data)
    files = dict['files']
    new_data_dict = None
    if(len(files) > 0):
            print len(files)
    else: 
        test.fail("no files exist in parent folder including the child file")
def stop_delivery(stop_cancel_delivery, delivery_id):
    
    test.log("stop delivery : " + stop_cancel_delivery + delivery_id)
   
    r = requests.post(stop_cancel_delivery + delivery_id)
    
    print r.status_code
    print r.text
    
    if(r.text):
        test.log("stopped or cancelled the delivery successfully")
    else:
        test.fail("Failed to cancel or stop the delivery")
def stop_delivery(stop_cancel_delivery, delivery_id):

    test.log("stop delivery : " + stop_cancel_delivery + delivery_id)

    r = requests.post(stop_cancel_delivery + delivery_id)

    print r.status_code
    print r.text

    if (r.text):
        test.log("stopped or cancelled the delivery successfully")
    else:
        test.fail("Failed to cancel or stop the delivery")
Ejemplo n.º 23
0
def depth_frame_call_back(frame):
    global previous_depth_frame_number
    frame_number = frame.get_frame_number()
    if previous_depth_frame_number != -1:
        dropped_frames = frame_number - (previous_depth_frame_number + 1)  # should be 0
        if dropped_frames > 0:
            print(dropped_frames, "depth frame(s) starting from frame", previous_depth_frame_number + 1, "were dropped")
            test.fail()
        if dropped_frames < 0:
            print("Depth frames repeated or out of order. Got frame", frame_number, "after frame",
                  previous_depth_frame_number)
            test.fail()
    previous_depth_frame_number = frame_number
def check_delivery_status_until_cancelled(check_delivery_status_url,
                                          delivery_id):
    test.log("check_delivery_status_until_cancelled")
    source(findFile("scripts", "deliverywebservices.py"))

    while (True):
        delivery_stage = check_delivery_status(check_delivery_status_url,
                                               delivery_id)
        test.log(delivery_stage)
        if (delivery_stage == "CANCELLED"):
            return delivery_stage
        elif (delivery_stage == "FAILED"):
            test.fail("Delivery cancel failed")
            return delivery_stage
Ejemplo n.º 25
0
def start_queued_deliveries(queued_deliveries_url):
    
    test.log("queued_deliveries_url" + queued_deliveries_url) 
    open = urllib2.urlopen(queued_deliveries_url)
    response_code = open.getcode()
    dict = json.load(open)
    
    request_status = dict['requestStatus'] 
    
    if(response_code == 200 and request_status == "OK"):
        test.log("started queued deliveries, response returned 200 and status is OK")
    else:
        test.log("request_status is not found")
        test.fail("response_code: " + response_code)
Ejemplo n.º 26
0
def switch_to_main_app():
    """Switch context to main app, to act in its process."""
    # in case of multi process not needed
    if not settings.G_MULTI_PROCESS:
        return True

    good = False
    if settings.G_APP_MAIN is not None:
        squish.snooze(settings.G_WAIT_SWITCH_APP_CONTEXT)
        squish.setApplicationContext(settings.G_APP_MAIN)
        good = True
    else:
        test.fail("Main app is not registered yet!!!")
    return good
Ejemplo n.º 27
0
def remove_delivery(remove_delivery_url, delivery_id, success):

    test.log("remove_delivery : " + remove_delivery_url + delivery_id)
    r = requests.delete(remove_delivery_url + delivery_id)
    #print r.status_code
    #print r.text

    if (r.text):
        test.log("removed the delivery card successfully")
        success = True
        return success
    else:
        test.fail("Failed to remove the delivery card")

    return success
def remove_delivery(remove_delivery_url, delivery_id,success):
    
    test.log("remove_delivery : " + remove_delivery_url + delivery_id)
    r = requests.delete(remove_delivery_url + delivery_id)
    #print r.status_code
    #print r.text
    
    if(r.text):
        test.log("removed the delivery card successfully")
        success = True
        return success
    else:
        test.fail("Failed to remove the delivery card")
    
    return success
def restart_delivery(restart_url, delivery_id):
           
    test.log("restart_delivery : " + restart_url + delivery_id)

    squish.snooze(10)
    r = requests.put(restart_url + delivery_id)
    print r.status_code
    dicts = json.loads(r.text)
    delivery_stage = dicts['deliveryStage'] 
    
    if(delivery_stage == "RESTARTED"):
        test.log("restarted the server")
        return delivery_stage
    else:
        test.fail("Failed to restart the delivery")
Ejemplo n.º 30
0
def restart_delivery(restart_url, delivery_id):

    test.log("restart_delivery : " + restart_url + delivery_id)

    squish.snooze(10)
    r = requests.put(restart_url + delivery_id)
    print r.status_code
    dicts = json.loads(r.text)
    delivery_stage = dicts['deliveryStage']

    if (delivery_stage == "RESTARTED"):
        test.log("restarted the server")
        return delivery_stage
    else:
        test.fail("Failed to restart the delivery")
Ejemplo n.º 31
0
def ftp_transfer(get_delivery_status_url, parent_delivery_id, latest_revert_id,
                 delivery_stage, ftp_vevo_host, ftp_vevo_user,
                 ftp_vevo_password, local_manifest_file_path):

    test.log("ftp_transfer : ")
    test.log("get_delivery_status_url : " + get_delivery_status_url)
    test.log("latest_revert_id : " + latest_revert_id)
    test.log("delivery_stage : " + delivery_stage)
    test.log("delivery_stage : " + local_manifest_file_path)
    test.log(
        "list of revert stages : REVERTED,REVERTING,REVERT_FAILED,UNREVERTABLE,UNREVERTABLE_DUPLICATE,UNREVERTABLE_NO_SOURCE,UNREVERTED"
    )

    if (delivery_stage == "WAITING_ON_CONFIRMATION"):
        # get the ftp path and transfer parse success replace success file
        source(findFile("scripts", "connect_to_ftpserver.py"))

        complete_url_of_parent = get_delivery_status_url + parent_delivery_id
        complete_url = get_delivery_status_url + latest_revert_id

        ftp_delivery_path = get_delivery_ftp_path_complete_url(complete_url)
        check_contents_in_ftp_server_and_download_manifest(
            ftp_delivery_path, ftp_vevo_host, ftp_vevo_user, ftp_vevo_password)
        squish.snooze(30)
        copy_to_ftp_server(local_manifest_file_path, ftp_delivery_path,
                           ftp_vevo_host, ftp_vevo_user, ftp_vevo_password)
        squish.snooze(60)
        test.log("waiting for 60 more seconds :")
        squish.snooze(60)
        delivery_stage = check_delivery_status_with_complete_url(complete_url)
        revert_stage_of_parent = check_revert_status_with_complete_url(
            complete_url_of_parent)  # REVERTED
        revert_stage = check_revert_status_with_complete_url(
            complete_url)  # UNREVERTABLE

        if (delivery_stage == "COMPLETE" and revert_stage == "UNREVERTABLE"
                and revert_stage_of_parent == "REVERTED"):
            test.passes("Delivery successfully Reverted")
            test.log("revert_stage: " + revert_stage)
            test.log("revert_stage_of_parent: " + revert_stage_of_parent)
        else:
            test.log("delivery_stage: " + delivery_stage)
            test.log("revert_stage: " + revert_stage)
            test.log("revert_stage_of_parent: " + revert_stage_of_parent)
            test.log("Reverting Delivery failed : " + complete_url)
            test.fail("Reverting Delivery failed : " + delivery_stage)
    else:
        test.fail("Reverting delivery has failed to complete the delivery")
Ejemplo n.º 32
0
def status_of_reverting_delivery(get_delivery_status_url, delivery_id):
    
    test.log("status_of_reverting_delivery : ")

    complete_url = get_delivery_status_url + delivery_id
    test.log("complete_url : " + complete_url)

    source(findFile("scripts", "deliverywebservices.py"))
    revert_stage = check_revert_status_with_complete_url(complete_url)
    latest_revert_id = get_latest_revert_id_with_complete_url(complete_url)

    if(revert_stage == "REVERTING" and latest_revert_id != None and latest_revert_id):
        test.log("Reverting the delivery")
        return latest_revert_id
    else:
        test.fail("Failed to Revert the delivery")
Ejemplo n.º 33
0
def main():
    test.log("Test Case Name: test_create_restart_remove")

    data = testData.dataset("s_list_of_webservices.tsv")[0]

    create_failed_delivery_data = {
        "serviceOriginName": "Dove UI",
        "callBackEndPoint": None,
        "callBackReferenceId": None,
        "requestTime": None,
        "sourceFile": 'hub://hub-t1/mirriad/storage/QA/MP4.mp4',
        "deliveryFile": 'hub://hub-t1/mirriad/storage/QA/MP41.mp4',
        "assetId": '10006',
        "campaignId": '10450402',
        "deliveryTargetService": 'VEVO',
        "revertOperation": False
    }

    create_delivery_url = testData.field(
        data, "create_save_delivery_using_post_url")
    get_delivery_status_url = testData.field(data, "get_delivery_status_url")
    restart_delivery_url = testData.field(data,
                                          "restart_delivery_using_put_url")
    remove_delivery_url = testData.field(data,
                                         "delete_delivery_using_delete_url")
    success = False

    source(findFile("scripts", "test_create_restart_remove.py"))

    success = create_restart_remove_delivery(create_delivery_url,
                                             create_failed_delivery_data,
                                             get_delivery_status_url,
                                             restart_delivery_url,
                                             remove_delivery_url, success)

    if (success):
        test.passes("test_create_restart_remove delivery passed")
    else:
        test.fail("test_create_restart_remove delivery failed")
        testdata = testData.create("shared", "status.failed")
        try:
            with open(testdata, "w+") as f:
                test.log("Failed so create a status file")
        except Exception as e:
            print e
            s = str(e)
            test.log(s)
Ejemplo n.º 34
0
def main():

    test.log("Test Case Name: test_create_cancel_remove")
    
    data = testData.dataset("s_list_of_webservices.tsv")[0]
    
    create_delivery_data_success = { 
    "serviceOriginName": "Dove UI",
    "callBackEndPoint": None,
    "callBackReferenceId": None,
    "requestTime": None,
    "sourceFile": 'hub://hub-t1/mirriad/storage/QA/GBUV71000779_I_AM_ARROWS_Another Picture Of You_no_P_logo_v2.mov',
    "deliveryFile": 'hub://hub-t1/mirriad/storage/QA/GBUV71000779_I_AM_ARROWS_Another Picture Of You_with_P_logo_v2.mov',
    "assetId": '12230',
    "campaignId": '27120900',
    "deliveryTargetService": 'VEVO',
    "revertOperation": False 
    }
    
    create_delivery_url = testData.field(data, "create_save_delivery_using_post_url")
    get_delivery_status_url = testData.field(data, "get_delivery_status_url")
    cancel_delivery_url = testData.field(data, "cancel_delivery_using_post_url")
    remove_delivery_url = testData.field(data, "delete_delivery_using_delete_url") 
    success = False
    '''t01 ftp connection login details'''
    ftp_vevo_host = "ftp.uk.mirriad.com"
    ftp_vevo_user = "******"
    ftp_vevo_password = "******"
    ftp_vevo_port = 21
    ftp_vevo_vevo_user = "******"
    
    source(findFile("scripts", "test_create_cancel_remove.py"))
    
    success  = create_cancel_remove_delivery(create_delivery_url, create_delivery_data_success, get_delivery_status_url, cancel_delivery_url, remove_delivery_url, ftp_vevo_host, ftp_vevo_user, ftp_vevo_password, success)
    if(success):
        test.passes("test_create_cancel_remove passed")
    else:
        test.fail("test_create_cancel_remove failed")
        testdata = testData.create("shared", "status.failed")
        try:
            with open(testdata, "w+") as f:
                test.log("Failed so create a status file")  
        except Exception as e:
            print e
            s = str(e)
            test.log(s)
Ejemplo n.º 35
0
def status_of_reverting_delivery(get_delivery_status_url, delivery_id):

    test.log("status_of_reverting_delivery : ")

    complete_url = get_delivery_status_url + delivery_id
    test.log("complete_url : " + complete_url)

    source(findFile("scripts", "deliverywebservices.py"))
    revert_stage = check_revert_status_with_complete_url(complete_url)
    latest_revert_id = get_latest_revert_id_with_complete_url(complete_url)

    if (revert_stage == "REVERTING" and latest_revert_id != None
            and latest_revert_id):
        test.log("Reverting the delivery")
        return latest_revert_id
    else:
        test.fail("Failed to Revert the delivery")
Ejemplo n.º 36
0
def bulk_revert_delivery(bulk_revert_url,get_delivery_status_url,parent_delivery_id):
    
    test.log("bulk_revert_delivery : " + bulk_revert_url)

    open = urllib2.urlopen(bulk_revert_url)
    response_code = open.getcode()
    dict = json.load(open)
    
    request_status = dict['requestStatus'] 
    
    if(response_code == 200 and request_status == "OK"):
        squish.snooze(30)
        test.passes("Bulk Revert initiated:")
    else:
        test.fail("Bulk Revert initiation failed: " + response_code)
   
    squish.snooze(60)
    latest_revert_id = status_of_reverting_delivery(get_delivery_status_url, parent_delivery_id)
    return latest_revert_id
Ejemplo n.º 37
0
def main():

    test.log("Test Case Name: tst_start_bulk_revert_delivery")

    data = testData.dataset("s_list_of_webservices.tsv")[0]
    get_delivery_status_url = testData.field(data, "get_delivery_status_url")
    revert_all_deliveries_get_call = testData.field(
        data, "revert_all_deliveries_get_call")

    data = testData.dataset("delivery_ids_for_bulk_reverting.tsv")[0]
    parent_delivery_id = testData.field(data, "delivery_id")
    videoISRC = testData.field(data, "videoISRC")

    test.log(" get_delivery_status_url : " + get_delivery_status_url)
    test.log(" revert_all_deliveries_get_call : " +
             revert_all_deliveries_get_call)
    test.log(" delivery_id : " + parent_delivery_id)
    test.log(" videoISRC: " + videoISRC)

    data = testData.dataset("ftp_login_details.tsv")[0]
    ftp_vevo_host = testData.field(data, "ftp_vevo_host")
    ftp_vevo_user = testData.field(data, "ftp_vevo_user")
    ftp_vevo_password = testData.field(data, "ftp_vevo_password")

    manifest_parse_success_replace_success = findFile(
        "testdata",
        "vevo_status\\parse_success_replace_success\\status-manifest.xml")

    squish.snooze(40)

    # latest_revert_id = "ff80808147da5cc80147e9c872f00172"
    latest_revert_id = bulk_revert_delivery(revert_all_deliveries_get_call,
                                            get_delivery_status_url,
                                            parent_delivery_id)
    if (latest_revert_id and latest_revert_id != None):
        delivery_stage = check_delivery_status_until_waiting_on_confirmation(
            get_delivery_status_url, latest_revert_id)
        ftp_transfer(get_delivery_status_url, parent_delivery_id,
                     latest_revert_id, delivery_stage, ftp_vevo_host,
                     ftp_vevo_user, ftp_vevo_password,
                     manifest_parse_success_replace_success)
    else:
        test.fail("latest revert id is null or doesn't exist")
Ejemplo n.º 38
0
def get_focus_window(window):
    """Return the object to the window according to dashboard/cluster"""
    found = True
    if window == "dashboard":
        obj_name = names.neptune_UI_Instrument_Cluster_QQuickWindowQmlImpl
    elif window == "console":
        obj_name = names.neptune_UI_Center_Console
    else:
        test.fail("The given window '" + window + "' is not known!!")
        obj = None
        found = False
        return found, obj
    try:
        obj = squish.waitForObject(obj_name, 1000)
    except Exception as e:
        test.fail("Could not find window '" + window + "'!!" + str(e))
        obj = None
        found = False
    return found, obj
def get_campaign_service_call(url,campaign_id):
        
    test.log("get_campaign_service_call: campaignId" + url + campaign_id)
    open = urllib2.urlopen(url)
    dict = json.load(open)
    #pprint(dict)
       
    total_number_of_results = dict['numberOfResults']
    
    if(total_number_of_results > 0):
        test.log("total campaign ids : ")
    else:
        test.fail("No campaign found")
       
    list_of_results = dict['results']
    #count = 0
    if(len(list_of_results) > 0):
        test.passes("Campaign service call returned open campaigns")
    else:
        test.fail("No campaign available ")
Ejemplo n.º 40
0
def create_delivery_and_save_delivery_id_to_tsv(create_delivery_url, create_delivery_data,videoISRC):   
    
    source(findFile("scripts", "deliverywebservices.py"))

    '''create the delivery'''
    delivery_id = create_save_delivery_using_post_url(create_delivery_url, create_delivery_data)
    squish.snooze(40)
         
    if(delivery_id and delivery_id != None):
            
        test.log("delivery successfully created", delivery_id)
        testdata = testData.create("shared", "delivery_ids_for_bulk_reverting.tsv")
        dataFile = open(testdata, "w")
        dataFile.write("delivery_id\tvideoISRC\n")
        dataFile.write(delivery_id + "\t" + videoISRC)
        dataFile.close()
        test.log("tsv created")
        return delivery_id
    else:
        test.fail("delivery id is none")
def get_campaign_service_call(url, campaign_id):

    test.log("get_campaign_service_call: campaignId" + url + campaign_id)
    open = urllib2.urlopen(url)
    dict = json.load(open)
    #pprint(dict)

    total_number_of_results = dict['numberOfResults']

    if (total_number_of_results > 0):
        test.log("total campaign ids : ")
    else:
        test.fail("No campaign found")

    list_of_results = dict['results']
    #count = 0
    if (len(list_of_results) > 0):
        test.passes("Campaign service call returned open campaigns")
    else:
        test.fail("No campaign available ")
Ejemplo n.º 42
0
def check_delivery_status_until_waiting_on_confirmation(get_delivery_status_url, latest_revert_id):
    
    test.log("check delivery status " + latest_revert_id)
    complete_url = get_delivery_status_url + latest_revert_id
    source(findFile("scripts", "deliverywebservices.py"))
    delivery_stage = None
    #ftp_file_path = None
    
    while(True):    
        squish.snooze(60)
        complete_url = get_delivery_status_url + latest_revert_id
        print complete_url 
        open = urllib2.urlopen(complete_url)
        dict = json.load(open)
        delivery_stage = dict['deliveryStage']
        test.log("delivery_stage : " + delivery_stage)
        if(delivery_stage == "WAITING_ON_CONFIRMATION"):
            return delivery_stage
        elif(delivery_stage == "FAILED"):
            test.fail("delivery stage is failed")
            return delivery_stage
Ejemplo n.º 43
0
def check_delivery_status_until_waiting_on_confirmation(get_delivery_status_url, delivery_id):
    
    test.log("check delivery status " + delivery_id)
    complete_url = get_delivery_status_url + delivery_id
    source(findFile("scripts", "deliverywebservices.py"))
    delivery_stage = None
    squish.snooze(30)

    while(True):    
        squish.snooze(60)
        complete_url = get_delivery_status_url + delivery_id
        print complete_url 
        open = urllib2.urlopen(complete_url)
        dict = json.load(open)
        delivery_stage = dict['deliveryStage']
        test.log("delivery_stage : " + delivery_stage)
        if(delivery_stage == "WAITING_ON_CONFIRMATION"):
            return delivery_stage
        elif(delivery_stage == "FAILED"):
            test.fail("delivery stage is failed")
            return delivery_stage
def create_cancel_remove_delivery(create_delivery_url, create_delivery_data_success, check_delivery_status_url, cancel_delivery_url, remove_delivery_url, ftp_vevo_host, ftp_vevo_user, ftp_vevo_password, success):
    test.log("create_cancel_remove_delivery")
    test.log("create_delivery_url : " + create_delivery_url)
    test.log("check_delivery_status_url : " + check_delivery_status_url)
    test.log("cancel_delivery_url : " + cancel_delivery_url)
    test.log("remove_delivery_url : " + remove_delivery_url)

    delivery_id = None
    delivery_stage = None
    source(findFile("scripts", "deliverywebservices.py"))
    delivery_id = create_save_delivery_using_post_url(create_delivery_url, create_delivery_data_success)
    source(findFile("scripts", "remove_delete_delivery.py"))
    squish.snooze(10)
    if(delivery_id or delivery_id != None):
        cancelling_delivery(check_delivery_status_url, cancel_delivery_url, delivery_id, ftp_vevo_host, ftp_vevo_user, ftp_vevo_password)      
        success = remove_delivery(remove_delivery_url, delivery_id,success)
        test.log("delivery removed so returning success : ")
        return success
    else:
        test.fail("delivery id is not created")
        return success
Ejemplo n.º 45
0
def bulk_revert_delivery(bulk_revert_url, get_delivery_status_url,
                         parent_delivery_id):

    test.log("bulk_revert_delivery : " + bulk_revert_url)

    open = urllib2.urlopen(bulk_revert_url)
    response_code = open.getcode()
    dict = json.load(open)

    request_status = dict['requestStatus']

    if (response_code == 200 and request_status == "OK"):
        squish.snooze(30)
        test.passes("Bulk Revert initiated:")
    else:
        test.fail("Bulk Revert initiation failed: " + response_code)

    squish.snooze(60)
    latest_revert_id = status_of_reverting_delivery(get_delivery_status_url,
                                                    parent_delivery_id)
    return latest_revert_id
def create_save_delivery_using_post_url(url, create_delivery_data):
     
    test.log("create_save_delivery_using_post_url")
    test.log("url : " + url)
    req = urllib2.Request(url)
    req.add_header('Content-Type', 'application/json')
    response = urllib2.urlopen(req, json.dumps(create_delivery_data))
    dict = json.load(response)
    #pprint(dict)
    if(dict['errorList'] and dict['errorList'] != None):
        test.log("Cannot create the delivery")
        test.fail("Duplicate delivery cannot be created")        
    else:    
        deliveryStage = dict['delivery']['deliveryStage'] 
    
        if(deliveryStage == "CREATED"):
            test.log("deliveryStage successfully created ")    
        delivery_id = dict['delivery']['id']
        if(delivery_id and delivery_id!=None):
            test.log("Delivery_id created : " + delivery_id)
        return delivery_id
Ejemplo n.º 47
0
def main():
    test.log("Test Case Name: test_create_restart_remove")
    
    data = testData.dataset("s_list_of_webservices.tsv")[0]
    
    create_failed_delivery_data = { 
    "serviceOriginName": "Dove UI",
    "callBackEndPoint": None,
    "callBackReferenceId": None,
    "requestTime": None,
    "sourceFile": 'hub://hub-t1/mirriad/storage/QA/MP4.mp4',
    "deliveryFile": 'hub://hub-t1/mirriad/storage/QA/MP41.mp4',
    "assetId": '10006',
    "campaignId": '10450402',
    "deliveryTargetService": 'VEVO',
    "revertOperation": False 
    }
    
    create_delivery_url = testData.field(data, "create_save_delivery_using_post_url")
    get_delivery_status_url = testData.field(data, "get_delivery_status_url")
    restart_delivery_url = testData.field(data, "restart_delivery_using_put_url")
    remove_delivery_url = testData.field(data, "delete_delivery_using_delete_url") 
    success = False
    
    source(findFile("scripts", "test_create_restart_remove.py"))

    success = create_restart_remove_delivery(create_delivery_url, create_failed_delivery_data, get_delivery_status_url, restart_delivery_url, remove_delivery_url, success)
    
    if(success):
        test.passes("test_create_restart_remove delivery passed")
    else:
        test.fail("test_create_restart_remove delivery failed")
        testdata = testData.create("shared", "status.failed")
        try:
            with open(testdata, "w+") as f:
                test.log("Failed so create a status file")  
        except Exception as e:
            print e
            s = str(e)
            test.log(s)      
def get_list_of_media_families(url, campaign_id):
    test.log("get_list_of_media_families :" + url + campaign_id)
    complete_url = url + campaign_id
    print complete_url 
    open = urllib2.urlopen(complete_url)
    dict = json.load(open)
    squish.snooze(10)
    test.log("get_list_of_media_families : " + complete_url)
    #pprint(dict)
      
    number_of_results = dict['numberOfResults']
    media_family_id = None
    if(number_of_results > 0):
        print number_of_results
        count = 0
        for i in range(number_of_results):
            count = count + 1
            dict_of_media_family_id_list = dict['results'][i]
            media_family_id = dict_of_media_family_id_list['id']
            print media_family_id
        test.log("successfully retrieved the no of results :")
        if(number_of_results != count):
            test.fail("assets doesn't match the number of results retrieved")
    else:
        test.fail("No results exist for media family")
    
    if(media_family_id and media_family_id != None):
         test.log("media family id exists : ", media_family_id)
         test.passes("Media family exists")
         return media_family_id
    else:
        test.fail("Failed to retrieve media family id")
Ejemplo n.º 49
0
def get_list_of_media_families(url, campaign_id):
    test.log("get_list_of_media_families :" + url + campaign_id)
    complete_url = url + campaign_id
    print complete_url
    open = urllib2.urlopen(complete_url)
    dict = json.load(open)
    squish.snooze(10)
    test.log("get_list_of_media_families : " + complete_url)
    #pprint(dict)

    number_of_results = dict['numberOfResults']
    media_family_id = None
    if (number_of_results > 0):
        print number_of_results
        count = 0
        for i in range(number_of_results):
            count = count + 1
            dict_of_media_family_id_list = dict['results'][i]
            media_family_id = dict_of_media_family_id_list['id']
            print media_family_id
        test.log("successfully retrieved the no of results :")
        if (number_of_results != count):
            test.fail("assets doesn't match the number of results retrieved")
    else:
        test.fail("No results exist for media family")

    if (media_family_id and media_family_id != None):
        test.log("media family id exists : ", media_family_id)
        test.passes("Media family exists")
        return media_family_id
    else:
        test.fail("Failed to retrieve media family id")
Ejemplo n.º 50
0
def ftp_transfer(get_delivery_status_url, parent_delivery_id, latest_revert_id, delivery_stage, ftp_vevo_host, ftp_vevo_user, ftp_vevo_password, local_manifest_file_path):
    
    test.log("ftp_transfer : ")
    test.log("get_delivery_status_url : " + get_delivery_status_url)
    test.log("latest_revert_id : " + latest_revert_id)
    test.log("delivery_stage : " + delivery_stage)
    test.log("local_manifest_file_path : " + local_manifest_file_path)
    #test.log("list of revert stages : REVERTED,REVERTING,REVERT_FAILED,UNREVERTABLE,UNREVERTABLE_DUPLICATE,UNREVERTABLE_NO_SOURCE,UNREVERTED")

    
    if(delivery_stage == "WAITING_ON_CONFIRMATION"):
        # get the ftp path and transfer parse success replace success file
        source(findFile("scripts", "connect_to_ftpserver.py"))
        
        complete_url_of_parent = get_delivery_status_url + parent_delivery_id
        complete_url = get_delivery_status_url + latest_revert_id

        ftp_delivery_path = get_delivery_ftp_path_complete_url(complete_url)
        check_contents_in_ftp_server_and_download_manifest(ftp_delivery_path, ftp_vevo_host, ftp_vevo_user, ftp_vevo_password)
        squish.snooze(30)
        copy_to_ftp_server(local_manifest_file_path, ftp_delivery_path, ftp_vevo_host, ftp_vevo_user, ftp_vevo_password)
        squish.snooze(60)
        test.log("waiting for 60 more seconds :")
        squish.snooze(60)
        delivery_stage = check_delivery_status_with_complete_url(complete_url)
        revert_stage_of_parent = check_revert_status_with_complete_url(complete_url_of_parent)  # REVERTED
        revert_stage = check_revert_status_with_complete_url(complete_url)  # UNREVERTABLE

        if(delivery_stage == "COMPLETE" and revert_stage == "UNREVERTABLE" and revert_stage_of_parent == "REVERTED"):
            test.passes("Delivery successfully Reverted")
            test.log("revert_stage: " + revert_stage)
            test.log("revert_stage_of_parent: " + revert_stage_of_parent)
        else:
            test.log("delivery_stage: " + delivery_stage)
            test.log("revert_stage: " + revert_stage)
            test.log("revert_stage_of_parent: " + revert_stage_of_parent)
            test.log("Reverting Delivery failed : " + complete_url)
            test.fail("Reverting Delivery failed : " + delivery_stage)
    else:
        test.fail("Reverting delivery has failed to complete the delivery")
def check_contents_in_ftp_server(ftp_delivery_path, ftp_vevo_host, ftp_vevo_user, ftp_vevo_password):
    test.log("check_contents_in_ftp_server")
    test.log("ftp_delivery_path : " + ftp_delivery_path)
    squish.snooze(60)

    files = []
    
    squish.snooze(60)

    try:
        session = ftplib.FTP(ftp_vevo_host, ftp_vevo_user, ftp_vevo_password)
        #print session
        session.cwd(ftp_delivery_path) # Change working directory 
        files = session.nlst()
        print files
        for filename in files:
            print filename
            if(len(files) == 3):
                test.fail("files are transferred to FTP server even though we have cancelled the delivery")
                return False
            elif(len(files) > 3):
                test.fail("no of files in the FTP server are more than 3 ")
                return False
            elif(len(files) < 3):
                test.passes("no of files in the FTP server are less than 3 ")
                return True
        session.quit()
    except Exception as e:
        print e
        s = str(e)
        print sys.exc_info()
        test.log("exception due to :" + s)
        test.fail("check_contents_in_ftp_server")
def create_restart_remove_delivery(create_delivery_url, create_failed_delivery_data, check_delivery_status_url, restart_url, remove_delivery_url, success):
    test.log("create_restart_remove_delivery()")
    test.log("create_delivery_url : " + create_delivery_url)
    test.log("check_delivery_status_url : " + check_delivery_status_url)
    test.log("restart_url : " + restart_url)
    test.log("remove_delivery_url : " + remove_delivery_url)

    delivery_id = None
    delivery_stage = None
    
    source(findFile("scripts", "deliverywebservices.py"))

    delivery_id = create_save_delivery_using_post_url(create_delivery_url, create_failed_delivery_data)
    squish.snooze(30);
    if(delivery_id or delivery_id != None):
        delivery_stage = restarting_delivery(check_delivery_status_url, restart_url, delivery_id) 
        source(findFile("scripts", "remove_delete_delivery.py"))
        squish.snooze(30);
        success = remove_delivery(remove_delivery_url, delivery_id,success)
        return success
    else:
        test.fail("delivery id is not created")
Ejemplo n.º 53
0
def register_app(app):
    """Registers an app into settings.G_APP_HANDLE, if this app is known."""
    good = False

    app_url = os.path.basename(os.path.normpath(app.cwd))
    app_array = filter(lambda x, app_url=app_url: x[1] == app_url,
                       settings.G_NAME_ID)
    app_name = None
    if len(app_array) != 0:
        app_name = app_array[0][0]

    if app_name is not None and app_name in settings.G_APP_HANDLE.keys():
        good = True
        if settings.G_APP_HANDLE[app_name] is None:
            settings.G_APP_HANDLE[app_name] = app
            test.log("Registered the new app '" + app_name +
                     "' to be usable in squish!")
        else:
            test.log("App '" + app_name + "' is already registered!")
    else:
        test.fail("The app with path '" + app.cwd + "' is not known!")
    return good
def get_list_of_assets(url, media_family_id):
    test.log("get_list_of_assets")
    test.log("url : " + url)
    test.log("media_family_id " + media_family_id)
    complete_url = url + media_family_id
    print complete_url 
    open = urllib2.urlopen(complete_url)
    dict = json.load(open)
    squish.snooze(10)
    test.log("get_list_of_assets" + complete_url)
    
    number_of_results = dict['numberOfResults']
    print number_of_results
    if(number_of_results > 0):
        count = 0
        print number_of_results
        test.log("successfully retrieved list of assets :")
        for i in range(number_of_results):
            count = count + 1
            assets_list = dict['results'][i]
            asset_id = assets_list['id']
            print asset_id
        if(number_of_results != count):
            test.fail("assets doesn't match the number of results retrieved")
        else:
            test.passes("asset ids exist")
    else:
        test.fail("No results exist for media family to get the list of assets")
        testdata = testData.create("shared", "status.failed")
        try:
            with open(testdata, "w+") as f:
                test.log("Failed so create a status file")  
        except Exception as e:
            print e
            s = str(e)
            test.log(s)
def check_contents_in_ftp_server_and_download_manifest(ftp_delivery_path,ftp_vevo_host,ftp_vevo_user,ftp_vevo_password):
    test.log("check_contents_in_ftp_server_and_download_manifest")
    test.log("ftp_delivery_path : " + ftp_delivery_path)
    squish.snooze(60)

    files = []
    absolute_path = None
    squish.snooze(60)

    try:
        session = ftplib.FTP(ftp_vevo_host, ftp_vevo_user, ftp_vevo_password)
        print session
        session.cwd(ftp_delivery_path) # Change working directory 
        files = session.nlst()
        print files
        for filename in files:
            print filename
            #getting delivery.complete.lock file as soon as file transfer has been done(look for that as well)
            if(len(files) == 3 and filename == "manifest.xml"):
                print filename
                
                testdata = testData.create("shared", filename)
                print testdata
                #dataFile = open(testdata, "w")
                #local_filename = os.path.join('download_manifest', filename)
                absolute_path = os.path.abspath(testdata)
                print absolute_path
                file = open(testdata, 'wb')
                session.retrbinary('RETR %s' % filename, file.write)
                file.close()
            elif(len(files) > 3):
                test.fail("no of files in the FTP server are more than 3")
                test.log(len(files))

            elif(len(files) < 3):
                test.fail("no of files in the FTP server are less than 3")
                test.log(len(files))

        session.quit()
        return absolute_path 
    except Exception as e:
        test.fail("check_contents_in_ftp_server_and_download_manifest")
        print e
        s = str(e)
        print sys.exc_info()
        test.log(s)
Ejemplo n.º 56
0
def main():
    
    test.log("Test Case Name: tst_create_queued_delivery")
 
    '''run the script to set the queued delivery'''
    
    # arguments to pass: 1 create a campaign with start date in the past and end date in future and any campaign Id: 84062112
    # arguments to pass: 2 QUEUED -create a campaign with start date in the future and end date in future and any campaign Id: 84062112
    # arguments to pass: 3 create a campaign with start date in the past and end date in past and any campaign Id: 84062112
    test.log("update adbroker database for campaign start and end dates")
    os.system("C:\\utils\\run_update_campaign_dates.bat 2 84062112")
    
    try:
        test.log("create successful delivery")
        delivery_id = None
        delivery_stage = None
        create_delivery_data = { 
        "serviceOriginName": "Dove UI",
        "callBackEndPoint": None,
        "callBackReferenceId": None,
        "requestTime": None,
        "sourceFile": 'hub://hub-t1/mirriad/storage/QA/GBUV71000779_I_AM_ARROWS_Another Picture Of You_no_P_logo_v2.mov',
        "deliveryFile": 'hub://hub-t1/mirriad/storage/QA/GBUV71000779_I_AM_ARROWS_Another Picture Of You_with_P_logo_v2.mov',
        "assetId": '4134',
        "campaignId": '84062112',
        "deliveryTargetService": 'VEVO',
        "revertOperation": False 
        }
        
        videoISRC = "USUV71201410" 
        
        data = testData.dataset("s_list_of_webservices.tsv")[0]
            
        create_delivery_url = testData.field(data, "create_save_delivery_using_post_url")
        get_delivery_status_url = testData.field(data, "get_delivery_status_url")
        
        source(findFile("scripts", "deliverywebservices.py"))

        '''create the delivery'''
        delivery_id = create_save_delivery_using_post_url(create_delivery_url, create_delivery_data)
        squish.snooze(40)
        
        delivery_stage = check_delivery_status(get_delivery_status_url, delivery_id)
        
        if(delivery_id and delivery_id != None and delivery_stage == "QUEUED"):
            
            test.log("delivery successfully created", delivery_id)
            testdata = testData.create("shared", "delivery_ids_for_reverting.tsv")
            dataFile = open(testdata, "w")
            dataFile.write("delivery_id\tvideoISRC\n")
            dataFile.write(delivery_id + "\t" + videoISRC)
            dataFile.close()
            test.log("tsv created")
        else:
            test.fail("delivery id is none or delivery stage is not queued")
    
    except Exception as e:
        print e
        s = str(e)
        print sys.exc_info()
        test.fail("create queued delivery has failed")
        if(s and s!=None):
            test.log(s)
            test.fail("create queued delivery has failed due to :" + s)
def create_delivery_first_step(create_delivery_data, videoISRC, hub_status_config_url, create_delivery_url, get_delivery_status_url, local_manifest_file_path_parse_success, local_manifest_file_path, count, ftp_vevo_host, ftp_vevo_user, ftp_vevo_password):
    
    #delivery_stage = None
    #local_manifest_file_path_success = "C:\\tmp\\vevo_status\\parse_success\\status-manifest.xml"
    test.log("create_delivery_first_step")
    test.log("videoISRC : " + videoISRC)
    test.log("hub_status_config_url : " + hub_status_config_url)
    test.log("create_delivery_url : " + create_delivery_url)
    test.log("get_delivery_status_url : " + get_delivery_status_url)
    test.log("local_manifest_file_path : " + local_manifest_file_path)

    if(local_manifest_file_path_parse_success != None):
        test.log("local_manifest_file_path_parse_success in create delivery first step : " + local_manifest_file_path_parse_success)
    else:
        test.log("local_manifest_file_path_parse_success is None for parse failure delivery")

    delivery_ftp_path = None
    manifest_file_path = None
    video_text = None
    first_step_pass = False
    
    source(findFile("scripts", "deliverywebservices.py"))

    '''check the status of delivery hub'''
    get_delivery_config_get_url(hub_status_config_url)
      
    '''create the delivery'''
    delivery_id = create_save_delivery_using_post_url(create_delivery_url, create_delivery_data)
               
    '''check the delivery status and get the ftp delivery path'''
    if(delivery_id and delivery_id != None):
       delivery_ftp_path = get_delivery_ftp_path(get_delivery_status_url, delivery_id, count)
       test.log("Delivery FTP Path: " + delivery_ftp_path)
    else:
       test.fail("No delivery Id returned : or duplicate delivery")
    
    source(findFile("scripts", "connect_to_ftpserver.py"))
       
    if(delivery_ftp_path != "NOTHING_TO_DO_ON_FAILED" and delivery_ftp_path != "NOTHING_TO_DO_ON_CANCELLED"):
        '''connect to FTP and download the manifest path to the local machine'''
        if(delivery_ftp_path and delivery_ftp_path != None):
           manifest_file_path = check_contents_in_ftp_server_and_download_manifest(delivery_ftp_path, ftp_vevo_host, ftp_vevo_user, ftp_vevo_password)
        else:
           test.fail("No delivery path returned from FTP :")
        source(findFile("scripts", "read_manifest_xml.py"))

        '''check the contents in the manifest xml file'''
        if(manifest_file_path and manifest_file_path != None):
           video_text = parsexml(manifest_file_path)
        else:
           test.fail("No manifest_file_path in local machine returned :")
            
        '''compare the original video ISRC code with the one in the manifest.xml file'''
        if(video_text and video_text != None):
            if(videoISRC == video_text):
               first_step_pass = True
               test.log("Video ISRC code in manifest xml matches with the original ISRC code")
               #delivery_status = copy_local_manifest_to_ftp(first_step_pass, ftp_delivery_path, local_manifest_file_path, get_delivery_status_url)
               #return delivery_status
            else:
               test.fail("Video ISRC code in the manifest xml doesn't match the original ISRC code")
               test.log(video_text)
               
    elif(delivery_ftp_path == "NOTHING_TO_DO_ON_CANCELLED"):
        test.log("delivery FTP path returns nothing to do status on cancelled")
        test.log("Delivery stage is cancelled")
        #success
    else:
       test.log("Failed to get delivery_ftp_path and deliver correct files into FTP server") 
       test.fail("Delivery stage is Failed so the delivery has been failed")

    
    if(first_step_pass):
        first_step_pass = False
        test.log("calling copy local manifest file to FTP")
        delivery_id = copy_local_manifest_to_ftp(delivery_ftp_path, local_manifest_file_path_parse_success, local_manifest_file_path, get_delivery_status_url, delivery_id, count, ftp_vevo_host, ftp_vevo_user, ftp_vevo_password)
        return delivery_id
    else:
        test.fail("First step FTP transfer has failed")
        return delivery_id
Ejemplo n.º 58
0
def main():
    try:
        
        test.log("Test Case Name: tst_create_parse_success_delivery")
        test.log("create parse success delivery")
    
        create_delivery_data_success = { 
        "serviceOriginName": "Dove UI",
        "callBackEndPoint": None,
        "callBackReferenceId": None,
        "requestTime": None,
        "sourceFile": 'hub://hub-t1/mirriad/storage/QA/GBUV71000779_I_AM_ARROWS_Another Picture Of You_no_P_logo_v2.mov',
        "deliveryFile": 'hub://hub-t1/mirriad/storage/QA/GBUV71000779_I_AM_ARROWS_Another Picture Of You_with_P_logo_v2.mov',
        "assetId": '12230',
        "campaignId": '27120900',
        "deliveryTargetService": 'VEVO',
        "revertOperation": False 
        }
        
        videoISRC = "GBUV71000779" # I am Arrows
        
        data = testData.dataset("s_list_of_webservices.tsv")[0]
            
        hub_status_config_url = testData.field(data, "get_delivery_config_get_url")
        create_delivery_url = testData.field(data, "create_save_delivery_using_post_url")
        get_delivery_status_url = testData.field(data, "get_delivery_status_url")
        manifest_parse_success_replace_success = "vevo_status\\parse_success_replace_success\\status-manifest.xml"
        manifest_parse_success = "vevo_status\\parse_success\\status-manifest.xml"
        #manifest_parse_success_replace_success = findFile("testdata", "vevo_status\\parse_success_replace_success\\status-manifest.xml")
        #manifest_parse_success = findFile("testdata", "vevo_status\\parse_success\\status-manifest.xml")
        delivery_ftp_path = None
        '''t01 ftp connection login details'''
        ftp_vevo_host = "ftp.uk.mirriad.com"
        ftp_vevo_user = "******"
        ftp_vevo_password = "******"
        ftp_vevo_port = 21
        ftp_vevo_vevo_user = "******"
        
        test.log("manifest_parse_success : " + manifest_parse_success)
        test.log("manifest_parse_success_replace_success : " + manifest_parse_success_replace_success)
        
        x = None
        count = 4 # using count for FTP transfer as a trigger
        delivery_id = None
        delivery_stage = None
        source(findFile("scripts", "create_delivery.py"))
        
        delivery_id = create_delivery_first_step(create_delivery_data_success, videoISRC, hub_status_config_url, create_delivery_url, get_delivery_status_url, manifest_parse_success, manifest_parse_success_replace_success, count, ftp_vevo_host, ftp_vevo_user, ftp_vevo_password)
        squish.snooze(60)

        if(delivery_id or delivery_id != None):
            source(findFile("scripts", "deliverywebservices.py"))
            squish.snooze(60)
            delivery_stage = check_delivery_status(get_delivery_status_url, delivery_id)
            delivery_ftp_path = get_delivery_ftp_path(get_delivery_status_url, delivery_id, count)

        '''remove the delivery as it is on waiting on confirmation, you cannot use the same delivery again
        transfer the file and change the status to completed'''
  
        if(delivery_stage == "WAITING_ON_CONFIRMATION"):
            test.passes("parse_success is successful")
            source(findFile("scripts", "connect_to_ftpserver.py"))
            manifest_parse_success_replace_success = findFile("testdata", manifest_parse_success_replace_success)
            squish.snooze(60)
            copy_to_ftp_server(manifest_parse_success_replace_success, delivery_ftp_path, ftp_vevo_host, ftp_vevo_user, ftp_vevo_password)
            source(findFile("scripts", "deliverywebservices.py"))
            squish.snooze(60)
            delivery_stage = check_delivery_status(get_delivery_status_url, delivery_id)
            if(delivery_stage == "COMPLETE"):
                test.passes("parse_success is successful and parse_success_replace_success is also successful")
            else:
                test.fail("parse_success_replace_success in parse success delivery has failed, deliveryStage : " + delivery_stage)
        elif(delivery_stage == "FAILED"):
            test.fail("Delivery stage is failed after copying parse success file so need not copy parse success replace success file")
        else:
            test.fail("parse_success delivery has failed")
    except Exception as e:
        print e
        s = str(e)
        print sys.exc_info()
        test.log(s)
        test.fail("parse_success has failed due to : " + s)
        testdata = testData.create("shared", "status.failed")
        try:
            with open(testdata, "w+") as f:
                test.log("Failed so create a status file")  
        except Exception as e:
            print e
            s = str(e)
            test.log(s)
Ejemplo n.º 59
0
import time

# import test utilities and configuration
import test

if __name__ == '__main__':

  # load test program onto arduino
  test.load('serial_test.hex')

  # open serial port
  ser = test.ser_open(1)

  output = [ 0 ]
  while True:
    for i in range(256):
      output[0] = i
      print "Sending byte %d"%i
      ser.write(str(bytearray(output)))
      inc = ser.read()
      if len(inc) != 1:
        print "Receive byte timed out"
        test.fail()
      else:
        print "Got byte %d"%ord(inc[0])
        if ord(inc[0]) != output[0]:
          print "Got a byte I wasn't expecting"
          test.fail()

#  test.pass()