예제 #1
0
    def test_inline_holiday_change(self):
        """ Tests setting/changing holiday on a listing using inline edit
        """

        self.custom_setup('listings_push_attributes')

        expected_listings = [
            'Four\nThe category of this listing does not support holiday',
            'One\nEaster', 'Three\nVeterans\' Day', 'Two\nFather\'s Day'
        ]

        expected_api_calls = [{
            'PUT': '/v2/listings/100001/attributes/46803063659?value_ids=37',
            'body': {}
        }, {
            'PUT': '/v2/listings/100002/attributes/46803063659?value_ids=38',
            'body': {}
        }, {
            'PUT': '/v2/listings/100003/attributes/46803063659?value_ids=49',
            'body': {}
        }]

        select_listings_to_edit(self.driver)
        bp = BulkPage(self.driver)

        # set holiday
        bp.select_single_holiday('One', 'Easter')
        # change holiday
        bp.select_single_holiday('Two', 'Father\'s Day')
        bp.select_single_holiday('Three', 'Veterans\' Day')

        # Check listings
        actual_listings = bp.listing_rows_texts_sorted()
        assert actual_listings == expected_listings

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

        # 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')
        assert bp.is_part_modified(
            'Holiday') is False, 'Blue dot is still shown'

        # Check holiday data in DB and Etsy requests
        check_etsy_emulator_requests(expected_api_calls)
예제 #2
0
    def test_bulk_holiday_delete(self):
        """ Tests deleting holiday from listings using bulk
        """

        self.custom_setup('listings_delete_holiday_bulk')

        expected_listings = [
            'Four\nThe category of this listing does not support holiday',
            'One\nChoose Holiday', 'Three\nChoose Holiday',
            'Two\nChoose Holiday'
        ]

        expected_holiday_db = []

        expected_api_calls = [{
            'DELETE': '/v2/listings/100002/attributes/46803063659',
            'body': {}
        }, {
            'DELETE': '/v2/listings/100003/attributes/46803063659',
            'body': {}
        }]

        # Delete holiday from listings using bulk
        select_listings_to_edit(self.driver, 'None')
        bp = BulkPage(self.driver)

        # Apply changes and check listings
        click(bp.operation_apply())
        actual_listings = bp.listing_rows_texts_sorted()
        assert actual_listings == expected_listings

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

        # 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')
        assert bp.is_part_modified(
            'Holiday') is False, 'Blue dot is still shown'

        # Check Etsy requests and holiday data in DB after resync
        check_etsy_emulator_requests(expected_api_calls)
        check_db_state(expected_holiday_db)
예제 #3
0
    def test_inline_occasion_change(self):
        """ Tests setting/changing of occasion on listings using inline edit
        """

        self.custom_setup('listings_push_attributes')

        expected_listings = [
            'Four\nThe category of this listing does not support occasion',
            'One\nEngagement', 'Three\nChoose Occasion', 'Two\nWedding'
        ]

        expected_api_calls = [{
            'PUT': '/v2/listings/100001/attributes/46803063641?value_ids=22',
            'body': {}
        }, {
            'PUT': '/v2/listings/100002/attributes/46803063641?value_ids=32',
            'body': {}
        }]

        select_listings_to_edit(self.driver)
        bp = BulkPage(self.driver)

        # Change occasion
        bp.select_single_occasion('One', 'Engagement')
        # Set occasion
        bp.select_single_occasion('Two', 'Wedding')

        # Check listings
        actual_listings = bp.listing_rows_texts_sorted()
        assert actual_listings == expected_listings

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

        # 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')
        assert bp.is_part_modified(
            'Occasion') is False, 'Blue dot is still shown'

        # Check occasion data in Etsy requests
        check_etsy_emulator_requests(expected_api_calls)
예제 #4
0
    def test_bulk_holiday_set(self):
        """ Tests setting/changing holiday using bulk on listings
        """

        self.custom_setup('listings_push_attributes')

        expected_listings = [
            'Four\nThe category of this listing does not support holiday',
            'One\nChristmas', 'Three\nChristmas', 'Two\nChristmas'
        ]

        expected_api_calls = [{
            'PUT': '/v2/listings/100001/attributes/46803063659?value_ids=35',
            'body': {}
        }, {
            'PUT': '/v2/listings/100002/attributes/46803063659?value_ids=35',
            'body': {}
        }, {
            'PUT': '/v2/listings/100003/attributes/46803063659?value_ids=35',
            'body': {}
        }]

        # Set/change holiday using bulk
        select_listings_to_edit(self.driver, 'Christmas')
        bp = BulkPage(self.driver)

        # Apply changes and check listings
        click(bp.operation_apply())
        actual_listings = bp.listing_rows_texts_sorted()
        assert actual_listings == expected_listings

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

        # 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')
        assert bp.is_part_modified(
            'Holiday') is False, 'Blue dot is still shown'

        # Check holiday data in DB and Etsy requests
        check_etsy_emulator_requests(expected_api_calls)
예제 #5
0
    def test_inline_occasion_delete(self):
        """ Tests deleting occasion from a listing using inline edit
        """

        self.custom_setup('listings_delete_occasion')

        expected_listings = [
            'Four\nThe category of this listing does not support occasion',
            'One\nChoose Occasion', 'Three\nChoose Occasion',
            'Two\nChoose Occasion'
        ]

        expected_occasion_db = []

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

        select_listings_to_edit(self.driver)
        bp = BulkPage(self.driver)

        # Delete occasion from listing
        bp.select_single_occasion('One', 'None')

        # Check listings
        actual_listings = bp.listing_rows_texts_sorted()
        assert actual_listings == expected_listings

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

        # 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')
        assert bp.is_part_modified(
            'Occasion') is False, 'Blue dot is still shown'

        # Check Etsy requests and occasion data in DB after resync
        check_etsy_emulator_requests(expected_api_calls)
        check_db_state(expected_occasion_db)
예제 #6
0
    def test_inline_add_photo_sync(self):
        """ Test adding a picture using inline edit and syncing it to Etsy
        """

        # the last API call doesn't show actual picture data, because we don't have multipart support in emulator
        expected_api_calls = [
            {
                'DELETE': '/v2/listings/100001/images/1224764834',
                'body': {}
            }, {
                'POST': '/v2/listings/100001/images',
                'body': {
                    'listing_id': '100001',
                    'listing_image_id': '1224764834',
                    'overwrite': '1',
                    'rank': '1'
                }
            }, {
                'POST': '/v2/listings/100001/images',
                'body': {
                    'listing_id': '100001',
                    'overwrite': '1',
                    'rank': '2'
                }
            }
        ]

        bp = BulkPage(self.driver)

        # Add a photo to a listing
        bp.select_single_photo('One', 1, full_path('onion.jpg'))

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

        # 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')
        assert bp.is_part_modified('Photos') is False, 'Blue dot is still shown'

        # Wait for shop to sync and check requests made to Etsy
        vela.wait_for_shop_to_sync(expected_status='up_to_date')
        check_etsy_emulator_requests(expected_api_calls)
예제 #7
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