Example #1
0
    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, '*')
Example #2
0
    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)
Example #3
0
    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)
Example #4
0
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
Example #5
0
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
Example #6
0
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
Example #7
0
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
Example #8
0
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
Example #9
0
    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)