def process_webhook(upload_pk, callbacks): log.info('Processing webhook for: {}'.format(upload_pk)) upload = FileUpload.objects.get(pk=upload_pk) github = GithubCallback(callbacks) res = github.get() upload.name = '{}-github-webhook.xpi'.format(upload.pk) upload.path = rezip_file(res, upload.pk) upload.save() log.info('Validating: {}'.format(upload_pk)) validate(upload, listed=True, subtask=process_results.si(upload_pk, callbacks))
def test_badzip(self): with self.settings(FILE_UNZIP_SIZE_LIMIT=5): with self.assertRaises(forms.ValidationError): rezip_file(self.response, 1)
def test_rezip(self): new_path = rezip_file(self.response, 1) with open(new_path, 'r') as new_file: new_zip = zipfile.ZipFile(new_file) self.assertSetEqual(set([f.filename for f in new_zip.filelist]), set(['manifest.json', 'index.js']))