Beispiel #1
0
    def test_resolve_guid_download_errors(self):
        testfile = TestFile.get_or_create(self.node, 'folder/path')
        testfile.name = 'asdf'
        testfile.materialized_path = '/folder/path'
        guid = testfile.get_guid(create=True)
        testfile.save()
        testfile.delete()
        res = self.app.get('/{}/download'.format(guid), expect_errors=True)
        assert res.status_code == 404

        pp = PreprintFactory(is_published=False)

        res = self.app.get(pp.url + 'download', expect_errors=True)
        assert res.status_code == 404

        pp.is_published = True
        pp.save()
        pp.is_public = False
        pp.save()

        non_contrib = AuthUserFactory()

        res = self.app.get(pp.url + 'download', auth=non_contrib.auth, expect_errors=True)
        assert res.status_code == 403

        pp.deleted = timezone.now()
        pp.save()

        res = self.app.get(pp.url + 'download', auth=non_contrib.auth, expect_errors=True)
        assert res.status_code == 410
    def test_resolve_guid_download_errors(self):
        testfile = TestFile.get_or_create(self.node, 'folder/path')
        testfile.name = 'asdf'
        testfile.materialized_path = '/folder/path'
        guid = testfile.get_guid(create=True)
        testfile.save()
        testfile.delete()
        res = self.app.get('/{}/download'.format(guid), expect_errors=True)
        assert res.status_code == 404

        pp = PreprintFactory(is_published=False)

        res = self.app.get(pp.url + 'download', expect_errors=True)
        assert res.status_code == 404

        pp.is_published = True
        pp.save()
        pp.is_public = False
        pp.save()

        non_contrib = AuthUserFactory()

        res = self.app.get(pp.url + 'download', auth=non_contrib.auth, expect_errors=True)
        assert res.status_code == 403

        pp.deleted = timezone.now()
        pp.save()

        res = self.app.get(pp.url + 'download', auth=non_contrib.auth, expect_errors=True)
        assert res.status_code == 410
Beispiel #3
0
def deleted_preprint(user):
    preprint = PreprintFactory(creator=user)
    preprint.deleted = timezone.now()
    preprint.save()
    return preprint
def deleted_preprint(user):
    preprint = PreprintFactory(creator=user)
    preprint.deleted = timezone.now()
    preprint.save()
    return preprint