def assert_copy_and_paste(self, operation, source_sheet, dest_sheet=None, dest_location=None, to_set='formula'): if dest_sheet is None: dest_sheet = source_sheet # he populates some cells using usercode (because the test runs faster) orig_usercode = self.get_usercode() self.prepend_usercode( dedent(''' for row in range(3, 6): for col in 'BC': worksheet[col, row].%s = '%%s%%d' %% (col, row) ''' % (to_set, ))) self.wait_for_cell_value(2, 3, 'B3') if to_set == 'formula': self.enter_usercode(orig_usercode) self.wait_for_spinner_to_stop() # he copies (or cuts) a region from one place operation((2, 3), (3, 5)) # If he's cutting, it disappears if operation == self.cut_range: self.wait_for_cell_value(2, 3, '') self.wait_for_cell_value(3, 3, '') self.wait_for_cell_value(2, 4, '') self.wait_for_cell_value(3, 4, '') self.wait_for_cell_value(2, 5, '') self.wait_for_cell_value(3, 5, '') # ...and pastes it elsewhere if dest_sheet != source_sheet: self.go_to_url(Url.sheet_page(self.get_my_username(), dest_sheet)) self.wait_for_grid_to_appear() self.paste_range(dest_location) # the destination is populated c, r = dest_location self.wait_for_cell_value(c, r, 'B3') self.wait_for_cell_value(1 + c, r, 'C3') self.wait_for_cell_value(c, 1 + r, 'B4') self.wait_for_cell_value(1 + c, 1 + r, 'C4') self.wait_for_cell_value(c, 2 + r, 'B5') self.wait_for_cell_value(1 + c, 2 + r, 'C5')
def assert_copy_and_paste(self, operation, source_sheet, dest_sheet=None, dest_location=None, to_set="formula"): if dest_sheet is None: dest_sheet = source_sheet # he populates some cells using usercode (because the test runs faster) orig_usercode = self.get_usercode() self.prepend_usercode( dedent( """ for row in range(3, 6): for col in 'BC': worksheet[col, row].%s = '%%s%%d' %% (col, row) """ % (to_set,) ) ) self.wait_for_cell_value(2, 3, "B3") if to_set == "formula": self.enter_usercode(orig_usercode) self.wait_for_spinner_to_stop() # he copies (or cuts) a region from one place operation((2, 3), (3, 5)) # If he's cutting, it disappears if operation == self.cut_range: self.wait_for_cell_value(2, 3, "") self.wait_for_cell_value(3, 3, "") self.wait_for_cell_value(2, 4, "") self.wait_for_cell_value(3, 4, "") self.wait_for_cell_value(2, 5, "") self.wait_for_cell_value(3, 5, "") # ...and pastes it elsewhere if dest_sheet != source_sheet: self.go_to_url(Url.sheet_page(self.get_my_username(), dest_sheet)) self.wait_for_grid_to_appear() self.paste_range(dest_location) # the destination is populated c, r = dest_location self.wait_for_cell_value(c, r, "B3") self.wait_for_cell_value(1 + c, r, "C3") self.wait_for_cell_value(c, 1 + r, "B4") self.wait_for_cell_value(1 + c, 1 + r, "C4") self.wait_for_cell_value(c, 2 + r, "B5") self.wait_for_cell_value(1 + c, 2 + r, "C5")
def test_copy_and_paste_to_new_sheet(self): # * Harold logs in to Dirigible and creates a new sheet dest_sheet = self.login_and_create_new_sheet() source_sheet = self.create_new_sheet() self.assert_copy_and_paste(self.copy_range, source_sheet, dest_sheet, dest_location=(3, 4)) # the cells in the original sheet are all still there self.go_to_url(Url.sheet_page(self.get_my_username(), source_sheet)) self.wait_for_grid_to_appear() self.wait_for_cell_value(2, 3, "B3") self.wait_for_cell_value(2, 4, "B4") self.wait_for_cell_value(2, 5, "B5") self.wait_for_cell_value(3, 3, "C3") self.wait_for_cell_value(3, 4, "C4") self.wait_for_cell_value(3, 5, "C5")
def test_access_sheet_with_incorrect_user_id(self): ## Create sheet as user 1, for the rest of the test harriet = self.get_my_usernames()[1] harold = self.get_my_username() sheet_id = self.login_and_create_new_sheet(username=harriet) self.logout() harolds_broken_sheet_url = Url.sheet_page(harold, sheet_id) # Before logging in, Harold tries to access one of Harriet's sheets # using the wrong direct URL, with his username but the correct sheet ID. # He gets a 404 self.assert_HTTP_error(harolds_broken_sheet_url, 404) # After logging in, Harold tries to access one of Harriet's sheets # using the wrong direct URL, with his username but the correct sheet ID. # He gets a 404. self.login(username=harold) self.assert_HTTP_error(harolds_broken_sheet_url, 404)
def test_copy_and_paste_to_new_sheet(self): # * Harold logs in to Dirigible and creates a new sheet dest_sheet = self.login_and_create_new_sheet() source_sheet = self.create_new_sheet() self.assert_copy_and_paste(self.copy_range, source_sheet, dest_sheet, dest_location=(3, 4)) # the cells in the original sheet are all still there self.go_to_url(Url.sheet_page(self.get_my_username(), source_sheet)) self.wait_for_grid_to_appear() self.wait_for_cell_value(2, 3, 'B3') self.wait_for_cell_value(2, 4, 'B4') self.wait_for_cell_value(2, 5, 'B5') self.wait_for_cell_value(3, 3, 'C3') self.wait_for_cell_value(3, 4, 'C4') self.wait_for_cell_value(3, 5, 'C5')