def test_get_file_guids_for_live_folder_wo_guids(self): node = self.node_settings.owner folder = OsfStorageFolder(name='foofolder', target=node) folder.save() files = [] for i in range(1, 4): files.append(folder.append_file('foo.{}'.format(i))) all_guids = OsfStorageFileNode.get_file_guids( '/' + folder._id, provider='osfstorage', target=node) assert [] == all_guids
def test_get_file_guids_for_live_folder_wo_guids(self): node = self.node_settings.owner folder = OsfStorageFolder(name='foofolder', node=node) folder.save() files = [] for i in range(1, 4): files.append(folder.append_file('foo.{}'.format(i))) all_guids = OsfStorageFileNode.get_file_guids( '/' + folder._id, provider='osfstorage', node=node) assert [] == all_guids
def test_move_preprint_primary_file_within_preprint(self): user = UserFactory() preprint = PreprintFactory(creator=user) preprint.save() folder = OsfStorageFolder(name='foofolder', target=preprint) folder.save() to_move = preprint.files.all()[0] assert_true(to_move.is_preprint_primary) moved = to_move.move_under(folder, name='Tuna') assert preprint.primary_file == to_move assert to_move.parent == folder assert folder.target == preprint
def test_move_preprint_primary_file_within_preprint(self): user = UserFactory() preprint = PreprintFactory(creator=user) preprint.save() folder = OsfStorageFolder(name='foofolder', target=preprint) folder.save() to_move = preprint.files.all()[0] assert_true(to_move.is_preprint_primary) moved = to_move.move_under(folder, name='Tuna') assert preprint.primary_file == to_move assert to_move.parent == folder assert folder.target == preprint
def test_get_file_guids_for_live_folder(self): node = self.node_settings.owner folder = OsfStorageFolder(name='foofolder', node=node) folder.save() files = [] for i in range(1, 4): files.append(folder.append_file('foo.{}'.format(i))) files[-1].get_guid(create=True) guids = [file.get_guid()._id for file in files] assert len(guids) == len(files) all_guids = OsfStorageFileNode.get_file_guids( '/' + folder._id, provider='osfstorage', node=node) assert sorted(guids) == sorted(all_guids)
def test_get_file_guids_for_live_folder(self): node = self.node_settings.owner folder = OsfStorageFolder(name='foofolder', target=node) folder.save() files = [] for i in range(1, 4): files.append(folder.append_file('foo.{}'.format(i))) files[-1].get_guid(create=True) guids = [file.get_guid()._id for file in files] assert len(guids) == len(files) all_guids = OsfStorageFileNode.get_file_guids( '/' + folder._id, provider='osfstorage', target=node) assert sorted(guids) == sorted(all_guids)
def test_get_file_guids_for_trashed_folder_recursive_wo_guids(self): node = self.node_settings.owner folder = OsfStorageFolder(name='foofolder', target=node) folder.save() files = [] for i in range(1, 4): files.append(folder.append_file('foo.{}'.format(i))) subfolder = folder.append_folder('subfoo') for i in range(1, 4): files.append(subfolder.append_file('subfoo.{}'.format(i))) folder.delete() all_guids = OsfStorageFileNode.get_file_guids( '/' + folder._id, provider='osfstorage', target=node) assert [] == all_guids
def test_get_file_guids_for_trashed_folder_recursive_wo_guids(self): node = self.node_settings.owner folder = OsfStorageFolder(name='foofolder', node=node) folder.save() files = [] for i in range(1, 4): files.append(folder.append_file('foo.{}'.format(i))) subfolder = folder.append_folder('subfoo') for i in range(1, 4): files.append(subfolder.append_file('subfoo.{}'.format(i))) folder.delete() all_guids = OsfStorageFileNode.get_file_guids( '/' + folder._id, provider='osfstorage', node=node) assert [] == all_guids
def create_file_node(sender, instance, **kwargs): if instance.root_folder: return # Note: The "root" node will always be "named" empty string root_folder = OsfStorageFolder(name='', target=instance, is_root=True) root_folder.save()
def create_file_node(sender, instance, **kwargs): if instance.root_folder: return # Note: The "root" node will always be "named" empty string root_folder = OsfStorageFolder(name='', target=instance, is_root=True) root_folder.save()