def _can_delete_file(self, filenum): """ Helper function, wraps `file_upload_api.can_delete_file()`. """ team_id = self.get_team_info().get('team_id') key = self._get_student_item_key(filenum) current_user_id = self.get_student_item_dict()['student_id'] return file_upload_api.can_delete_file(current_user_id, self.teams_enabled, key, team_id)
def test_cannot_delete_file_if_user_ids_do_not_match(shared_file_upload_fixture): assert api.can_delete_file( 'a-different-student-id', True, 'my-key', DEFAULT_TEAM_ID, shared_file=shared_file_upload_fixture(), ) is False
def test_can_delete_file_if_team_ids_match(shared_file_upload_fixture): assert api.can_delete_file( DEFAULT_OWNER_ID, True, 'my-key', DEFAULT_TEAM_ID, shared_file=shared_file_upload_fixture(), ) is True
def test_cannot_delete_file_if_team_ids_do_not_match(shared_file_upload_fixture): assert api.can_delete_file( DEFAULT_OWNER_ID, True, 'my-key', 'a-different-team-id', shared_file=shared_file_upload_fixture(), ) is False
def test_can_delete_file_if_key_not_found_in_shared_files(): assert api.can_delete_file(DEFAULT_OWNER_ID, True, 'any-key', DEFAULT_TEAM_ID) is True
def test_cannot_delete_file_if_file_shared_and_not_on_team(shared_file_upload_fixture): _ = shared_file_upload_fixture() assert api.can_delete_file(DEFAULT_OWNER_ID, True, 'my-key', None) is False
def test_can_delete_file_if_file_not_shared_and_not_on_team(): assert api.can_delete_file(DEFAULT_OWNER_ID, True, 'a-different-key', None) is True
def test_can_delete_file_if_teams_not_enabled(): assert api.can_delete_file(DEFAULT_OWNER_ID, False, 'any-key', DEFAULT_TEAM_ID) is True