コード例 #1
0
def insert_data_into_existing_rows(sheet_tab, metakey_list):
    data_start_row = xwu.find_first_data_row(sheet_tab)
    db_status_col_number = xwu.find_col_by_metakey('DbStatus')

    while sheet_tab.range(data_start_row, db_status_col_number).value == 2:
        fc.test_populator(sheet_tab, data_start_row, metakey_list,
                          partner_list)
        data_start_row = data_start_row + 1
コード例 #2
0
def test1():
    # setup parameters
    ticket_id = ''
    test_description = 'After inserting a wholesale line which will be transmitted to the OrderBook. For a partner without any units, populate a unit for them. Ensure that both Delivery Not Before/After dates have been populated correctly.'
    expected_result = 'Delivery Not Before and Delivery Not After Dates have been Populated correctly.'

    #Get WSR List
    whole_sale_ready_list = fc.get_wholesale_ready_metakey_list(
        os_column_tab, exclude_order_book=True)
    whole_sale_ready_list.append("PartnerOriginalUnitsBySize")
    whole_sale_ready_list.append("SizeRange")
    whole_sale_ready_list.append("OriginalDespatchMonth")

    #Get Random Partner
    partner_list = cu.get_partners(order_sheet)
    random_partner = rnd.choice(partner_list)
    partner_list.remove(random_partner)

    #Get data insert row
    data_insert_row_no = xwu.get_insert_data_row_number(tiny_sheet_tab_1)

    #Populate Wholesale ready fields and Units for given Partner
    fc.test_populator(tiny_sheet_tab_1,
                      data_insert_row_no,
                      whole_sale_ready_list, [random_partner],
                      max_col_range=2000)

    #Get ORID of inputted row
    order_row_id_val = str(
        tiny_sheet_tab_1.range(
            data_insert_row_no,
            metakey_col_dict_tiny_sheet[("OrderRowId", None, None)]).value)

    #Gets a dictionry of possible metakeys to insert units into to proc the delivery not before/after
    by_units_ob_metakey_list = []
    for key_tuple in metakey_col_dict_tiny_book:
        if key_tuple[0] in [
                "PartnerOriginalUnitsBySize", "PartnerRevisedUnitsBySize"
        ] and key_tuple[1] != random_partner:
            by_units_ob_metakey_list.append(key_tuple)
    by_units_ob_metakey_set = set(by_units_ob_metakey_list)

    metakey_units_by_size_insert_dict = xwu.get_metakey_dict_for_sheet(
        by_units_ob_metakey_set, metakey_col_dict_tiny_book)

    #Sync the orderbook
    tool_object_ob.refresh_all_sheets()

    #Get Row no in the ob to insert data into
    ob_row_insert_no = xwu.find_row_no_by_orwid(tiny_book_tab_1,
                                                order_row_id_val)

    #populate a random units cell block
    selected_metakey_tuple = rnd.choice(
        list(metakey_units_by_size_insert_dict.keys()))
    selected_metakey = selected_metakey_tuple[0]
    selected_partner_ob = selected_metakey_tuple[1]
    fc.test_populator(tiny_book_tab_1, ob_row_insert_no, [selected_metakey],
                      [selected_partner_ob])

    #Get the original despatch month of the partner you inputted data into
    original_despatch_month_value = tiny_book_tab_1.range(
        ob_row_insert_no, metakey_col_dict_tiny_book[("OriginalDespatchMonth",
                                                      None, None)]).value

    #Set the arcadia book to the sheet you need and get the deliverynotvefore/after required values
    arcadia_tool.set_current_sheet(selected_partner_ob)
    expected_delivery_not_before_value = arcadia_tool.get_lookup_value_given_despatch_month_for_partner(
        "DeliveryNotBefore", original_despatch_month_value)
    expected_delivery_not_after_value = arcadia_tool.get_lookup_value_given_despatch_month_for_partner(
        "DeliveryNotAfter", original_despatch_month_value)

    #Check that delivery not before/after have been populated correctly

    if tiny_book_tab_1.range(
            ob_row_insert_no, metakey_col_dict_tiny_book[(
                "DeliveryNotBefore", selected_partner_ob,
                None)]).value == expected_delivery_not_before_value:
        test_status = 1
        actual_result = "The Delivery Not Before Date has been correctly populated"
    else:
        test_status = 0
        actual_result = "The Delivery Not Before Date has been incorrectly populated"

    if tiny_book_tab_1.range(
            ob_row_insert_no, metakey_col_dict_tiny_book[(
                "DeliveryNotAfter", selected_partner_ob,
                None)]).value == expected_delivery_not_after_value:
        actual_result = actual_result + ", The Delivery Not After Date has been correctly populated"
    else:
        test_status = 0
        actual_result = actual_result + ", The Delivery Not After Date has been incorrectly populated"

    logger.write_result(ticket_id, test_description, expected_result,
                        actual_result, test_status)
コード例 #3
0
def write_data_to_order_sheet_tab(sheet_tab):
    row_number_to_write = xwu.get_insert_data_row_number(sheet_tab)
    fc.test_populator(sheet_tab, row_number_to_write, not_wholesale_ready_list,
                      partner_list)
    return row_number_to_write