def test_attachment_rename(self):
        revision = self.add_one()
        old_uid = revision.attachments.all()[0].get_uid
        revision = PackageRevision.objects.get(package=self.package,
                                               revision_number=1)
        response = self.client.post(revision.get_rename_attachment_url(),{
                    'new_filename': 'xxx',
                    'new_ext': 'txt',
                    'uid': old_uid})
        eq_(response.status_code, 200)
        response = simplejson.loads(response.content)
        assert response.has_key('uid')
        assert response['uid'] != old_uid

        revision = next_revision(revision)
        eq_(revision.attachments.count(), 1)
Beispiel #2
0
    def test_attachment_rename(self):
        revision = self.add_one()
        old_uid = revision.attachments.all()[0].get_uid
        revision = PackageRevision.objects.get(package=self.package, revision_number=1)
        response = self.client.post(
            revision.get_rename_attachment_url(), {"new_filename": "xxx", "new_ext": "txt", "uid": old_uid}
        )
        eq_(response.status_code, 200)
        content = simplejson.loads(response.content)
        assert content.has_key("uid")
        assert content["uid"] != old_uid

        revision = next_revision(revision)
        eq_(revision.attachments.count(), 1)

        # use a not allowed extension length
        old_rev_no = revision.package.revisions.count()
        old_uid = revision.attachments.all()[0].get_uid
        response = self.client.post(
            revision.get_rename_attachment_url(),
            {"new_filename": "xxx", "new_ext": "01234567890987654321", "uid": old_uid},
        )
        eq_(response.status_code, 403)
Beispiel #3
0
 def add_one(self, data="foo", filename="some.txt"):
     self.upload(self.get_upload_url(self.revision.revision_number), data, filename)
     self.revision = next_revision(self.revision)
     return self.revision