Exemple #1
0
    def test_create_tag_special_chars(self):
        """ Tests that a tag can be created in bulk edit with czech chars, but not special chars
        """
        expected_tags = [
            ['Tag01', 'žvýkačky'],
            ['Tag01', 'žvýkačky'],
            ['Tag01', 'žvýkačky'],
        ]

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

        send_keys(bp.operation_input(), 'žvýkačky')
        click(bp.operation_apply())

        apply_class = bp.operation_apply().get_attribute('class')
        assert 'inactive' in apply_class.split(' ')

        tag_names = bp.tag_names()
        assert tag_names == expected_tags

        send_keys(bp.operation_input(), 'me@site')
        err = bp.error_baloon()
        assert err == "Tag can only include spaces, letters, hyphens, and numbers"
Exemple #2
0
    def test_delete_tag(self):
        """ Tests that tags can be deleted in bulk
        """

        expected_tags = [
            [],
            [],
            [],
        ]

        select_listings_to_edit(self.driver, 'Delete')
        d = self.driver
        bp = BulkPage(d)

        tag_field = bp.operation_input()
        click(tag_field)
        send_keys(tag_field, 'Tag')
        send_keys(tag_field, '01')
        click(bp.operation_apply())

        apply_class = bp.operation_apply().get_attribute('class')
        assert 'inactive' in apply_class.split(' ')

        tag_names = bp.tag_names()
        assert tag_names == expected_tags
Exemple #3
0
    def test_sync_updates_title(self):
        """ Tests that data is written to the database when [Sync Updates] is clicked
            It also tests that data are correctly processed in more than one batch (see HIVE-1216).
        """

        # Configure Hive to process changes in batches of two listings
        # Env variable must be set before Hive is started
        os.environ['SYNC_UPDATES_BATCH_SIZE'] = '2'

        expected_data = [['1', 'hello First something 1234 (1)'],
                         ['2', 'hello Second something 1235 (2)'],
                         ['3', 'hello Third something LG-512a (3)']]

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

        input_field = bp.operation_input()
        send_keys(input_field, 'hello ')

        # click on Apply and check Apply button
        click(bp.operation_apply())
        wait_for_web_assert(False,
                            bp.operation_apply().is_enabled,
                            'Apply button is enabled')

        # Sync changes
        click(bp.sync_updates_button())

        # Check data in DB
        wait_for_assert(expected_data,
                        lambda: run_sql('HIVE', 'select_title_modified', True),
                        'Unexpected title data in DB')
Exemple #4
0
    def test_title_replace(self):
        """ Tests title replace - basic test
        """

        expected_listings_1 = [
            'Prvni something 1234 (1)\n116 characters remaining',
            'Second something 1235 (2)\n115 characters remaining',
            'Third something LG-512a (3)\n113 characters remaining'
        ]

        select_listings_to_edit(self.driver, 'Find & Replace')
        d = self.driver
        bp = BulkPage(d)

        input_find_field = bp.operation_input_find()
        input_replace_field = bp.operation_input_replace()

        # Normal Replace
        send_keys(input_find_field, 'First')
        send_keys(input_replace_field, 'Prvni')
        listings = bp.listing_rows_texts_sorted()
        assert listings == expected_listings_1

        # Apply (client only)
        click(bp.operation_apply())
        sleep(1)
        listings = bp.listing_rows_texts_sorted()
        assert listings == expected_listings_1

        apply_class = bp.operation_apply().get_attribute('class')
        assert 'inactive' in apply_class.split(' ')
Exemple #5
0
    def test_title_delete(self):
        """ Tests tile delete basic
        """

        expected_listings_1 = [
            'First something 1234 (1)\n122 characters remaining',
            'Second something 1235 (2)\n115 characters remaining',
            'Third something LG-512a (3)\n113 characters remaining'
        ]

        expected_listings_2 = [
            'Second something 1235 (2)\n115 characters remaining',
            'Third something LG-512a (3)\n113 characters remaining',
            'something 1234 (1)\n122 characters remaining'
        ]

        select_listings_to_edit(self.driver, 'Delete')
        d = self.driver
        bp = BulkPage(d)

        input_field = bp.operation_input()

        # Normal Delete
        send_keys(input_field, 'First ')
        listings = bp.listing_rows_texts_sorted()
        assert listings == expected_listings_1

        # Apply (client only)
        click(bp.operation_apply())
        sleep(1)
        listings = bp.listing_rows_texts_sorted()
        assert listings == expected_listings_2

        apply_class = bp.operation_apply().get_attribute('class')
        assert 'inactive' in apply_class.split(' ')
Exemple #6
0
    def test_sync_updates_tags(self):
        """ Tests that data is written to the database when [Sync Updates] is clicked
        """

        expected_data = [['1', '{Tag01,AAA,BBB,CCC}'],
                         ['2', '{Tag01,AAA,BBB,CCC}'],
                         ['3', '{Tag01,AAA,BBB,CCC}']]

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

        send_keys(bp.operation_input(), 'AAA,BBB   ,CCC')
        click(bp.operation_apply())

        # Check apply button
        assert bp.operation_apply().is_enabled(
        ) is False, 'Apply button is enabled'

        click(bp.sync_updates_button())

        # Check updated data in DB
        wait_for_assert(expected_data,
                        lambda: run_sql('HIVE', 'select_tags_modified', True),
                        'Unexpected tags data in DB')
Exemple #7
0
    def test_title_add_before_length(self):
        """ Tests add before where length limit is exceeded
        """

        long_text = 'Looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong'
        expected_listings_1 = [
            long_text + 'First something 1234 (1)\n2 characters remaining',
            long_text + 'Second something 1235 (2)\n1 character remaining',
            long_text + 'Third something LG-512a (3)\n1 character over limit'
        ]
        expected_listings_2 = [
            long_text + 'First something 1234 (1)\n2 characters remaining',
            long_text + 'Second something 1235 (2)\n1 character remaining',
            'Third something LG-512a (3)\n113 characters remaining'
        ]

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

        input_field = bp.operation_input()

        # Test long text
        send_keys(input_field, long_text)
        listings = bp.listing_rows_texts_sorted()
        assert listings == expected_listings_1

        # Apply (client only)
        click(bp.operation_apply())
        sleep(1)
        listings = bp.listing_rows_texts_sorted()
        assert listings == expected_listings_2

        apply_class = bp.operation_apply().get_attribute('class')
        assert 'inactive' in apply_class.split(' ')
    def test_create_category(self):
        """ Tests that a category can be created in bulk edit
        """
        expected_listings_01 = [
            'First something 1234 (1)\nClothing\nMen\'s Clothing\nSocks\nChoose Category',
            'Second something 1235 (2)\nClothing\nMen\'s Clothing\nSocks\nChoose Category',
            'Third something LG-512a (3)\nClothing\nMen\'s Clothing\nPants'
        ]

        expected_listings_02 = [
            'First something 1234 (1)\nAccessories\nCostume Accessories\nCostume Tails & Ears\nCostume Ears',
            'Second something 1235 (2)\nAccessories\nCostume Accessories\nCostume Tails & Ears\nCostume Ears',
            'Third something LG-512a (3)\nAccessories\nCostume Accessories\nCostume Tails & Ears\nCostume Ears'
        ]

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

        actual_listings = bp.listing_rows_texts_sorted()
        assert actual_listings == expected_listings_01

        bp.select_category(['Accessories', 'Costume Accessories', 'Costume Tails & Ears', 'Costume Ears'])


            # Apply changes
        click(bp.operation_apply())
        actual_listings = bp.listing_rows_texts_sorted()
        assert actual_listings == expected_listings_02

        apply_class = bp.operation_apply().get_attribute('class')
        assert 'inactive' in apply_class.split(' ')
Exemple #9
0
    def test_create_tag_multi_over(self):
        """ Tests that multiple tags can be created in bulk edit, but no more than 13
        """
        expected_tags_01 = [
            ['Tag01'],
            ['Tag01'],
            ['Tag01', 'AAA', 'BBB', 'CCC'],
        ]

        expected_tags_02 = [
            [
                'Tag01', '00', '01', '02', '03', '04', '05', '06', '07', '08',
                '09', '10', '11'
            ],
            [
                'Tag01', '00', '01', '02', '03', '04', '05', '06', '07', '08',
                '09', '10', '11'
            ],
            [
                'Tag01', 'AAA', 'BBB', 'CCC', '00', '01', '02', '03', '04',
                '05', '06', '07', '08'
            ],
        ]

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

        # deselect 2, 3
        bp.click_on_listings(
            ['Second something 1235 (2)', 'Third something LG-512a (3)'])

        # append AAA BBB CCC tags to the 1st listing
        send_keys(bp.operation_input(), 'AAA,BBB   ,CCC')
        click(bp.operation_apply())

        apply_class = bp.operation_apply().get_attribute('class')
        assert 'inactive' in apply_class.split(' ')

        tag_names = bp.tag_names()
        assert tag_names == expected_tags_01

        # select 2, 3 again
        bp.click_on_listings(
            ['Second something 1235 (2)', 'Third something LG-512a (3)'])
        send_keys(
            bp.operation_input(),
            '00, 01, 02, 03, 04, 05, 06, 07, 08, 09, 10, 11, 12, 13, 14, 15')
        click(bp.operation_apply())

        apply_class = bp.operation_apply().get_attribute('class')
        assert 'inactive' in apply_class.split(' ')

        tag_names = bp.tag_names()
        assert tag_names == expected_tags_02
    def test_create_material_multi_over(self):
        """ Tests that multiple materials can be created in bulk edit, but no more than 13
        """
        expected_materials_01 = [
            ['cotton'],
            ['cotton'],
            ['wool', 'AAA', 'BBB', 'CCC'],
        ]

        expected_materials_02 = [
            [
                'cotton', '00', '01', '02', '03', '04', '05', '06', '07', '08',
                '09', '10', '11'
            ],
            [
                'cotton', '00', '01', '02', '03', '04', '05', '06', '07', '08',
                '09', '10', '11'
            ],
            [
                'wool', 'AAA', 'BBB', 'CCC', '00', '01', '02', '03', '04',
                '05', '06', '07', '08'
            ],
        ]

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

        # deselect 2, 3
        bp.click_on_listings(
            ['Second something 1235 (2)', 'Third something LG-512a (3)'])

        # append AAA BBB CCC materials to the 1st listing
        send_keys(bp.operation_input(), 'AAA,BBB   ,CCC')
        click(bp.operation_apply())

        material_names = bp.material_names()
        assert material_names == expected_materials_01

        # append 00, 01, 02... to all listings
        bp.click_on_listings(
            ['Second something 1235 (2)', 'Third something LG-512a (3)'])
        send_keys(
            bp.operation_input(),
            '00, 01, 02, 03, 04, 05, 06, 07, 08, 09, 10, 11, 12, 13, 14, 15')
        click(bp.operation_apply())

        material_names = bp.material_names()
        assert material_names == expected_materials_02
    def test_description_find_replace(self):
        """ Tests that find and replace works
        special case '$'
        """
        expected_descriptions_1 = [
            'invisible shoes $10',
            'invisible shoes $10',
            'invisible shoes $10',
        ]
        expected_descriptions_2 = [
            'invisible shoes 10 Kč (not $)',
            'invisible shoes 10 Kč (not $)',
            'invisible shoes 10 Kč (not $)',
        ]

        operation = 'Find & Replace'

        select_listings_to_edit(self.driver, operation)
        d = self.driver
        bp = BulkPage(d)

        input_find_field = bp.operation_input_find_description()
        input_replace_field = bp.operation_input_replace_description()

        send_keys(input_find_field, 'gloves')
        send_keys(input_replace_field, 'shoes $10')
        click(bp.operation_apply())

        descriptions = bp.listing_descriptions()
        assert descriptions == expected_descriptions_1

        apply_class = bp.operation_apply().get_attribute('class')
        assert 'inactive' in apply_class.split(' ')

        # check '$' can be replaced
        bp.select_operation(operation)
        input_find_field = bp.operation_input_find_description()
        input_replace_field = bp.operation_input_replace_description()

        send_keys(input_find_field, '$10')
        send_keys(input_replace_field, '10 Kč (not $)')
        click(bp.operation_apply())

        descriptions = bp.listing_descriptions()
        assert descriptions == expected_descriptions_2

        apply_class = bp.operation_apply().get_attribute('class')
        assert 'inactive' in apply_class.split(' ')
Exemple #12
0
    def test_bulk_category_variations_validation(self):
        """ Test verifies that error message is shown when attempting to change Category to incompatible
        with existing Variation property / scale on the listing, and that Category is not changed for such listing
        """

        expected_categories = [
            ['Jewelry', 'Brooches'],
            ['Jewelry', 'Brooches'],
            ['Clothing', 'Women\'s Clothing', 'Dresses']
        ]

        category = ['Jewelry', 'Brooches']

        bp = BulkPage(self.driver)
        # change to incompatible category (3rd listing)
        bp.select_category(category)

        row = bp.listing_row('Product #3 with two variations with quantity on both and pricing on both')

        # check that error is shown
        assert bp.error_baloon_texts(row) ==\
            ['The selected category is not compatible with the variations of this listing'],\
            'Incorrect validation error message for listing #3'

        # Apply and check that category was set for 1st and 2nd listings, for 3rd it hasn't changed
        click(bp.operation_apply())
        for i, row in enumerate(bp.listing_rows()):
            category_names = bp.category_names(row)
            assert category_names == expected_categories[i]
Exemple #13
0
    def test_bulk_occasion_validation(self):
        """ Tests that occasion can't be set at all or changed on certain categories that don't permit it
        """

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

        expected_listings_02 = [
            'Four\nThe category of this listing does not support occasion',
            'One\nGrief & Mourning',
            'Three\nChoose Occasion\nOccasion cannot be changed due to category',
            'Two\nChoose Occasion\nOccasion cannot be changed due to category'
        ]

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

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

        actual_listings = bp.listing_rows_texts_sorted()
        assert actual_listings == expected_listings_01

        # Change occasion using bulk
        bp.select_occasion('Grief & Mourning')

        actual_listings = bp.listing_rows_texts_sorted()
        assert actual_listings == expected_listings_02

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

        # Check apply button
        wait_for_web_assert(False,
                            bp.operation_apply().is_enabled,
                            'Apply button is enabled')
Exemple #14
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
Exemple #15
0
    def test_title_add_before_restricted_chars_existing(self):
        """ Tests add before where restricted character already exists in the title
        """

        restricted_char = '%'
        expected_listings_1 = [
            'A%First something 1234 (1)\n114 characters remaining',
            'A%Second something 1235 (2)\n113 characters remaining',
            'A%Third something LG-512a (3)\n111 characters remaining'
        ]

        expected_listings_2 = [
            'A%A%First something 1234 (1)\nCharacters % : & must be used at most once',
            'A%A%Second something 1235 (2)\nCharacters % : & must be used at most once',
            'A%A%Third something LG-512a (3)\nCharacters % : & must be used at most once'
        ]

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

        input_field = bp.operation_input()

        # Test single restricted char - OK
        send_keys(input_field, BACKSPACE_KEYS + 'A' + restricted_char)
        error_msg = bp.error_baloon()
        assert error_msg == ''

        # Apply (client only)
        click(bp.operation_apply())
        sleep(1)
        listings = bp.listing_rows_texts_sorted()
        assert listings == expected_listings_1

        apply_class = bp.operation_apply().get_attribute('class')
        assert 'inactive' in apply_class.split(' ')

        # Test another restricted char - Err
        send_keys(input_field, BACKSPACE_KEYS + 'A' + restricted_char)
        error_msg = bp.error_baloon()
        listings = bp.listing_rows_texts_sorted()
        assert error_msg == ''
        assert listings == expected_listings_2  # Error per listing with double %
    def test_create_material(self):
        """ Tests that a material can be created in bulk edit
        """
        expected_materials = [
            ['cotton', 'AAA'],
            ['cotton', 'AAA'],
            ['wool', 'AAA'],
        ]

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

        send_keys(bp.operation_input(), 'AAA')
        click(bp.operation_apply())

        material_names = bp.material_names()
        assert material_names == expected_materials

        apply_class = bp.operation_apply().get_attribute('class')
        assert 'inactive' in apply_class.split(' ')
Exemple #17
0
    def test_create_tag_normal(self):
        """ Tests that a tag can be created in bulk edit
        """
        expected_tags = [
            ['Tag01', 'AAA'],
            ['Tag01', 'AAA'],
            ['Tag01', 'AAA'],
        ]

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

        send_keys(bp.operation_input(), 'AAA')
        click(bp.operation_apply())

        apply_class = bp.operation_apply().get_attribute('class')
        assert 'inactive' in apply_class.split(' ')

        tag_names = bp.tag_names()
        assert tag_names == expected_tags
    def test_description_delete(self):
        """ Tests that delete works
        """
        expected_descriptions = [
            'visible gloves',
            'visible gloves',
            'visible gloves',
        ]

        select_listings_to_edit(self.driver, 'Delete')
        d = self.driver
        bp = BulkPage(d)

        input_field = bp.operation_input_description()
        send_keys(input_field, 'in')
        click(bp.operation_apply())

        descriptions = bp.listing_descriptions()
        assert descriptions == expected_descriptions

        apply_class = bp.operation_apply().get_attribute('class')
        assert 'inactive' in apply_class.split(' ')
    def test_description_add_after(self):
        """ Tests that correct text can be added after
        """
        expected_descriptions = [
            'invisible gloves hello',
            'invisible gloves hello',
            'invisible gloves hello',
        ]

        select_listings_to_edit(self.driver, 'Add After')
        d = self.driver
        bp = BulkPage(d)

        input_field = bp.operation_input_description()
        send_keys(input_field, ' hello')
        click(bp.operation_apply())

        descriptions = bp.listing_descriptions()
        assert descriptions == expected_descriptions

        apply_class = bp.operation_apply().get_attribute('class')
        assert 'inactive' in apply_class.split(' ')
Exemple #20
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)
Exemple #21
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)
Exemple #22
0
    def test_title_delete_first_char(self):
        """ Tests title delete - first character must be alphanumeric
        """

        expected_listings_1 = [
            'First something 1234 (1)\nMust begin with alphanumerical character',
            'Second something 1235 (2)\n115 characters remaining',
            'Third something LG-512a (3)\n113 characters remaining'
        ]

        expected_listings_2 = [
            'First something 1234 (1)\n116 characters remaining',
            'Second something 1235 (2)\n115 characters remaining',
            'Third something LG-512a (3)\n113 characters remaining'
        ]

        select_listings_to_edit(self.driver, 'Delete')
        d = self.driver
        bp = BulkPage(d)

        input_field = bp.operation_input()

        # Normal Delete
        send_keys(input_field,
                  'First')  # title starts with a space now -> Error
        sleep(2)
        listings = bp.listing_rows_texts_sorted()
        assert listings == expected_listings_1

        # Apply (client only)
        click(bp.operation_apply())
        sleep(1)
        listings = bp.listing_rows_texts_sorted()
        assert listings == expected_listings_2

        apply_class = bp.operation_apply().get_attribute('class')
        assert 'inactive' in apply_class.split(' ')
Exemple #23
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)
    def test_create_material_multi_basic(self):
        """ Tests that multiple materials can be created in bulk edit
        """
        expected_materials = [
            ['cotton', 'AAA', 'BBB', 'CCC'],
            ['cotton', 'AAA', 'BBB', 'CCC'],
            ['wool', 'AAA', 'BBB', 'CCC'],
        ]

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

        send_keys(bp.operation_input(), 'AAA,BBB   ,CCC')
        click(bp.operation_apply())

        material_names = bp.material_names()
        assert material_names == expected_materials
    def test_delete_material(self):
        """ Tests that materials can be deleted in bulk
        """
        expected_materials = [
            [],
            ['cotton'],
            ['cotton'],
        ]

        select_listings_to_edit(self.driver, 'Delete')
        d = self.driver
        bp = BulkPage(d)

        send_keys(bp.operation_input(), 'wool')
        click(bp.operation_apply())

        material_names = bp.material_names()
        assert material_names == expected_materials
Exemple #26
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)
    def test_create_material_special_chars(self):
        """ Tests that a material can be created in bulk edit with czech chars, but not special chars
        """
        expected_materials = [
            ['cotton', 'žvýkačky'],
            ['cotton', 'žvýkačky'],
            ['wool', 'žvýkačky'],
        ]

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

        send_keys(bp.operation_input(), 'žvýkačky')
        click(bp.operation_apply())

        material_names = bp.material_names()
        assert material_names == expected_materials

        send_keys(bp.operation_input(), 'me@site')
        err = bp.error_baloon()
        assert err == "Materials can only include spaces, letters, and numbers."
Exemple #28
0
    def test_bulk_photo(self):
        """ Tests photos can be added, replaced, deleted
        """

        d = self.driver
        bp = BulkPage(d)

        # add bulk photos
        bp.select_photo(0, full_path('onion.jpg'))
        bp.select_photo(1, full_path('bunny.jpeg'))
        click(bp.operation_apply())

        apply_class = bp.operation_apply().get_attribute('class')
        assert 'inactive' in apply_class.split(' ')

        # add individual photos
        row = bp.listing_row('Second something 1235 (2)')
        photos = bp.row_photo_elements(row)
        bp.select_image(photos[2], full_path('jmeter.png'))
        bp.select_image(photos[3], full_path('ario.png'))

        # replace images
        bp.select_operation('Replace')
        bp.select_photo(3, full_path('mail.png'))
        click(bp.operation_apply())

        apply_class = bp.operation_apply().get_attribute('class')
        assert 'inactive' in apply_class.split(' ')

        # delete images
        bp.select_operation('Delete')
        photos = bp.bulk_photo_elements()
        click(photos[2])
        click(bp.operation_apply())

        apply_class = bp.operation_apply().get_attribute('class')
        assert 'inactive' in apply_class.split(' ')
Exemple #29
0
    def test_etsy_upload(self):
        """
        Verify that listings can be fetched from Etsy, changed in vela GUI and pushed back to Etsy
        """

        # debug
        # with open('tests-etsy/data.json') as f:
        #     data = json.load(f)
        # self.validate_listings(data, '20161124_184056')
        # return

        # Delete log files
        logs = Logs(os.environ['LOG_CLEAN_SCRIPT'],
                    os.environ['LOG_GREP_SCRIPT'])
        logs.empty()

        timestamp = strftime("%Y%m%d_%H%M%S")

        credentials = self.get_credentials()
        etsy = EtsyApiForATs(credentials)

        # Delete our section from Etsy
        log("Deleting section from Etsy")
        etsy.remove_at_section(AT_SECTION)

        # Delete and re-create listings on Etsy
        log("Removing AT listings from Etsy")
        etsy.remove_at_listings()
        log("Creating AT listings on Etsy")
        st_id = etsy.get_shipping_template_id()
        for i in range(3):
            title = "{}_{:02d}".format(AT_TITLE, i)
            etsy.create_listing(
                dict(self.NEW_LISTING,
                     title=title,
                     taxonomy_id=1,
                     shipping_template_id=st_id))

        listings = etsy.get_listings()
        for listing_id, title in ((l['listing_id'], l['title'])
                                  for l in listings
                                  if l['title'][:len(AT_TITLE)] == AT_TITLE):
            print(listing_id, title)

        # Clean up Vela DB, Load new shop
        log("Cleaning Vela DB")
        # Reset feature flags for features that are not in production yet
        self.db.reset_user_profile_flags(self.user_id, BETA_FEATURE_FLAGS)
        self.reload_shop()

        log("Making UI changes")
        self.go_to_bulk()
        bp = BulkPage(self.driver)

        # Edit title
        log("   title")
        bp.edit_part('Title').click()
        bp.select_operation('Add After')
        send_keys(bp.operation_input(), ' ' + timestamp)
        bp.operation_apply().click()

        # Edit description
        log("   description")
        bp.edit_part('Description').click()
        bp.select_operation('Add After')
        send_keys(bp.operation_input_description(), ' ' + timestamp)
        bp.operation_apply().click()

        # Edit category
        log("   category")
        bp.edit_part('Category').click()
        bp.select_category(AT_CATEGORIES)
        bp.operation_apply().click()

        # Edit photos
        log("   photos")
        bp.edit_part('Photos').click()
        with Photos(self.driver) as photos:
            for i, img in enumerate(AT_IMAGES):
                photos.select_photo(
                    i, os.path.join(photos.photo_dir, img['file']))
            bp.operation_apply().click()

        # Edit tags
        log("   tags")
        bp.edit_part('Tags').click()
        send_keys(bp.operation_input(), ', '.join(AT_TAGS))
        bp.operation_apply().click()

        # Edit materials
        log("   materials")
        bp.edit_part('Materials').click()
        send_keys(bp.operation_input(), ', '.join(AT_MATERIALS))
        bp.operation_apply().click()

        # Edit section
        log("   section")
        bp.edit_part('Section').click()
        bp.operation_select().click()
        sleep(2)
        send_keys(bp.operation_menu_new_item_input(), AT_SECTION + Keys.RETURN)
        bp.operation_apply().click()

        # Edit Occasion
        log("   occasion")
        bp.edit_part('Occasion').click()
        bp.select_occasion(AT_OCCASION)
        bp.operation_apply().click()

        # Edit Holiday
        log("   holiday")
        bp.edit_part('Holiday').click()
        bp.select_holiday(AT_HOLIDAY)
        bp.operation_apply().click()

        # Edit variations
        log("   variations")
        bp.edit_part('Variations').click()
        biv = BulkPageInventoryVariations(self.driver, self.ts)
        bp.select_category(AT_CATEGORIES)
        bulk_row = biv.bulk_edit_row
        biv.set_property(bulk_row, 0, AT_VAR_PROPERTY_NAME)
        for option_name in AT_VAR_OPTION_VALUES:
            biv.add_option(bulk_row, 0, option_name)
        bp.operation_apply().click()

        # Edit price
        log("   price")
        bp.edit_part('Price').click()
        bip = BulkPageInventoryPrice(self.driver, self.ts)
        bip.select_operation('Change To')
        input_field = bip.operation_input()
        send_keys(input_field, AT_PRICE)
        bp.operation_apply().click()

        # Edit quantity
        log("   quantity")
        bp.edit_part('Quantity').click()
        biq = BulkPageInventoryQuantity(self.driver, self.ts)
        biq.select_operation('Change To')
        input_field = biq.operation_input()
        send_keys(input_field, str(AT_QUANTITY))
        biq.operation_apply().click()

        # Edit Sku
        log("   sku")
        bp.edit_part('SKU').click()
        bis = BulkPageInventorySku(self.driver, self.ts)
        input_field = bis.operation_input()
        send_keys(input_field, AT_SKU)
        bis.operation_apply().click()

        # Sync Updates
        log("Syncing Updates")
        bp.sync_updates_button().click()
        sleep(10)
        self.wait_for_synced()

        # Get listings from Etsy
        data = etsy.get_at_listings_details()
        self.validate_listings(data, timestamp)

        # Check logs for errors
        logs.check_for_errors()
Exemple #30
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