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
Ejemplo n.º 2
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")
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.º 4
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")
Ejemplo n.º 5
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.º 6
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.º 7
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.º 8
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_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")
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")
Ejemplo n.º 11
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.º 12
0
def load_series(window_given, series_num):

    series = ":scrollArea.frame-%s_SeriesThumbPreview" % (series_num - 1)

    window, x, y = find_window(window_given)

    # if series needed is bigger than 8, check if scrolling is needed to reach the series
    if object.exists(cvi42Objects.series_scrollbar):
        squish.scrollTo(squish.waitForObject(cvi42Objects.series_scrollbar),
                        -505)

        if series_num > 8:
            squish.scrollTo(
                squish.waitForObject(cvi42Objects.series_scrollbar), 855)

    # Load series into window requested

    squish.mouseMove(squish.waitForObject(series), 5, 5)
    squish.mousePress(squish.waitForObject(series))
    #     squish.snooze(1)
    squish.mouseRelease(squish.waitForObject(window))
    squish.snooze(0.2)

    if object.exists(":Load Volume.Yes_QPushButton"):
        squish.clickButton(
            squish.waitForObject(":Load Volume.Yes_QPushButton"))

    # Wait for progress bar
    time = loading_time()

    if time > 10:
        test.log("Time to load series: %.2f" % time)

    return
Ejemplo n.º 13
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")
Ejemplo n.º 14
0
def main():

    test.log("Test Case Name: tst_create_delivery_for_bulk_revert")
    '''run the script to set the 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 1 12735523")

    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": '6287',
        "campaignId": '12735523',
        "deliveryTargetService": 'VEVO',
        "revertOperation": False
    }

    videoISRC = "USUV71100201"
    #os.system("C:\\utils\\run_update_campaign_end_dates.bat 12735523")

    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")

    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")

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

    squish.snooze(30)
    delivery_id = create_delivery_and_save_delivery_id_to_tsv(
        create_delivery_url, create_delivery_data, videoISRC)
    squish.snooze(30)
    delivery_stage = check_delivery_status_until_waiting_on_confirmation(
        get_delivery_status_url, delivery_id)
    ftp_transfer(get_delivery_status_url, delivery_id, delivery_stage,
                 ftp_vevo_host, ftp_vevo_user, ftp_vevo_password,
                 local_manifest_file_path)
def check_delivery_status(check_delivery_status_url, delivery_id):
    test.log("check_delivery_status()")
    while(True):
        squish.snooze(10)
        source(findFile("scripts", "deliverywebservices.py"))
        delivery_stage = check_delivery_status(check_delivery_status_url, delivery_id)
        test.log(delivery_stage)
        if(delivery_stage == "FAILED"):
            test.log("Delivery successfully failed")
            return delivery_stage
Ejemplo n.º 16
0
def check_delivery_status(check_delivery_status_url, delivery_id):
    test.log("check_delivery_status()")
    while (True):
        squish.snooze(10)
        source(findFile("scripts", "deliverywebservices.py"))
        delivery_stage = check_delivery_status(check_delivery_status_url,
                                               delivery_id)
        test.log(delivery_stage)
        if (delivery_stage == "FAILED"):
            test.log("Delivery successfully failed")
            return delivery_stage
def get_delivery_ftp_path_complete_url(complete_url):
    test.log("get_delivery_ftp_path")
    test.log("url" + complete_url)
    while(True):
        squish.snooze(30)
        print complete_url 
        open = urllib2.urlopen(complete_url)
        dict = json.load(open)
        delivery_path = dict['deliveryPath']
        test.log("delivery_path: " + delivery_path)
        return delivery_path
Ejemplo n.º 18
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.º 19
0
def main():
    
    test.log("Test Case Name: tst_create_delivery_for_bulk_revert")
 
    '''run the script to set the 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 1 12735523")
    
    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": '6287',
        "campaignId": '12735523',
        "deliveryTargetService": 'VEVO',
        "revertOperation": False 
    }
        
    videoISRC = "USUV71100201" 
    #os.system("C:\\utils\\run_update_campaign_end_dates.bat 12735523")

        
    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")
       
    
    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")  
    
    local_manifest_file_path = findFile("testdata", "vevo_status\\parse_success_replace_success\\status-manifest.xml")

    squish.snooze(30)
    delivery_id = create_delivery_and_save_delivery_id_to_tsv(create_delivery_url, create_delivery_data,videoISRC)
    squish.snooze(30)
    delivery_stage = check_delivery_status_until_waiting_on_confirmation(get_delivery_status_url, delivery_id)
    ftp_transfer(get_delivery_status_url, delivery_id, delivery_stage, ftp_vevo_host, ftp_vevo_user, ftp_vevo_password, local_manifest_file_path)
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.º 21
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")
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")
def copy_to_ftp_server(local_manifest_file_path,ftp_delivery_path,ftp_vevo_host,ftp_vevo_user,ftp_vevo_password):
    test.log("copy_to_ftp_server started")
    test.log("local_manifest_file_path : " + local_manifest_file_path)
    test.log("ftp_delivery_path : " + ftp_delivery_path)
    squish.snooze(60)

    test.log("copying : "  + local_manifest_file_path + "to " +ftp_delivery_path)
    session = ftplib.FTP(ftp_vevo_host, ftp_vevo_user, ftp_vevo_password)
    file = open(local_manifest_file_path, 'rb')                  # file to send
    files = session.nlst()
    print files
    session.cwd(ftp_delivery_path)                   # Change working directory 
    session.storbinary('STOR status-manifest.xml', file)  # send the file using STOR command
    file.close()                                    # close file and FTP
    session.quit()
    test.log("copy_to_ftp_server finished")
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)
def restarting_delivery(check_delivery_status_url, restart_url, delivery_id):
    
    test.log("restarting_delivery()")
    delivery_stage = check_delivery_status(check_delivery_status_url, delivery_id)
    if(delivery_stage == "FAILED"):
       test.log("Delivery successfully failed")
    #restart the failed delivery
       source(findFile("scripts", "restart_delivery.py"))
       delivery_stage = restart_delivery(restart_url, delivery_id)
       if(delivery_stage == "RESTARTED"):
           while(True):
               squish.snooze(10)
               source(findFile("scripts", "deliverywebservices.py"))
               delivery_stage = check_delivery_status(check_delivery_status_url, delivery_id)
               if(delivery_stage == "FAILED"):
                   test.log("Delivery successfully failed")
                   return delivery_stage
Ejemplo n.º 26
0
    def findObjectWithText(self,
                           object,
                           value,
                           property='text',
                           lang=None,
                           exact_match=False,
                           delay=0,
                           time_out=15000):
        squish.snooze(delay / 1000.0)
        if lang is not None:
            value = self.getTranslatedText(value, lang)

        obj = object.copy()
        if exact_match:
            obj[property] = value
        else:
            obj[property] = Wildcard("*" + value + "*")
        return waitForObject(obj, time_out)
Ejemplo n.º 27
0
def close_study():

    squish.activateItem(
        squish.waitForObjectItem(cvi42Objects.menuBar, "Workspace"))
    squish.snooze(0.5)
    squish.activateItem(
        squish.waitForObjectItem(cvi42Objects.workspaceButton, "Close Study"))
    start = time.time()

    while True:
        if object.exists(cvi42Objects.patientlistEditBox) is True:
            break
        else:
            pass
    end = time.time()

    test.log("Time to close study: %.2f" % (end - start))

    return
Ejemplo n.º 28
0
    def objectWithTextExists(self,
                             object_template,
                             value,
                             property="text",
                             lang=None,
                             exact_match=False,
                             pause=0):
        squish.snooze(
            pause /
            1000.0)  #Possibly we need to wait for the interface to update.
        if lang is not None:
            value = self.getTranslatedText(value, lang)

        obj = object_template.copy()
        if exact_match:
            obj[property] = value
        else:
            obj[property] = Wildcard("*" + value + "*")
        return object.exists(obj)
def copy_to_ftp_server(local_manifest_file_path, ftp_delivery_path,
                       ftp_vevo_host, ftp_vevo_user, ftp_vevo_password):
    test.log("copy_to_ftp_server started")
    test.log("local_manifest_file_path : " + local_manifest_file_path)
    test.log("ftp_delivery_path : " + ftp_delivery_path)
    squish.snooze(60)

    test.log("copying : " + local_manifest_file_path + "to " +
             ftp_delivery_path)
    session = ftplib.FTP(ftp_vevo_host, ftp_vevo_user, ftp_vevo_password)
    file = open(local_manifest_file_path, 'rb')  # file to send
    files = session.nlst()
    print files
    session.cwd(ftp_delivery_path)  # Change working directory
    session.storbinary('STOR status-manifest.xml',
                       file)  # send the file using STOR command
    file.close()  # close file and FTP
    session.quit()
    test.log("copy_to_ftp_server finished")
Ejemplo n.º 30
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.º 31
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.º 32
0
def restarting_delivery(check_delivery_status_url, restart_url, delivery_id):

    test.log("restarting_delivery()")
    delivery_stage = check_delivery_status(check_delivery_status_url,
                                           delivery_id)
    if (delivery_stage == "FAILED"):
        test.log("Delivery successfully failed")
        #restart the failed delivery
        source(findFile("scripts", "restart_delivery.py"))
        delivery_stage = restart_delivery(restart_url, delivery_id)
        if (delivery_stage == "RESTARTED"):
            while (True):
                squish.snooze(10)
                source(findFile("scripts", "deliverywebservices.py"))
                delivery_stage = check_delivery_status(
                    check_delivery_status_url, delivery_id)
                if (delivery_stage == "FAILED"):
                    test.log("Delivery successfully failed")
                    return delivery_stage
Ejemplo n.º 33
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")
Ejemplo n.º 34
0
    def restartCuraWithArguments(self):
        squish.snooze(12)  #Allow autosave to kick in.
        squish.currentApplicationContext().detach()

        # Get registered AUT name from conf file
        suite_conf = os.path.join(squishinfo.testCase, "..", "suite.conf")
        aut = None

        with open(suite_conf) as file:
            line = file.readline()
            while line:
                if line.startswith("AUT="):
                    aut = (line.split("AUT=")[1]).rstrip()
                    break
        try:
            projFile = "3mf" in aut
            startApplication(aut)
            waitForObject(names.open_Project_QQuickWindowQmlImpl, 50000)
        except LookupError:
            print("No project file given as an argument to Cura")
Ejemplo n.º 35
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.º 36
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
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.º 38
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
Ejemplo n.º 39
0
def step(context, views):
    if not context.userData:
        context.userData = {}
    calling_name = context.userData['calling']

    # use a natural numbering, so +1 since entry 0 is entry 1
    squish.snooze(0.25)
    # switch and wait a little
    app.switch_to_app('phone')
    squish.snooze(0.25)

    caller_name_obj = squish.waitForObject(names.phoneCallerLabel)

    caller_name = None
    if caller_name_obj is not None:
        caller_name = str(caller_name_obj.text)
    # end call before comparing
    end_call_button = squish.waitForObject(names.phoneCallerEndButton)
    squish.tapObject(end_call_button)

    app.compare(calling_name, caller_name, "calling the right name")

    # switch to main before new command
    app.switch_to_main_app()
    squish.snooze(0.2)
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 get_delivery_ftp_path(url, delivery_id, count):
    test.log("get_delivery_ftp_path")
    test.log("url" + url)
    test.log("delivery_id" + delivery_id)
    while(True):
        squish.snooze(30)
        complete_url = url + delivery_id
        print complete_url 
        open = urllib2.urlopen(complete_url)
        dict = json.load(open)
        #pprint(dict)
        delivery_stage = dict['deliveryStage'] 
        delivery_path = dict['deliveryPath']
        print delivery_stage
    
        if(delivery_stage == "WAITING_ON_CONFIRMATION"):
                return delivery_path
        elif(delivery_stage == "COMPLETE"):
                return delivery_path 
        elif(delivery_stage == "FAILED"):
            return "NOTHING_TO_DO_ON_FAILED"
        elif(delivery_stage == "CANCELLED"):
            return "NOTHING_TO_DO_ON_CANCELLED"
Ejemplo n.º 42
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")
Ejemplo n.º 43
0
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 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)
Ejemplo n.º 45
0
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")
Ejemplo n.º 46
0
def main(): 
    
    test.log("Test Case Name: tst_bulk_start_queued_deliveries")
    data = testData.dataset("s_list_of_webservices.tsv")[0]
    start_queued_deliveries_get = testData.field(data, "start_queued_deliveries_get_call")
    
    #revert_delivery_with_id_put = testData.field(data, "revert_delivery_with_id_put_call")
    #revert_all_deliveries_get = testData.field(data, "revert_all_deliveries_get_call")
    
    get_delivery_status_url = testData.field(data, "get_delivery_status_url")


    data = testData.dataset("delivery_ids_for_reverting.tsv")[0]
    delivery_id = testData.field(data, "delivery_id")  
    videoISRC = testData.field(data, "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")  
    # ftp_vevo_port = testData.field(data, "ftp_vevo_port")  
    # ftp_vevo_vevo_user = testData.field(data, "ftp_vevo_vevo_user")  
        
    #manifest_parse_success_replace_success = "vevo_status\\parse_success_replace_success\\status-manifest.xml"

    test.log("get_delivery_status_url: " + get_delivery_status_url)
    test.log("delivery_id: " + delivery_id) 
    test.log("videoISRC: " + videoISRC) 
    
    manifest_parse_success_replace_success = findFile("testdata", "vevo_status\\parse_success_replace_success\\status-manifest.xml")

    squish.snooze(30)
    start_queued_deliveries(start_queued_deliveries_get)
    delivery_stage = check_delivery_status_until_waiting_on_confirmation(get_delivery_status_url, delivery_id)
    ftp_transfer(get_delivery_status_url, delivery_id,delivery_stage, ftp_vevo_host, ftp_vevo_user, ftp_vevo_password, manifest_parse_success_replace_success)
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.º 48
0
    def clickTab(self, tabName):
        # It might take some time for all files to sync except the expected number of unsynced files
        squish.snooze(10)

        tabFound = False

        # Selecting tab by name fails for "Not Synced" when there are no unsynced files
        # Because files count will be appended like "Not Synced (2)"
        # So to overcome this the following approach has been implemented
        tabCount = squish.waitForObjectExists(self.SUBTAB_CONTAINER).count
        for index in range(tabCount):
            tabText = squish.waitForObjectExists({
                "container": names.stack_qt_tabwidget_tabbar_QTabBar,
                "index": index,
                "type": "TabItem",
            }).text

            if tabName in tabText:
                tabFound = True
                squish.clickTab(squish.waitForObject(self.SUBTAB), tabText)
                break

        if not tabFound:
            raise Exception("Tab not found: " + tabName)
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
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")
Ejemplo n.º 51
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)
Ejemplo n.º 52
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)