Esempio n. 1
0
    def test_migrates_guids(self):
        names = []
        for num in range(10):
            names.append('DEAR GOD! {} CARPNADOS'.format(num))
            guid = model.OsfStorageGuidFile(node=self.project, path=names[-1])
            guid.save()
            oldels.OsfStorageFileRecord.get_or_create(names[-1],
                                                      self.node_settings)

        assert len(model.OsfStorageGuidFile.find()) == 10

        migration.migrate_node_settings(self.node_settings, dry=False)
        migration.migrate_children(self.node_settings, dry=False)

        guids = model.OsfStorageGuidFile.find()
        paths = [
            x.path for x in model.OsfStorageFileNode.find(
                Q('kind', 'eq', 'file')
                & Q('node_settings', 'eq', self.node_settings))
        ]
        assert len(guids) == 10
        for guid in guids:
            paths.remove(guid._path)
        assert len(paths) == 0

        finishm.migrate()

        paths = [
            x.path for x in model.OsfStorageFileNode.find(
                Q('kind', 'eq', 'file')
                & Q('node_settings', 'eq', self.node_settings))
        ]
        assert len(guids) == 10
        for guid in guids:
            paths.remove(guid.path)
        assert len(paths) == 0

        finishm.unmigrate()

        old_paths = [x.path for x in self.node_settings.file_tree.children]
        paths = [
            x.path for x in model.OsfStorageFileNode.find(
                Q('kind', 'eq', 'file')
                & Q('node_settings', 'eq', self.node_settings))
        ]
        assert len(guids) == 10
        for guid in guids:
            old_paths.remove(guid.path)
            paths.remove(guid._path)
        assert len(paths) == 0
        assert len(old_paths) == 0
Esempio n. 2
0
    def test_migrate_logs(self):
        names = []
        for num in range(10):
            names.append('DEAR GOD! {} CARPNADOS'.format(num))
            x, _ = oldels.OsfStorageFileRecord.get_or_create(
                names[-1], self.node_settings)
            x.delete(None)
            self.project.logs.latest().params['path'] = x.path
            self.project.logs.latest().save()

            if num % 2 == 0:
                x.undelete(None)
                self.project.logs.latest().params['path'] = x.path
                self.project.logs.latest().save()

        migration.migrate_node_settings(self.node_settings, dry=False)
        migration.migrate_children(self.node_settings, dry=False)

        for log in self.project.logs:
            if log.action.startswith('osf_storage_file'):
                path = log.params['_path']
                node = self.node_settings.root_node.find_child_by_name(
                    path.strip('/'))
                assert node._id in log.params['_urls']['view']
                assert node._id in log.params['_urls']['download']

        finishm.migrate()

        for log in self.project.logs:
            if log.action.startswith('osf_storage_file'):
                log.reload()
                path = log.params['path']
                node = self.node_settings.root_node.find_child_by_name(
                    path.strip('/'))
                assert node._id in log.params['urls']['view']
                assert node._id in log.params['urls']['download']

        finishm.unmigrate()

        for log in self.project.logs:
            if log.action.startswith('osf_storage_file'):
                log.reload()
                path = log.params['path'].lstrip('/')
                node = oldels.OsfStorageFileRecord.find_by_path(
                    path, self.node_settings)
                assert quote(node.path) in log.params['urls']['view']
                assert quote(node.path) in log.params['urls']['download']
Esempio n. 3
0
    def test_migrate_logs(self):
        names = []
        for num in range(10):
            names.append('DEAR GOD! {} CARPNADOS'.format(num))
            x, _ = model.OsfStorageFileRecord.get_or_create(names[-1], self.node_settings)
            x.delete(None)
            self.project.logs[-1].params['path'] = x.path
            self.project.logs[-1].save()

            if num % 2 == 0:
                x.undelete(None)
                self.project.logs[-1].params['path'] = x.path
                self.project.logs[-1].save()

        migration.migrate_node_settings(self.node_settings, dry=False)
        migration.migrate_children(self.node_settings, dry=False)

        for log in self.project.logs:
            if log.action.startswith('osf_storage_file'):
                path = log.params['_path']
                node = self.node_settings.root_node.find_child_by_name(path.strip('/'))
                assert node._id in log.params['_urls']['view']
                assert node._id in log.params['_urls']['download']

        finishm.migrate()

        for log in self.project.logs:
            if log.action.startswith('osf_storage_file'):
                log.reload()
                path = log.params['path']
                node = self.node_settings.root_node.find_child_by_name(path.strip('/'))
                assert node._id in log.params['urls']['view']
                assert node._id in log.params['urls']['download']

        finishm.unmigrate()

        for log in self.project.logs:
            if log.action.startswith('osf_storage_file'):
                log.reload()
                path = log.params['path'].lstrip('/')
                node = model.OsfStorageFileRecord.find_by_path(path, self.node_settings)
                assert quote(node.path) in log.params['urls']['view']
                assert quote(node.path) in log.params['urls']['download']
Esempio n. 4
0
    def test_migrates_guids(self):
        names = []
        for num in range(10):
            names.append('DEAR GOD! {} CARPNADOS'.format(num))
            guid = model.OsfStorageGuidFile(node=self.project, path=names[-1])
            guid.save()
            model.OsfStorageFileRecord.get_or_create(names[-1], self.node_settings)

        assert len(model.OsfStorageGuidFile.find()) == 10

        migration.migrate_node_settings(self.node_settings, dry=False)
        migration.migrate_children(self.node_settings, dry=False)

        guids = model.OsfStorageGuidFile.find()
        paths = [x.path for x in model.OsfStorageFileNode.find(Q('kind', 'eq', 'file') & Q('node_settings', 'eq', self.node_settings))]
        assert len(guids) == 10
        for guid in guids:
            paths.remove(guid._path)
        assert len(paths) == 0

        finishm.migrate()

        paths = [x.path for x in model.OsfStorageFileNode.find(Q('kind', 'eq', 'file') & Q('node_settings', 'eq', self.node_settings))]
        assert len(guids) == 10
        for guid in guids:
            paths.remove(guid.path)
        assert len(paths) == 0

        finishm.unmigrate()

        old_paths = [x.path for x in self.node_settings.file_tree.children]
        paths = [x.path for x in model.OsfStorageFileNode.find(Q('kind', 'eq', 'file') & Q('node_settings', 'eq', self.node_settings))]
        assert len(guids) == 10
        for guid in guids:
            old_paths.remove(guid.path)
            paths.remove(guid._path)
        assert len(paths) == 0
        assert len(old_paths) == 0