def test_legacy_patch(self): """Validate a patch with non-existent dependencies raises a 404.""" # we're explicitly creating a patch without a series patch = create_patch(series=None) with self.assertRaises(Http404): utils.series_patch_to_mbox(patch, '*')
def test_patch_with_numeric_series(self): series, patch_a, patch_b = self._create_patches() mbox = utils.series_patch_to_mbox(patch_b, series.id) self.assertIn(patch_a.content, mbox) self.assertIn(patch_b.content, mbox)
def test_patch_with_wildcard_series(self): _, patch_a, patch_b = self._create_patches() mbox = utils.series_patch_to_mbox(patch_b, '*') self.assertIn(patch_a.content, mbox) self.assertIn(patch_b.content, mbox)
def patch_mbox(request, patch_id): patch = get_object_or_404(Patch, id=patch_id) series_id = request.GET.get('series') response = HttpResponse(content_type='text/plain') if series_id: response.write(series_patch_to_mbox(patch, series_id)) else: response.write(patch_to_mbox(patch)) response['Content-Disposition'] = 'attachment; filename=' + \ patch.filename.replace(';', '').replace('\n', '') return response
def patch_mbox(request, patch_id): patch = get_object_or_404(Patch, id=patch_id) series_id = request.GET.get('series') response = HttpResponse(content_type='text/plain') if series_id: response.write(series_patch_to_mbox(patch, series_id)) else: response.write(patch_to_mbox(patch)) response['Content-Disposition'] = 'attachment; filename=%s.patch' % ( patch.filename) return response
def patch_mbox(request, project_id, msgid): db_msgid = ('<%s>' % msgid) project = get_object_or_404(Project, linkname=project_id) patch = get_object_or_404(Patch, project_id=project.id, msgid=db_msgid) series_id = request.GET.get('series') response = HttpResponse(content_type='text/plain; charset=utf-8') if series_id: response.write(series_patch_to_mbox(patch, series_id)) else: response.write(patch_to_mbox(patch)) response['Content-Disposition'] = 'attachment; filename=%s.patch' % ( patch.filename) return response
def patch_mbox(request, patch_id): patch = get_object_or_404(Patch, id=patch_id) series_id = request.GET.get('series') response = HttpResponse(content_type='text/plain') if series_id: if not patch.series: raise Http404('Patch does not have an associated series. This is ' 'because the patch was processed with an older ' 'version of Patchwork. It is not possible to ' 'provide dependencies for this patch.') response.write(series_patch_to_mbox(patch, series_id)) else: response.write(patch_to_mbox(patch)) response['Content-Disposition'] = 'attachment; filename=%s.patch' % ( patch.filename) return response
def patch_mbox(request, patch_id): patch = get_object_or_404(Patch, id=patch_id) series_id = request.GET.get('series') response = HttpResponse(content_type='text/plain') if series_id: if not patch.series: raise Http404('Patch does not have an associated series. This is ' 'because the patch was processed with an older ' 'version of Patchwork. It is not possible to ' 'provide dependencies for this patch.') response.write(series_patch_to_mbox(patch, series_id)) else: response.write(patch_to_mbox(patch)) response['Content-Disposition'] = 'attachment; filename=%s.patch' % ( patch.filename) return response
def test_patch_with_invalid_series(self): series, patch_a, patch_b = self._create_patches() for value in ('foo', str(series.id + 1)): with self.assertRaises(Http404): utils.series_patch_to_mbox(patch_b, value)