Ejemplo n.º 1
0
    def test_table_single_row_modification(self):

        newQuantity = 800
        newSupplier = "screw supplier"

        table_page = TablePage(self.driver, PurchaseOrderScreen)
        table_page.login()

        # Open purchase order screen
        table_page.go_to_target_page_by_menu("Purchasing", "purchaseorder")

        firstrow = table_page.get_table_row(rowNumber=1)
        reference = firstrow.get_attribute("id")

        supplier_content = table_page.get_content_of_row_column(
            firstrow, "supplier")
        supplier_inputfield = table_page.click_target_cell(
            supplier_content, "supplier")
        # only put existing supplier otherwise saving modification fails
        table_page.enter_text_in_inputfield(supplier_inputfield, newSupplier)

        quantity_content = table_page.get_content_of_row_column(
            firstrow, "quantity")
        quantity_inputfield = table_page.click_target_cell(
            quantity_content, "quantity")
        table_page.enter_text_in_inputfield(quantity_inputfield, newQuantity)
        self.assertEqual(
            quantity_content.text,
            "800",
            "the input field of quantity hasn't been modified",
        )

        enddate_content = table_page.get_content_of_row_column(
            firstrow, "enddate")
        enddate_inputdatefield = table_page.click_target_cell(
            enddate_content, "enddate")

        oldEndDate = datetime.strptime(
            enddate_inputdatefield.get_attribute("value"), "%Y-%m-%d %H:%M:%S")
        newEndDate = oldEndDate + mainDate.timedelta(days=9)
        newdatetext = table_page.enter_text_in_inputdatefield(
            enddate_inputdatefield, newEndDate)

        enddate_content = table_page.get_content_of_row_column(
            firstrow, "enddate")
        enddate_inputdatefield = table_page.click_target_cell(
            enddate_content, "enddate")
        self.assertEqual(
            enddate_inputdatefield.get_attribute("value"),
            newEndDate.strftime("%Y-%m-%d %H:%M:%S"),
            "the input field of Receipt Date hasn't been modified",
        )

        # checking if data has been saved into database after saving data
        table_page.click_save_button()
        time.sleep(1)

        self.assertEqual(
            PurchaseOrder.objects.all().filter(
                reference=reference,
                enddate=newdatetext,
                supplier_id=newSupplier,
                quantity=newQuantity,
            ).count(),
            1,
        )
Ejemplo n.º 2
0
    def test_table_single_row_modification(self):

        newQuantity = 20
        newOperation = "Saw chair leg"

        table_page = TablePage(self.driver, SeleniumTest)
        table_page.login(self)

        # Open purchase order screen
        table_page.go_to_target_page_by_menu("Manufacturing",
                                             "manufacturingorder")

        manufacturing_order_table = table_page.get_table()

        firstrow = table_page.get_table_row(rowNumber=1)
        reference = firstrow.get_attribute("id")

        operation_content = table_page.get_content_of_row_column(
            firstrow, "operation")
        operation_inputfield = table_page.click_target_cell(
            operation_content, "operation")
        #only put existing operation otherwise saving modification fails
        table_page.enter_text_in_inputfield(operation_inputfield, newOperation)

        quantity_content = table_page.get_content_of_row_column(
            firstrow, "quantity")
        quantity_inputfield = table_page.click_target_cell(
            quantity_content, "quantity")
        table_page.enter_text_in_inputfield(quantity_inputfield, newQuantity)
        self.assertEqual(quantity_content.text, "20",
                         "the input field of quantity hasn't been modified")

        enddate_content = table_page.get_content_of_row_column(
            firstrow, "enddate")
        enddate_inputdatefield = table_page.click_target_cell(
            enddate_content, "enddate")

        oldEndDate = datetime.strptime(
            enddate_inputdatefield.get_attribute("value"), "%Y-%m-%d %H:%M:%S")
        newEndDate = oldEndDate + mainDate.timedelta(days=9)
        newdatetext = table_page.enter_text_in_inputdatefield(
            enddate_inputdatefield, newEndDate)

        enddate_content = table_page.get_content_of_row_column(
            firstrow, "enddate")
        enddate_inputdatefield = table_page.click_target_cell(
            enddate_content, "enddate")
        self.assertEqual(
            enddate_inputdatefield.get_attribute("value"),
            newEndDate.strftime("%Y-%m-%d 00:00:00"),
            "the input field of Receipt Date hasn't been modified")

        #checking if data has been saved into database after saving data
        table_page.click_save_button()
        time.sleep(1)

        self.assertEqual(
            ManufacturingOrder.objects.all().filter(
                reference=reference,
                enddate=newdatetext,
                operation_id=newOperation,
                quantity=newQuantity).count(),
            1,
        )