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)
Beispiel #2
0
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
Beispiel #3
0
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
Beispiel #4
0
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
Beispiel #5
0
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
Beispiel #6
0
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
Beispiel #7
0
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
Beispiel #8
0
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