예제 #1
0
    def test_inline_section_remove(self):
        """ Tests removing section from a single listing
        """

        expected_section_names = ['Summer Sale', 'Choose Section']

        expected_api_calls = [{
            'PUT': '/v2/listings/100002?shop_section_id=0',
            'body': {
                'listing_id': 100002,
                'state': 'active'
            }
        }]

        bp = BulkPage(self.driver)
        bp.select_single_section('Second something 1235', 'None')

        # Check listings
        assert bp.section_names() == expected_section_names

        # Check that sync button is enabled after clicking on Apply
        wait_for_web_assert(True,
                            bp.sync_updates_button().is_enabled,
                            'Sync button is not enabled')

        # Sync changes
        click(bp.sync_updates_button())

        # Check that sync button is disabled after clicking on Sync
        wait_for_web_assert(False,
                            bp.sync_updates_button().is_enabled,
                            'Sync button is not disabled')

        # Check API calls to Etsy emulator - section should be set to None on one listing
        check_etsy_emulator_requests(expected_api_calls)
예제 #2
0
    def test_wholesale_bulk_delete_occasion(self):
        """ Test verifies bulk delete of occasion of listings that have different value of the flag
            'can_write_inventory' - Etsy returns false for this flag when a listing is not Retail listing. So far it is
            not possible to update inventory and attributes on such listings through API, therefore VELA doesn't allow
            to change it.
            Test also verifies that if 'can_write_inventory' is changed to false on Etsy, no occasion
            updates of the listing are sent to Etsy (HIVE-1553).
        """

        expected_can_write_inventory = [
            ('100001', True),
            ('100002', False),
            ('100003', False),
        ]

        retail_expected_value = 'Choose Occasion'

        expected_api_calls = [{
            'DELETE': '/v2/listings/100001/attributes/46803063641',
            'body': {}
        }]

        # ---- Make changes in Occasion editor ----

        bp = BulkPage(self.driver)
        click(bp.edit_part('Occasion'))
        bp.select_occasion('None')

        # Apply changes and check listings
        click(bp.operation_apply())

        assert bp.listing_row('One').text == 'One\n' + retail_expected_value
        assert bp.listing_row(
            'Two').text == 'Two\n' + CANNOT_EDIT_OCCASION_TEXT
        assert bp.listing_row(
            'Three').text == 'Three\n' + retail_expected_value

        # Check that sync button is enabled after clicking on Apply
        wait_for_web_assert(True,
                            bp.sync_updates_button().is_enabled,
                            'Sync button is not enabled')

        # Sync changes
        click(bp.sync_updates_button())

        # Check that sync button is disabled after clicking on Sync
        wait_for_web_assert(False,
                            bp.sync_updates_button().is_enabled,
                            'Sync button is not disabled')

        # Check API calls to Etsy emulator - only first listing should be updated
        check_etsy_emulator_requests(expected_api_calls)

        # Check can_write_inventory flags in DB - it was set to False on the listing 'Three'
        assert self.db.get_can_write_inventory(
        ) == expected_can_write_inventory
예제 #3
0
    def test_bulk_section_add(self):
        """ Tests adding a new section and setting it to listings using bulk operation
        """

        new_section_name = 'New section'

        expected_section_names = [new_section_name] * 2

        expected_api_calls = [{
            'POST': '/v2/shops/14458117/sections?title=New%20section',
            'body': {}
        }, {
            'PUT': '/v2/listings/100001',
            'body': {
                'listing_id': 100001,
                'shop_section_id': '66666666',
                'state': 'active'
            }
        }, {
            'PUT': '/v2/listings/100002',
            'body': {
                'listing_id': 100002,
                'shop_section_id': '66666666',
                'state': 'active'
            }
        }]

        bp = BulkPage(self.driver)
        bp.add_new_section(new_section_name)

        # Apply changes and check listings
        click(bp.operation_apply())
        assert bp.section_names() == expected_section_names

        # Check that sync button is enabled after clicking on Apply
        wait_for_web_assert(True,
                            bp.sync_updates_button().is_enabled,
                            'Sync button is not enabled')

        # Sync changes
        click(bp.sync_updates_button())

        # Check that sync button is disabled after clicking on Sync
        wait_for_web_assert(False,
                            bp.sync_updates_button().is_enabled,
                            'Sync button is not disabled')

        # Check API calls to Etsy emulator - new section should be created and two listings updated
        check_etsy_emulator_requests(expected_api_calls)
예제 #4
0
    def test_bulk_section_change(self):
        """ Tests changing section on listings using bulk operation
        """

        expected_section_names = ['On Sale'] * 2

        expected_api_calls = [{
            'PUT': '/v2/listings/100001',
            'body': {
                'listing_id': 100001,
                'shop_section_id': '15183328',
                'state': 'active'
            }
        }, {
            'PUT': '/v2/listings/100002',
            'body': {
                'listing_id': 100002,
                'shop_section_id': '15183328',
                'state': 'active'
            }
        }]

        bp = BulkPage(self.driver)
        bp.select_section('On Sale')

        # Apply changes and check listings
        click(bp.operation_apply())
        assert bp.section_names() == expected_section_names

        # Check that sync button is enabled after clicking on Apply
        wait_for_web_assert(True,
                            bp.sync_updates_button().is_enabled,
                            'Sync button is not enabled')

        # Sync changes
        click(bp.sync_updates_button())

        # Check that sync button is disabled after clicking on Sync
        wait_for_web_assert(False,
                            bp.sync_updates_button().is_enabled,
                            'Sync button is not disabled')

        # Check API calls to Etsy emulator - section should be changed on two listings
        check_etsy_emulator_requests(expected_api_calls)
예제 #5
0
    def test_variations_inline_visibility_change(self):
        """ Tests visibilities changes on two listings using variations inline edit
        """

        expected_product_offerings = [
            ['1', '500.00', '550', '50', 't', '', '', '', ''],
            ['2', '1.00', '111', '11', 't', 'Beige', '1', '', ''],
            ['2', '2.00', '111', '11', 'f', 'Black', '2', '', ''],
            ['2', '3.00', '111', '11', 't', 'Blue', '3', '', ''],
            ['2', '4.00', '111', '11', 'f', 'Silver', '4', '', ''],
            ['2', '5.00', '111', '11', 't', 'White', '5', '', ''],
            ['2', '6.00', '111', '11', 't', 'Yellow', '6', '', ''],
            ['2', '7.00', '111', '11', 't', 'Custom color 1', '7', '', ''],
            ['2', '8.00', '111', '11', 't', 'Custom color 2', '8', '', ''],
            ['3', '10.00', '222', '1', 't', 'XXS', '1', 'Material 1', '1'],
            ['3', '20.00', '222', '2', 't', 'XXS', '1', 'Material 2', '2'],
            ['3', '30.00', '222', '3', 't', 'XXS', '1', 'Material 3', '3'],
            [
                '3', '40.00', '222', '4', 'f', 'One size (plus)', '2',
                'Material 1', '1'
            ],
            [
                '3', '50.00', '222', '5', 't', 'One size (plus)', '2',
                'Material 2', '2'
            ],
            [
                '3', '60.00', '222', '6', 't', 'One size (plus)', '2',
                'Material 3', '3'
            ],
            [
                '3', '70.00', '222', '7', 't', 'Custom size 1', '3',
                'Material 1', '1'
            ],
            [
                '3', '80.00', '222', '8', 't', 'Custom size 1', '3',
                'Material 2', '2'
            ],
            [
                '3', '90.00', '222', '9', 't', 'Custom size 1', '3',
                'Material 3', '3'
            ]
        ]

        from data.test_variations_inline_visibility_change_expected_data import expected_api_calls

        self.set_etsy_testcase('listings_push_inventory')

        bpiv = BulkPageInventoryVariations(self.driver, self.ts)

        # --- Change visibilities in 2nd listing ---

        row2 = bpiv.listing_row('Product #2 with one variation with pricing')
        bpiv.select_inventory_tab(row2, 'Visibility')

        # Click second and third toggle
        toggles = bpiv.bulk_individual_option_toggles(row2, i=0)
        click(toggles[1])
        click(toggles[2])

        # --- Change visibilities in 3rd listing ---

        row3 = bpiv.listing_row(
            'Product #3 with two variations with quantity on both and pricing on both'
        )
        bpiv.select_inventory_tab(row3, 'Visibility')

        # Click fourth and fifth toggle
        toggles = bpiv.bulk_individual_option_toggles(row3, i=0)
        click(toggles[3])
        click(toggles[4])

        bpiv.end_inline_edit()

        # --- Check selection of listings, sync button/dot and then sync updates ---

        # Check that edited listings are unchecked
        check_listings_checked(bpiv, [True, False, False])

        # Check that sync is ready and sync
        check_sync_button_and_dot(bpiv, expected_sync_ready=True)
        click(bpiv.sync_updates_button())
        check_sync_button_and_dot(bpiv, expected_sync_ready=False)

        # --- Check state of data in DB and requests to Etsy emulator

        check_db_state(expected_product_offerings,
                       DB_INITIAL_VARIATION_PROPERTIES,
                       DB_INITIAL_VARIATION_OPTIONS)
        check_etsy_emulator_requests(expected_api_calls)
예제 #6
0
    def test_variations_inline_sku_change(self):
        """ Tests SKU changes on two listings including where the SKU is set using variations inline edit
        """

        new_sku2 = 'SKU002'
        new_skus3 = ['SKU003A', 'SKU003B', 'SKU003C']

        expected_product_offerings = [
            ['1', '500.00', '550', '50', 't', '', '', '', ''],
            ['2', '1.00', 'SKU002', '11', 't', 'Beige', '1', '', ''],
            ['2', '2.00', 'SKU002', '11', 't', 'Black', '2', '', ''],
            ['2', '3.00', 'SKU002', '11', 'f', 'Blue', '3', '', ''],
            ['2', '4.00', 'SKU002', '11', 'f', 'Silver', '4', '', ''],
            ['2', '5.00', 'SKU002', '11', 't', 'White', '5', '', ''],
            ['2', '6.00', 'SKU002', '11', 't', 'Yellow', '6', '', ''],
            ['2', '7.00', 'SKU002', '11', 't', 'Custom color 1', '7', '', ''],
            ['2', '8.00', 'SKU002', '11', 't', 'Custom color 2', '8', '', ''],
            ['3', '10.00', 'SKU003A', '1', 't', 'XXS', '1', 'Material 1', '1'],
            ['3', '20.00', 'SKU003B', '2', 't', 'XXS', '1', 'Material 2', '2'],
            ['3', '30.00', 'SKU003C', '3', 't', 'XXS', '1', 'Material 3', '3'],
            [
                '3', '40.00', '222', '4', 't', 'One size (plus)', '2',
                'Material 1', '1'
            ],
            [
                '3', '50.00', '222', '5', 'f', 'One size (plus)', '2',
                'Material 2', '2'
            ],
            [
                '3', '60.00', '222', '6', 't', 'One size (plus)', '2',
                'Material 3', '3'
            ],
            [
                '3', '70.00', '222', '7', 't', 'Custom size 1', '3',
                'Material 1', '1'
            ],
            [
                '3', '80.00', '222', '8', 't', 'Custom size 1', '3',
                'Material 2', '2'
            ],
            [
                '3', '90.00', '222', '9', 't', 'Custom size 1', '3',
                'Material 3', '3'
            ]
        ]

        expected_variation_properties = [[
            '2', 't', '200', 'Primary color', '', 't', 'f', 'f'
        ], ['3', 't', '52047899294', 'Size', '25', 't', 't',
            't'], ['3', 'f', '507', 'Material', '', 't', 't', 't']]

        from data.test_variations_inline_sku_change_expected_data import expected_api_calls

        self.set_etsy_testcase('listings_push_inventory')

        bpiv = BulkPageInventoryVariations(self.driver, self.ts)

        # --- Change global sku in 2nd listing ---

        row2 = bpiv.listing_row('Product #2 with one variation with pricing')
        bpiv.select_inventory_tab(row2, 'SKU')

        # Clear global input and set to new value
        global_input = bpiv.global_sku_input(row2)
        global_input.clear()
        send_keys(global_input, new_sku2)

        # --- Change skus to combinations and set values in 3rd listing ---

        row3 = bpiv.listing_row(
            'Product #3 with two variations with quantity on both and pricing on both'
        )
        bpiv.select_inventory_tab(row3, 'SKU')
        # Clear global input and switch to sku on combinations
        global_input = bpiv.global_sku_input(row3)
        global_input.clear()
        click(bpiv.bulk_header_checkbox(row3, 0), delay=0.5)

        # Set skus
        for i, sku in enumerate(new_skus3):
            sku_input = bpiv.bulk_individual_option_inputs(row3, 0)[i]
            sku_input.clear()
            send_keys(sku_input, sku)

        bpiv.end_inline_edit()

        # --- Check selection of listings, sync button/dot and sync updates ---

        # Check that edited listings are unchecked
        check_listings_checked(bpiv, [True, False, False])

        # Check that sync is ready and sync
        check_sync_button_and_dot(bpiv, expected_sync_ready=True)
        click(bpiv.sync_updates_button())
        check_sync_button_and_dot(bpiv, expected_sync_ready=False)

        # --- Check state of data in DB and requests to Etsy emulator
        check_db_state(expected_product_offerings,
                       expected_variation_properties,
                       DB_INITIAL_VARIATION_OPTIONS)
        check_etsy_emulator_requests(expected_api_calls)
예제 #7
0
    def test_variations_inline_properties_changes(self):
        """ Test checks various changes of variation properties on all listings
         - add property, add option, delete option, ...

        :return:
        """

        expected_product_offerings = [
            ['1', '33.33', '550', '33', 't', 'Beige', '1', 'Blue', '1'],
            ['1', '333.33', '550', '33', 't', 'Beige', '1', 'Levande', '2'],
            ['1', '33.33', '550', '33', 't', 'Black', '2', 'Blue', '1'],
            ['1', '333.33', '550', '33', 't', 'Black', '2', 'Levande', '2'],
            ['1', '33.33', '550', '33', 't', 'Blue', '3', 'Blue', '1'],
            ['1', '333.33', '550', '33', 't', 'Blue', '3', 'Levande', '2'],
            ['1', '33.33', '550', '33', 't', 'Bronze', '4', 'Blue', '1'],
            ['1', '333.33', '550', '33', 't', 'Bronze', '4', 'Levande', '2'],
            ['1', '33.33', '550', '33', 't', 'Brown', '5', 'Blue', '1'],
            ['1', '333.33', '550', '33', 't', 'Brown', '5', 'Levande', '2'],
            ['1', '33.33', '550', '33', 't', 'Clear', '6', 'Blue', '1'],
            ['1', '333.33', '550', '33', 't', 'Clear', '6', 'Levande', '2'],
            ['1', '33.33', '550', '33', 't', 'Copper', '7', 'Blue', '1'],
            ['1', '333.33', '550', '33', 't', 'Copper', '7', 'Levande', '2'],
            ['1', '33.33', '550', '33', 't', 'Gold', '8', 'Blue', '1'],
            ['1', '333.33', '550', '33', 't', 'Gold', '8', 'Levande', '2'],
            ['1', '33.33', '550', '33', 't', 'Gray', '9', 'Blue', '1'],
            ['1', '333.33', '550', '33', 't', 'Gray', '9', 'Levande', '2'],
            ['1', '33.33', '550', '33', 't', 'Green', '10', 'Blue', '1'],
            ['1', '333.33', '550', '33', 't', 'Green', '10', 'Levande', '2'],
            ['1', '33.33', '550', '33', 't', 'Orange', '11', 'Blue', '1'],
            ['1', '333.33', '550', '33', 't', 'Orange', '11', 'Levande', '2'],
            ['1', '33.33', '550', '33', 't', 'Pink', '12', 'Blue', '1'],
            ['1', '333.33', '550', '33', 't', 'Pink', '12', 'Levande', '2'],
            ['1', '33.33', '550', '33', 't', 'Purple', '13', 'Blue', '1'],
            ['1', '333.33', '550', '33', 't', 'Purple', '13', 'Levande', '2'],
            ['1', '33.33', '550', '33', 't', 'Rainbow', '14', 'Blue', '1'],
            ['1', '333.33', '550', '33', 't', 'Rainbow', '14', 'Levande', '2'],
            ['1', '33.33', '550', '33', 't', 'Red', '15', 'Blue', '1'],
            ['1', '333.33', '550', '33', 't', 'Red', '15', 'Levande', '2'],
            ['1', '33.33', '550', '33', 't', 'Rose gold', '16', 'Blue', '1'],
            [
                '1', '333.33', '550', '33', 't', 'Rose gold', '16', 'Levande',
                '2'
            ], ['1', '33.33', '550', '33', 't', 'Silver', '17', 'Blue', '1'],
            ['1', '333.33', '550', '33', 't', 'Silver', '17', 'Levande', '2'],
            ['1', '33.33', '550', '33', 't', 'White', '18', 'Blue', '1'],
            ['1', '333.33', '550', '33', 't', 'White', '18', 'Levande', '2'],
            ['1', '33.33', '550', '33', 't', 'Yellow', '19', 'Blue', '1'],
            ['1', '333.33', '550', '33', 't', 'Yellow', '19', 'Levande', '2'],
            ['2', '1.00', '111', '111', 't', 'Beige', '1', '44.4', '1'],
            ['2', '1.00', '111', '222', 't', 'Beige', '1', '55.5', '2'],
            ['2', '2.00', '111', '111', 't', 'Black', '2', '44.4', '1'],
            ['2', '2.00', '111', '222', 't', 'Black', '2', '55.5', '2'],
            ['2', '3.00', '111', '111', 'f', 'Blue', '3', '44.4', '1'],
            ['2', '3.00', '111', '222', 'f', 'Blue', '3', '55.5', '2'],
            ['2', '4.00', '111', '111', 'f', 'Silver', '4', '44.4', '1'],
            ['2', '4.00', '111', '222', 'f', 'Silver', '4', '55.5', '2'],
            ['2', '5.00', '111', '111', 't', 'White', '5', '44.4', '1'],
            ['2', '5.00', '111', '222', 't', 'White', '5', '55.5', '2'],
            ['2', '6.00', '111', '111', 't', 'Yellow', '6', '44.4', '1'],
            ['2', '6.00', '111', '222', 't', 'Yellow', '6', '55.5', '2'],
            [
                '2', '7.00', '111', '111', 't', 'Custom color 1', '7', '44.4',
                '1'
            ],
            [
                '2', '7.00', '111', '222', 't', 'Custom color 1', '7', '55.5',
                '2'
            ],
            ['2', '11.11', '111', '111', 't', 'New Color', '8', '44.4', '1'],
            ['2', '11.11', '111', '222', 't', 'New Color', '8', '55.5', '2'],
            [
                '3', '40.00', '222', '4', 't', 'One size (plus)', '1',
                'Material 1', '1'
            ],
            [
                '3', '50.00', '222', '5', 'f', 'One size (plus)', '1',
                'Material 2', '2'
            ],
            [
                '3', '70.00', '222', '7', 't', 'Custom size 1', '2',
                'Material 1', '1'
            ],
            [
                '3', '80.00', '222', '8', 't', 'Custom size 1', '2',
                'Material 2', '2'
            ]
        ]

        expected_variation_properties = [
            ['1', 't', '200', 'Color (primary)', '', 'f', 'f', 'f'],
            ['1', 'f', '52047899002', 'Color (secondary)', '', 't', 'f', 'f'],
            ['2', 't', '200', 'Primary color', '', 't', 'f', 'f'],
            ['2', 'f', '501', 'Dimensions', '344', 'f', 't', 'f'],
            ['3', 't', '52047899294', 'Size', '25', 't', 't', 'f'],
            ['3', 'f', '507', 'Material', '', 't', 't', 'f']
        ]

        expected_variation_options = [
            ['1', 't', '1213', 'Beige', '1'], ['1', 't', '1', 'Black', '2'],
            ['1', 't', '2', 'Blue',
             '3'], ['1', 't', '1216', 'Bronze', '4'],
            ['1', 't', '3', 'Brown', '5'], ['1', 't', '1219', 'Clear', '6'],
            ['1', 't', '1218', 'Copper', '7'], ['1', 't', '1214', 'Gold', '8'],
            ['1', 't', '5',
             'Gray', '9'], ['1', 't', '4', 'Green',
                            '10'], ['1', 't', '6', 'Orange', '11'],
            ['1', 't', '7', 'Pink', '12'], ['1', 't', '8', 'Purple', '13'],
            ['1', 't', '1220', 'Rainbow', '14'], ['1', 't', '9', 'Red', '15'],
            ['1', 't', '1217', 'Rose gold', '16'],
            ['1', 't', '1215', 'Silver',
             '17'], ['1', 't', '10', 'White', '18'],
            ['1', 't', '11',
             'Yellow', '19'], ['1', 'f', '2', 'Blue', '1'],
            ['1', 'f', '', 'Levande', '2'], ['2', 't', '1213', 'Beige', '1'],
            ['2', 't', '1', 'Black', '2'], ['2', 't', '2', 'Blue', '3'],
            ['2', 't', '1215', 'Silver', '4'], ['2', 't', '10', 'White', '5'],
            ['2', 't', '11', 'Yellow',
             '6'], ['2', 't', '105393734419', 'Custom color 1', '7'],
            ['2', 't', '', 'New Color', '8'], ['2', 'f', '', '44.4', '1'],
            ['2', 'f', '', '55.5', '2'],
            ['3', 't', '1795', 'One size (plus)', '1'],
            ['3', 't', '102314214578', 'Custom size 1', '2'],
            ['3', 'f', '5561256091', 'Material 1', '1'],
            ['3', 'f', '5561256101', 'Material 2', '2']
        ]

        from data.test_variations_inline_properties_changes_expected_data import expected_api_calls

        self.set_etsy_testcase('listings_push_inventory')

        bpiv = BulkPageInventoryVariations(self.driver, self.ts)

        # --- Add variations to 1st listing ---

        # Choose 1st and 2nd property and their options
        row1 = bpiv.listing_row('Product #1 without variations')
        bpiv.set_property(row1, 0, 'Color (primary)')
        bpiv.add_all_options(row1, 0)
        bpiv.set_property(row1, 1, 'Color (secondary)')
        bpiv.add_option(row1, 1, 'Blue')
        bpiv.add_custom_option(row1, 1, 'Levande')

        # Set individual prices on the second property
        bpiv.select_inventory_tab(row1, 'Price')
        click(bpiv.bulk_header_checkbox(row1, 1), delay=0.5)

        new_prices1 = ['33.33', '333.33']
        for i, price in enumerate(new_prices1):
            price_input = bpiv.bulk_individual_option_inputs(row1, 1)[i]
            price_input.clear()
            send_keys(price_input, price)

        # Set global Quantity
        bpiv.select_inventory_tab(row1, 'Quantity')
        global_input = bpiv.global_quantity_input(row1)
        global_input.clear()
        send_keys(global_input, '33')

        # --- Change variations on 2nd listing - add property, replace options ---

        # Modify options on the first property
        row2 = bpiv.listing_row('Product #2 with one variation with pricing')
        bpiv.delete_option(row2, 0, option_index=7)
        bpiv.add_custom_option(row2, 0, 'New Color')

        # Choose second property
        bpiv.set_property(row2, 1, 'Dimensions', 'Inches')
        bpiv.add_custom_option(row2, 1, '44.4')
        bpiv.add_custom_option(row2, 1, '55.5')

        # Set price for new option on the first property
        bpiv.select_inventory_tab(row2, 'Price')
        price_input = bpiv.bulk_individual_option_inputs(row2, 0)[7]
        send_keys(price_input, '11.11')

        # Set individual quantities on the second property
        bpiv.select_inventory_tab(row2, 'Quantity')
        click(bpiv.bulk_header_checkbox(row2, 1), delay=0.5)

        new_quantities2 = ['111', '222']
        for i, price in enumerate(new_quantities2):
            quantity_input = bpiv.bulk_individual_option_inputs(row2, 1)[i]
            quantity_input.clear()
            send_keys(quantity_input, price)

        # --- Change variations on 3rd listing - delete options ---

        # Delete one option from each property
        row3 = bpiv.listing_row(
            'Product #3 with two variations with quantity on both and pricing on both'
        )
        bpiv.delete_option(row3, 0, option_index=0)
        bpiv.delete_option(row3, 1, option_index=2)

        bpiv.end_inline_edit()

        # --- Check selection of listings, sync button/dot and sync updates ---

        # Check that edited listings are unchecked
        check_listings_checked(bpiv, [False, False, False])

        # Check that sync is ready and sync
        check_sync_button_and_dot(bpiv, expected_sync_ready=True)
        click(bpiv.sync_updates_button())
        check_sync_button_and_dot(bpiv, expected_sync_ready=False)

        # --- Check state of data in DB and requests to Etsy emulator
        check_db_state(expected_product_offerings,
                       expected_variation_properties,
                       expected_variation_options)
        check_etsy_emulator_requests(expected_api_calls)
예제 #8
0
    def test_variations_inline_quantity_change(self):
        """ Tests quantity changes on two listings including where the quantity is set using variations inline edit
        """

        new_quantities2 = ['1', '2', '0']
        new_quantities3 = ['100', '200', '0']

        expected_product_offerings = [
            ['1', '500.00', '550', '50', 't', '', '', '', ''],
            ['2', '1.00', '111', '1', 't', 'Beige', '1', '', ''],
            ['2', '2.00', '111', '2', 't', 'Black', '2', '', ''],
            ['2', '3.00', '111', '0', 'f', 'Blue', '3', '', ''],
            ['2', '4.00', '111', '11', 'f', 'Silver', '4', '', ''],
            ['2', '5.00', '111', '11', 't', 'White', '5', '', ''],
            ['2', '6.00', '111', '11', 't', 'Yellow', '6', '', ''],
            ['2', '7.00', '111', '11', 't', 'Custom color 1', '7', '', ''],
            ['2', '8.00', '111', '11', 't', 'Custom color 2', '8', '', ''],
            ['3', '10.00', '222', '100', 't', 'XXS', '1', 'Material 1', '1'],
            ['3', '10.00', '222', '200', 't', 'XXS', '1', 'Material 2', '2'],
            ['3', '10.00', '222', '0', 't', 'XXS', '1', 'Material 3', '3'],
            [
                '3', '10.00', '222', '100', 't', 'One size (plus)', '2',
                'Material 1', '1'
            ],
            [
                '3', '10.00', '222', '200', 'f', 'One size (plus)', '2',
                'Material 2', '2'
            ],
            [
                '3', '10.00', '222', '0', 't', 'One size (plus)', '2',
                'Material 3', '3'
            ],
            [
                '3', '10.00', '222', '100', 't', 'Custom size 1', '3',
                'Material 1', '1'
            ],
            [
                '3', '10.00', '222', '200', 't', 'Custom size 1', '3',
                'Material 2', '2'
            ],
            [
                '3', '10.00', '222', '0', 't', 'Custom size 1', '3',
                'Material 3', '3'
            ]
        ]

        expected_variation_properties = [[
            '2', 't', '200', 'Primary color', '', 't', 't', 'f'
        ], ['3', 't', '52047899294', 'Size', '25', 'f', 'f',
            'f'], ['3', 'f', '507', 'Material', '', 'f', 't', 'f']]

        from data.test_variations_inline_quantity_change_expected_data import expected_api_calls

        self.set_etsy_testcase('listings_push_inventory')

        bpiv = BulkPageInventoryVariations(self.driver, self.ts)

        # --- Change a few individual quantities in 2nd listing ---
        row2 = bpiv.listing_row('Product #2 with one variation with pricing')

        bpiv.select_inventory_tab(row2, 'Quantity')
        # Switch to individual quantity on the first property
        click(bpiv.bulk_header_checkbox(row2, 0), delay=0.5)

        # Change a few quantities, remaining are inherited from original global value
        for i, quantity in enumerate(new_quantities2):
            qty_input = bpiv.bulk_individual_option_inputs(row2, 0)[i]
            qty_input.clear()
            send_keys(qty_input, quantity)

        # --- Change quantity to individual and set values in 3rd listing ---

        row3 = bpiv.listing_row(
            'Product #3 with two variations with quantity on both and pricing on both'
        )
        # First switch price to global
        bpiv.select_inventory_tab(row3, 'Price')
        click(bpiv.bulk_header_checkbox(row3, 0), delay=0.5)

        bpiv.select_inventory_tab(row3, 'Quantity')
        # Switch to quantity on the second property
        click(bpiv.bulk_header_checkbox(row3, 0), delay=0.5)

        # Set quantities
        for i, quantity in enumerate(new_quantities3):
            qty_input = bpiv.bulk_individual_option_inputs(row3, 1)[i]
            send_keys(qty_input, quantity)

        bpiv.end_inline_edit()

        # --- Check selection of listings, sync button/dot and sync updates ---

        # Check that edited listings are unchecked
        check_listings_checked(bpiv, [True, False, False])

        # Check that sync is ready and sync
        check_sync_button_and_dot(bpiv, expected_sync_ready=True)
        click(bpiv.sync_updates_button())
        check_sync_button_and_dot(bpiv, expected_sync_ready=False)

        # --- Check state of data in DB and requests to Etsy emulator
        check_db_state(expected_product_offerings,
                       expected_variation_properties,
                       DB_INITIAL_VARIATION_OPTIONS)
        check_etsy_emulator_requests(expected_api_calls)
예제 #9
0
    def test_inventory_increase_quantity(self):
        """ Tests that a quantity can be increased in bulk edit
        Also test the results in DB and check requests made to Etsy emulator.
        """

        self.set_etsy_testcase('listings_push_inventory')

        expected_listings_02 = {
            'Product #1 without variations': '60',
            'Product #2 with one variation with pricing': '21',
            'Product #3 with two variations with quantity on both and pricing on both': [

                ('XXS US Women\'s', 'Material 1', '11'),
                ('XXS US Women\'s', 'Material 2', '12'),
                ('XXS US Women\'s', 'Material 3', '13'),
                ('One size (plus) US Women\'s', 'Material 1', '14'),
                ('One size (plus) US Women\'s', 'Material 2', '15'),
                ('One size (plus) US Women\'s', 'Material 3', '16'),
                ('Custom size 1 US Women\'s', 'Material 1', '17'),
                ('Custom size 1 US Women\'s', 'Material 2', '18'),
                ('Custom size 1 US Women\'s', 'Material 3', '19'),
            ]
        }

        expected_product_offerings = [
            ['1', '500.00', '550', '60', 't', '', '', '', ''],
            ['2', '1.00', '111', '21', 't', 'Beige', '1', '', ''],
            ['2', '2.00', '111', '21', 't', 'Black', '2', '', ''],
            ['2', '3.00', '111', '21', 'f', 'Blue', '3', '', ''],
            ['2', '4.00', '111', '21', 'f', 'Silver', '4', '', ''],
            ['2', '5.00', '111', '21', 't', 'White', '5', '', ''],
            ['2', '6.00', '111', '21', 't', 'Yellow', '6', '', ''],
            ['2', '7.00', '111', '21', 't', 'Custom color 1', '7', '', ''],
            ['2', '8.00', '111', '21', 't', 'Custom color 2', '8', '', ''],
            ['3', '10.00', '222', '11', 't', 'XXS', '1', 'Material 1', '1'],
            ['3', '20.00', '222', '12', 't', 'XXS', '1', 'Material 2', '2'],
            ['3', '30.00', '222', '13', 't', 'XXS', '1', 'Material 3', '3'],
            ['3', '40.00', '222', '14', 't', 'One size (plus)', '2', 'Material 1', '1'],
            ['3', '50.00', '222', '15', 'f', 'One size (plus)', '2', 'Material 2', '2'],
            ['3', '60.00', '222', '16', 't', 'One size (plus)', '2', 'Material 3', '3'],
            ['3', '70.00', '222', '17', 't', 'Custom size 1', '3', 'Material 1', '1'],
            ['3', '80.00', '222', '18', 't', 'Custom size 1', '3', 'Material 2', '2'],
            ['3', '90.00', '222', '19', 't', 'Custom size 1', '3', 'Material 3', '3']
        ]

        from data.test_inventory_increase_quantity_expected_data import expected_api_calls

        operation = 'Increase By'

        biq = BulkPageInventoryQuantity(self.driver, self.ts)

        actual_listings = biq.listing_details()
        self.check_listing_options(actual_listings, expected_listings_01)

        # select operation and enter price difference
        biq.select_operation(operation)
        input_field = biq.quantity_input()
        send_keys(input_field, '10')

        # Apply changes
        assert biq.operation_apply().is_enabled() is True, 'Apply button is not enabled'
        click(biq.operation_apply())

        # Check listings that changes were applied
        actual_listings = biq.listing_details()
        self.check_listing_options(actual_listings, expected_listings_02)
        assert biq.operation_apply().is_enabled() is False, 'Apply button is enabled'

        # Check that sync button is enabled and blue dot is displayed after clicking on Apply
        wait_for_web_assert(True, biq.sync_updates_button().is_enabled,
                            'Sync button is not enabled')
        assert biq.is_part_modified('Quantity') is True, 'Blue dot didn\'t show up'

        # Sync changes
        click(biq.sync_updates_button())

        # Check that sync button is disabled and blue dot is not displayed after clicking on Sync
        wait_for_web_assert(False, biq.sync_updates_button().is_enabled,
                            'Sync button is not disabled')
        assert biq.is_part_modified('Quantity') is False, 'Blue dot is still shown'

        # --- Check state of data in DB and requests to Etsy emulator
        check_db_state(expected_product_offerings, DB_INITIAL_VARIATION_PROPERTIES, DB_INITIAL_VARIATION_OPTIONS)
        check_etsy_emulator_requests(expected_api_calls)
예제 #10
0
    def test_wholesale_bulk_change_inventory(self):
        """ Test verifies bulk changes of inventory of listings that have different value of the flag
            'can_write_inventory' - Etsy returns false for this flag when a listing is not Retail listing. So far it is
            not possible to update inventory and attributes on such listings through API, therefore VELA doesn't allow
            to change it.
            Test also verifies that if 'can_write_inventory' is changed to false on Etsy, no inventory updates of the
            listing are sent to Etsy (HIVE-1553).
        """

        api_products_unpacked1 = [{
            'offerings': [{
                'is_enabled': 1,
                'price': 33.33,
                'quantity': 21
            }],
            'property_values': [{
                'property_id': 500,
                'property_name': 'Finish',
                'scale_id': None,
                'value': 'smooth',
                'value_id': None
            }],
            'sku':
            'NEW SKU'
        }]

        expected_api_calls = [{
            'PUT':
            '/v2/listings/100001/inventory?price_on_property=&quantity_on_property=&sku_on_property=',
            'body': {
                '_products_unpacked': api_products_unpacked1,
                'listing_id': 100001
            }
        }]

        expected_can_write_inventory = [
            ('100001', True),
            ('100002', False),
            ('100003', False),
        ]

        bp = BulkPage(self.driver)

        # ---- Make changes in Variations editor ----

        click(bp.edit_part('Variations'))

        category = ['Accessories']
        bpiv = BulkPageInventoryVariations(self.driver, self.ts)

        # Select category in bulk edit area
        bpiv.select_category(category)

        # Set first variation property and its option
        bulk_row = bpiv.bulk_edit_row
        bpiv.set_property(bulk_row, 0, 'Finish')
        bpiv.add_custom_option(bulk_row, 0, 'smooth')

        # Apply changes and check results in UI
        click(bpiv.operation_apply())
        assert 'smooth' in bpiv.listing_row('One').text
        assert bpiv.listing_row(
            'Two').text == 'Two\n' + CANNOT_EDIT_INVENTORY_TEXT
        assert 'smooth' in bpiv.listing_row('Three').text
        wait_for_web_assert(True, lambda: bpiv.is_part_modified('Variations'),
                            'Blue dot didn\'t show up for Variations editor')

        # ---- Make changes in Price, Quantity, SKU editors ----

        retail_values = {'Price': '33.33', 'Quantity': '21', 'SKU': 'NEW SKU'}

        retail_expected_values = {
            'Price': '$33.33',
            'Quantity': '21',
            'SKU': 'NEW SKU'
        }

        for editor_name in ['Price', 'Quantity', 'SKU']:
            # Switch to particular inventory editor, choose bulk operation and set the value for it
            click(bpiv.edit_part(editor_name))
            operation = 'Change To'
            bp.select_operation(operation)
            input_field = bp.operation_input()
            send_keys(input_field, retail_values[editor_name])

            # Apply changes and check results in UI
            click(bp.operation_apply())
            wait_for_web_assert(
                True, lambda: bp.is_part_modified(editor_name),
                'Blue dot didn\'t show up for %s editor' % editor_name)
            assert bp.listing_row(
                'One').text == 'One\n' + retail_expected_values[editor_name]
            assert bp.listing_row(
                'Two').text == 'Two\n' + CANNOT_EDIT_INVENTORY_TEXT
            assert bp.listing_row(
                'Three'
            ).text == 'Three\n' + retail_expected_values[editor_name]

        # Sync changes
        click(bp.sync_updates_button())

        # Check that sync button is disabled and blue dot is not displayed after clicking on Sync
        wait_for_web_assert(False,
                            bp.sync_updates_button().is_enabled,
                            'Sync button is not disabled')

        # Check API calls to Etsy emulator - only first listing should be updated
        check_etsy_emulator_requests(expected_api_calls)

        # Check can_write_inventory flags in DB - it was set to False on the listing 'Three'
        assert self.db.get_can_write_inventory(
        ) == expected_can_write_inventory
예제 #11
0
    def test_inventory_sku_delete_and_replace(self):

        self.set_etsy_testcase('listings_push_inventory')

        expected_listings_02 = [
            'Product #1 without variations\n0022550',
            'Product #2 with one variation with pricing\n0022111',
            'Product #3 with two variations with quantity on both and pricing on both\n0022222'
        ]

        expected_listings_03 = [
            'Product #1 without variations\n00550',
            'Product #2 with one variation with pricing\n00111',
            'Product #3 with two variations with quantity on both and pricing on both\n002'
        ]
        expected_listings_04 = [
            'Product #1 without variations\nLOLO55LO',
            'Product #2 with one variation with pricing\nLOLO111',
            'Product #3 with two variations with quantity on both and pricing on both\nLOLO2'
        ]

        # expected at the end of the test
        expected_product_offerings = [
            ['1', '500.00', 'LOLO55LO', '50', 't', '', '', '', ''],
            ['2', '1.00', 'LOLO111', '11', 't', 'Beige', '1', '', ''],
            ['2', '2.00', 'LOLO111', '11', 't', 'Black', '2', '', ''],
            ['2', '3.00', 'LOLO111', '11', 'f', 'Blue', '3', '', ''],
            ['2', '4.00', 'LOLO111', '11', 'f', 'Silver', '4', '', ''],
            ['2', '5.00', 'LOLO111', '11', 't', 'White', '5', '', ''],
            ['2', '6.00', 'LOLO111', '11', 't', 'Yellow', '6', '', ''],
            ['2', '7.00', 'LOLO111', '11', 't', 'Custom color 1', '7', '', ''],
            ['2', '8.00', 'LOLO111', '11', 't', 'Custom color 2', '8', '', ''],
            ['3', '10.00', 'LOLO2', '1', 't', 'XXS', '1', 'Material 1', '1'],
            ['3', '20.00', 'LOLO2', '2', 't', 'XXS', '1', 'Material 2', '2'],
            ['3', '30.00', 'LOLO2', '3', 't', 'XXS', '1', 'Material 3', '3'],
            ['3', '40.00', 'LOLO2', '4', 't', 'One size (plus)', '2', 'Material 1', '1'],
            ['3', '50.00', 'LOLO2', '5', 'f', 'One size (plus)', '2', 'Material 2', '2'],
            ['3', '60.00', 'LOLO2', '6', 't', 'One size (plus)', '2', 'Material 3', '3'],
            ['3', '70.00', 'LOLO2', '7', 't', 'Custom size 1', '3', 'Material 1', '1'],
            ['3', '80.00', 'LOLO2', '8', 't', 'Custom size 1', '3', 'Material 2', '2'],
            ['3', '90.00', 'LOLO2', '9', 't', 'Custom size 1', '3', 'Material 3', '3']
        ]

        from data.test_inventory_sku_delete_and_replace_expected_data import expected_api_calls

        operation = 'Delete'
        bis = BulkPageInventorySku(self.driver, self.ts)
        assert expected_listings_01 == bis.listing_rows_texts_sorted()

        # this is shortcut how to add 0022 before every listings sku. Controls of corrections are in another Test
        send_keys(bis.sku_input(), '0022')
        click(bis.operation_apply())
        assert expected_listings_02 == bis.listing_rows_texts_sorted()

        # work with new data
        bis.select_operation(operation)
        send_keys(bis.sku_input(), '22')

        # Apply changes
        click(bis.operation_apply())
        assert expected_listings_03 == bis.listing_rows_texts_sorted()

        assert bis.is_part_modified('SKU') is True, 'Blue dot should be visible yet'
        assert bis.sync_updates_button().is_enabled() is True, 'Sync button should be enabled'

        assert bis.operation_apply().is_enabled() is False, 'Apply button is enabled'

        operation = 'Find & Replace'
        bis.select_operation(operation)

        bis.find_n_replace('0', 'LO')

        # Apply changes
        click(bis.operation_apply())
        assert expected_listings_04 == bis.listing_rows_texts_sorted()

        assert bis.is_part_modified('SKU') is True, 'Blue dot should be visible yet'
        assert bis.sync_updates_button().is_enabled() is True, 'Sync button should be enabled'

        assert bis.operation_apply().is_enabled() is False, 'Apply button is enabled'

        # Sync changes
        click(bis.sync_updates_button())

        # Check that sync button is disabled and blue dot is not displayed after clicking on Sync
        wait_for_web_assert(False, bis.sync_updates_button().is_enabled,
                            'Sync button is not disabled')
        assert bis.is_part_modified('SKU') is False, 'Blue dot is still shown'

        # --- Check state of data in DB and requests to Etsy emulator
        check_db_state(expected_product_offerings, DB_INITIAL_VARIATION_PROPERTIES, DB_INITIAL_VARIATION_OPTIONS)
        check_etsy_emulator_requests(expected_api_calls)
예제 #12
0
    def test_inventory_decrease_price_percent(self):
        """ Tests that a price can be decreased by % in bulk edit
        Also test the results in DB and check requests made to Etsy emulator.
        """

        self.set_etsy_testcase('listings_push_inventory')

        expected_listings_02 = {
            'Product #1 without variations':
            '$250.00',
            'Product #2 with one variation with pricing':
            [('Beige', '$0.50'), ('Black', '$1.00'), ('Blue', '$1.50'),
             ('Silver', '$2.00'), ('White', '$2.50'), ('Yellow', '$3.00'),
             ('Custom color 1', '$3.50'), ('Custom color 2', '$4.00')],
            'Product #3 with two variations with quantity on both and pricing on both':
            [
                ('XXS US Women\'s', 'Material 1', '$5.00'),
                ('XXS US Women\'s', 'Material 2', '$10.00'),
                ('XXS US Women\'s', 'Material 3', '$15.00'),
                ('One size (plus) US Women\'s', 'Material 1', '$20.00'),
                ('One size (plus) US Women\'s', 'Material 2', '$25.00'),
                ('One size (plus) US Women\'s', 'Material 3', '$30.00'),
                ('Custom size 1 US Women\'s', 'Material 1', '$35.00'),
                ('Custom size 1 US Women\'s', 'Material 2', '$40.00'),
                ('Custom size 1 US Women\'s', 'Material 3', '$45.00'),
            ]
        }

        expected_product_offerings = [
            ['1', '250.00', '550', '50', 't', '', '', '', ''],
            ['2', '0.50', '111', '11', 't', 'Beige', '1', '', ''],
            ['2', '1.00', '111', '11', 't', 'Black', '2', '', ''],
            ['2', '1.50', '111', '11', 'f', 'Blue', '3', '', ''],
            ['2', '2.00', '111', '11', 'f', 'Silver', '4', '', ''],
            ['2', '2.50', '111', '11', 't', 'White', '5', '', ''],
            ['2', '3.00', '111', '11', 't', 'Yellow', '6', '', ''],
            ['2', '3.50', '111', '11', 't', 'Custom color 1', '7', '', ''],
            ['2', '4.00', '111', '11', 't', 'Custom color 2', '8', '', ''],
            ['3', '5.00', '222', '1', 't', 'XXS', '1', 'Material 1', '1'],
            ['3', '10.00', '222', '2', 't', 'XXS', '1', 'Material 2', '2'],
            ['3', '15.00', '222', '3', 't', 'XXS', '1', 'Material 3', '3'],
            [
                '3', '20.00', '222', '4', 't', 'One size (plus)', '2',
                'Material 1', '1'
            ],
            [
                '3', '25.00', '222', '5', 'f', 'One size (plus)', '2',
                'Material 2', '2'
            ],
            [
                '3', '30.00', '222', '6', 't', 'One size (plus)', '2',
                'Material 3', '3'
            ],
            [
                '3', '35.00', '222', '7', 't', 'Custom size 1', '3',
                'Material 1', '1'
            ],
            [
                '3', '40.00', '222', '8', 't', 'Custom size 1', '3',
                'Material 2', '2'
            ],
            [
                '3', '45.00', '222', '9', 't', 'Custom size 1', '3',
                'Material 3', '3'
            ]
        ]

        from data.test_inventory_price_decrease_percent_expected_data import expected_api_calls

        operation = 'Decrease By'

        bip = BulkPageInventoryPrice(self.driver, self.ts)

        actual_listings = bip.listing_details()
        self.check_listing_options(actual_listings, expected_listings_01)

        # use %
        bip.select_operation(operation)
        click(bip.operation_switch_percent())

        input_field = bip.operation_input_dolars()
        send_keys(input_field, '50')

        # Apply changes and check Apply button after that
        click(bip.operation_apply())
        actual_listings = bip.listing_details()
        self.check_listing_options(actual_listings, expected_listings_02)

        assert bip.operation_apply().is_enabled(
        ) is False, 'Apply button is enabled'

        # Check that sync button is enabled and blue dot is displayed after clicking on Apply
        wait_for_web_assert(True,
                            bip.sync_updates_button().is_enabled,
                            'Sync button is not enabled')
        assert bip.is_part_modified(
            'Price') is True, 'Blue dot didn\'t show up'

        # Sync changes
        click(bip.sync_updates_button())

        # Check that sync button is disabled and blue dot is not displayed after clicking on Sync
        wait_for_web_assert(False,
                            bip.sync_updates_button().is_enabled,
                            'Sync button is not disabled')
        assert bip.is_part_modified(
            'Price') is False, 'Blue dot is still shown'

        # --- Check state of data in DB and requests to Etsy emulator
        check_db_state(expected_product_offerings,
                       DB_INITIAL_VARIATION_PROPERTIES,
                       DB_INITIAL_VARIATION_OPTIONS)
        check_etsy_emulator_requests(expected_api_calls)