Ejemplo n.º 1
0
def get_sheet_with_value_to_copy():
    book = xw.Book()
    sheet_containing_value = book.sheets[0]
    first_cell_range = sheet_containing_value.range(1, 1)
    generated_value = fc.gen_line_desc()
    first_cell_range.value = generated_value
    return sheet_containing_value
Ejemplo n.º 2
0
def test_field_lock(ticket_id, test_description, expected_result, book_test,
                    sheet, field_to_test):
    actual_result = ""
    test_status = None

    # target metakey column number
    target_field_col_number = xwu.find_col_by_multi_metakey([field_to_test],
                                                            sheet)
    first_data_row = xwu.find_first_data_row(sheet)
    row_number_insert = xwu.get_insert_data_row_number(sheet)

    for test_execution in range(3):
        selected_row = rnd.randint(first_data_row, row_number_insert)

        # record the current target data value
        initial_target_line_data = sheet.range(selected_row,
                                               target_field_col_number).value

        # send keys to line number cell
        book_test.clicker.setup("OK")
        updated_target_line_data = fc.gen_line_desc()
        xwu.ensure_focus(sheet,
                         sheet.range(selected_row, target_field_col_number))
        pwa.keyboard.send_keys(updated_target_line_data + "~")
        time.sleep(4)

        # check that an error message appeared and the data remains unchanged
        if book_test.clicker.click_count == 0:
            test_status = 0
            actual_result = "The error message did not appear for column " + field_to_test + "for at least one instance. "

        if sheet.range(
                selected_row,
                target_field_col_number).value != initial_target_line_data:
            test_status = 0
            actual_result = actual_result + "For at least one test instance the value in field " + field_to_test + " has changed"

    if test_status == 0:
        pass
    else:
        test_status = 1
        actual_result = "Error messages appeared for the field " + field_to_test + " and the " + field_to_test + " field remains unchanged"

    # Write the test to the database
    logger.write_result(ticket_id, test_description, expected_result,
                        actual_result, test_status)
Ejemplo n.º 3
0
def test_line_level_field(ticket_id, test_description, expected_result,
                          field_to_test):
    """
	SUMMARY:
		Ensure data cannot be changed in especific columns received as paramedters.

		As an expected result, an error message must appear in the screen and the 
		data remains unchanged

	DETAILS:
		Opens Order Sheet workbook and runs Reset macro
		Reads the column for the especific field to test in the first data sheet
		Gets the first row with data in a range
		Gets the first row available for insert in a range
		Runs 10 times a test getting a row at random and attempts to write a value
		Check if the script changed the data or an screen error appeared and the data remains unchanged.
		Write the test result to the database

	NOTES:
		This script will generate error messages in the screen and will attemp to 
		answer them. Thus, the focus should always be hold by the worksheet, so using
		the keyboard during the test will make the script to fail.
	"""
    #set up the ordersheet with tinysheet2 data
    book_test = setup_order_sheet(parameter_path)
    global pid
    pid = book_test.process_id

    #tab object
    ts2_tab1 = book_test.order_sheet.sheets[
        book_test.excel_book_parameters['OrderSheet Tabs'][0]]

    #target metakey column number
    target_field_col_number = xwu.find_col_by_multi_metakey([field_to_test],
                                                            ts2_tab1)
    first_data_row = xwu.find_first_data_row(ts2_tab1)
    row_number_insert = xwu.get_insert_data_row_number(ts2_tab1)

    #run test 10 times for the target field (different rows)
    for test_execution in range(10):
        #select row number
        selected_row = rnd.randint(first_data_row, row_number_insert)

        #record the current target data value
        initial_target_line_data = ts2_tab1.range(
            selected_row, target_field_col_number).value

        #send keys to line number cell
        book_test.clicker.setup("OK")
        updated_target_line_data = fc.gen_line_desc()
        xwu.ensure_focus(ts2_tab1,
                         ts2_tab1.range(selected_row, target_field_col_number))
        pwa.keyboard.send_keys(updated_target_line_data + "~")
        time.sleep(3)

        #check that an error message appeared and the data remains unchanged
        print(book_test.clicker.click_count)
        if book_test.clicker.click_count == 0:
            test_status = 0
            actual_result = "For at least one test instance the error message did not appear, "

        if ts2_tab1.range(
                selected_row,
                target_field_col_number).value != initial_target_line_data:
            test_status = 0
            actual_result = "For at least one test instance the value in field " + field_to_test + " has changed"
    try:
        if test_status == 0:
            pass
    except:
        test_status = 1
        actual_result = "Error messages appeared and the " + field_to_test + " field remains unchanged"

    #Write the test to the database
    logger.write_result(ticket_id, test_description, expected_result,
                        actual_result, test_status)

    #Close the ordersheet/clicker thread
    book_test.clicker.shut_down()
    book_test.order_sheet.close()
Ejemplo n.º 4
0
xwu.write_random_valid_value(arcadia_season_range)
inputs['arcadia_season'] = arcadia_season_range.value

#write to newness or trade
new_trade_column = xwu.find_col_by_metakey("NewnessOrTrade")
order_sheet_tab.range(data_row, new_trade_column).value = fc.gen_new_trade()
inputs['new_trade'] = order_sheet_tab.range(data_row, new_trade_column).value

#Write line number
line_no_col = xwu.find_col_by_metakey("OriginalLineNumber")
order_sheet_tab.range(data_row, line_no_col).value = fc.gen_line_ref()
inputs['line_no'] = order_sheet_tab.range(data_row, line_no_col).value

#Write line desc
line_desc_col = xwu.find_col_by_metakey("OriginalLineDescription")
order_sheet_tab.range(data_row, line_desc_col).value = fc.gen_line_desc()
inputs['line_desc'] = order_sheet_tab.range(data_row, line_desc_col).value

#Write colour
colour_col = xwu.find_col_by_metakey("OriginalColour")
order_sheet_tab.range(data_row, colour_col).value = fc.gen_colour()
inputs['colour'] = order_sheet_tab.range(data_row, colour_col).value

#Write cloth comp
cloth_comp_col = xwu.find_col_by_metakey("ClothComp")
order_sheet_tab.range(data_row, cloth_comp_col).value = fc.gen_cloth_comp()
inputs['cloth_comp'] = order_sheet_tab.range(data_row, cloth_comp_col).value

#Write Coo
coo_col = xwu.find_col_by_metakey("Coo")
order_sheet_tab.range(data_row, coo_col).value = fc.gen_coo()