def test_title_add_before_starting_chars(self): """ Tests that add before title starts with valid chars """ expected_listings_1 = [ '123First something 1234 (1)\n113 characters remaining', '123Second something 1235 (2)\n112 characters remaining', '123Third something LG-512a (3)\n110 characters remaining' ] expected_listings_2 = [ '@ First something 1234 (1)\nMust begin with alphanumerical character', '@ Second something 1235 (2)\nMust begin with alphanumerical character', '@ Third something LG-512a (3)\nMust begin with alphanumerical character' ] expected_listings_3 = [ 'á First something 1234 (1)\n114 characters remaining', 'á Second something 1235 (2)\n113 characters remaining', 'á Third something LG-512a (3)\n111 characters remaining' ] select_listings_to_edit(self.driver) d = self.driver bp = BulkPage(d) input_field = bp.operation_input() # Test 123 prefix - OK send_keys(input_field, '123') listings = bp.listing_rows_texts_sorted() error_msg = bp.error_baloon() assert error_msg == '' assert listings == expected_listings_1 # Test @ prefix - show error, temp title does not contain it send_keys(input_field, BACKSPACE_KEYS) send_keys(input_field, '@ ') sleep(2) listings = bp.listing_rows_texts_sorted() error_msg = bp.error_baloon() assert error_msg == 'Must begin with alphanumerical character' assert listings == expected_listings_2 # Test á prefix - no error, temp title contains it send_keys(input_field, BACKSPACE_KEYS) send_keys(input_field, 'á ') listings = bp.listing_rows_texts_sorted() error_msg = bp.error_baloon() assert error_msg == '' assert listings == expected_listings_3
def test_create_material_too_long(self): """ Tests that a material cannot be longer than 45 characters """ select_listings_to_edit(self.driver) d = self.driver bp = BulkPage(d) send_keys(bp.operation_input(), 'AAAAaBBBBbCCCCcDDDDdEEEEeFFFFfGGGGgHHHHhIIIIi') err = bp.error_baloon() assert err == "" send_keys(bp.operation_input(), 'J') err = bp.error_baloon() assert err == "Materials must be 45 characters or less."
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"
def test_create_tag_too_long(self): """ Tests that a tag cannot be longer than 20 characters """ select_listings_to_edit(self.driver) d = self.driver bp = BulkPage(d) send_keys(bp.operation_input(), 'AAAAABBBBBCCCCCDDDDDE') err = bp.error_baloon() assert err == "Maximum length of tag is 20"
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_title_add_before_restricted_chars(self): """ Tests add before with invalid chars - only one from each group, remaining chars are tested in unit tests """ allowed_char = 'A' restricted_char = '%' forbidden_char = '$' 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 == '' # Test double restricted char - Err send_keys( input_field, BACKSPACE_KEYS + 'A' + restricted_char + ' ' + restricted_char) error_msg = bp.error_baloon() assert error_msg == 'Characters % : & must be used at most once' # Test forbidden char - Err send_keys(input_field, BACKSPACE_KEYS + 'A' + forbidden_char) error_msg = bp.error_baloon() print("Testing " + forbidden_char, error_msg) assert 'allowed' in error_msg # Test allowed char - No error message send_keys(input_field, BACKSPACE_KEYS + 'A' + allowed_char) error_msg = bp.error_baloon() print("Testing " + allowed_char, error_msg) assert error_msg == ''
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."