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)
        eq_(revision.attachments.count(), 1)
Example #2
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(self.revision)
     return self.revision