def testSeriesAsReplyofSinglePatchCrossSeriesAwarePatchwork(self):
        """ + initia_patch                     \
            +--+ reply_1                        | Before patchwork knew
               +--+ patch_v2                    | about series
                  +--+ reply_2                 /
                     +--+ cover letter (0/3)   \
                        +--> patch 1/3          | After patchwork knew
                        +--> patch 2/3          | about series
                        +--> patch 3/3         /
        """
        initial_series = TestSeries(1, has_cover_letter=False)
        mails = initial_series.create_mails()
        initial_patch = mails[0]
        self.setMessageId(initial_patch, 'initial_patch')

        reply_1 = initial_series.create_reply(initial_patch)
        mails.append(reply_1)
        self.setMessageId(reply_1, 'reply_1')

        patch_v2 = initial_series.create_patch(in_reply_to=reply_1,
                                               subject_prefix="PATCH v2")
        mails.append(patch_v2)

        reply_2 = initial_series.create_reply(patch_v2)
        mails.append(reply_2)
        self.setMessageId(reply_2, 'reply_2')

        initial_series.insert(mails)

        # deleting the Series objects so far simulates the transition to
        # a series-aware patchwork from a previous version not creating
        # Series objects.
        Series.objects.all().delete()

        series = TestSeries(3)
        series_mails = series.create_mails()
        self.setMessageId(series_mails[0], 'cover_letter')
        self.setParentMail(series_mails[0], reply_2)
        for mail in series_mails[1:]:
            self.setParentMail(mail,
                               series_mails[0],
                               references=(reply_2, series_mails[0]))
        series.insert(series_mails)

        series = Series.objects.all()
        self.assertEqual(len(series), 1)
        revisions = series[0].revisions()
        # FIXME: We don't treat a series sent as a reply as a single
        # entity. Something that will need fixing.
        self.assertEqual(len(revisions), 3)
Exemplo n.º 2
0
    def testSeriesAsReplyofSinglePatchCrossSeriesAwarePatchwork(self):
        """ + initia_patch                     \
            +--+ reply_1                        | Before patchwork knew
               +--+ patch_v2                    | about series
                  +--+ reply_2                 /
                     +--+ cover letter (0/3)   \
                        +--> patch 1/3          | After patchwork knew
                        +--> patch 2/3          | about series
                        +--> patch 3/3         /
        """
        initial_series = TestSeries(1, has_cover_letter=False)
        mails = initial_series.create_mails()
        initial_patch = mails[0]
        self.setMessageId(initial_patch, 'initial_patch')

        reply_1 = initial_series.create_reply(initial_patch)
        mails.append(reply_1)
        self.setMessageId(reply_1, 'reply_1')

        patch_v2 = initial_series.create_patch(in_reply_to=reply_1,
                                               subject_prefix="PATCH v2")
        mails.append(patch_v2)

        reply_2 = initial_series.create_reply(patch_v2)
        mails.append(reply_2)
        self.setMessageId(reply_2, 'reply_2')

        initial_series.insert(mails)

        # deleting the Series objects so far simulates the transition to
        # a series-aware patchwork from a previous version not creating
        # Series objects.
        Series.objects.all().delete()

        series = TestSeries(3)
        series_mails = series.create_mails()
        self.setMessageId(series_mails[0], 'cover_letter')
        self.setParentMail(series_mails[0], reply_2)
        for mail in series_mails[1:]:
            self.setParentMail(mail, series_mails[0],
                               references=(reply_2, series_mails[0]))
        series.insert(series_mails)

        series = Series.objects.all()
        self.assertEqual(len(series), 1)
        revisions = series[0].revisions()
        # FIXME: We don't treat a series sent as a reply as a single
        # entity. Something that will need fixing.
        self.assertEqual(len(revisions), 3)
    def testPartialReferences(self):
        """Tests using the db to get the full list of references, for emails
        that only have partial list of ancestors in their References header"""
        series = TestSeries(3)
        mails = series.create_mails()
        self.setMessageId(mails[1], 'patch_1_3_v1')
        self.setMessageId(mails[2], 'patch_2_3_v1')
        self.setMessageId(mails[3], 'patch_3_3_v1')
        # review of patch 2/3
        reply_1 = series.create_reply(mails[2])
        mails.append(reply_1)
        self.setMessageId(reply_1, 'reply_1')
        # reply to the review
        reply_2 = series.create_reply(reply_1)
        mails.append(reply_2)
        self.setMessageId(reply_2, 'reply_2')
        # let's add yet another reply
        reply_3 = series.create_reply(reply_2)
        mails.append(reply_3)
        self.setMessageId(reply_3, 'reply_3')
        # now a revised patch (v2), which won't have the whole reference chain
        patch_v2 = series.create_patch(2,
                                       in_reply_to=reply_3,
                                       subject_prefix="PATCH v2")
        mails.append(patch_v2)
        self.setMessageId(patch_v2, 'patch_2_3_v2')
        # for good measure, a reply to that new patch
        reply_4 = series.create_reply(patch_v2)
        mails.append(reply_4)
        self.setMessageId(reply_4, 'reply_4')

        series.insert(mails)

        # and now the v3 of that patch, we'll need to reconstruct the full
        # list of references
        patch_v3 = series.create_patch(2,
                                       in_reply_to=reply_4,
                                       subject_prefix="PATCH v3")
        self.setMessageId(patch_v3, 'patch_2_3_v3')
        self.assertEquals(build_references_list(patch_v3), [
            reply_4.get('Message-Id'),
            patch_v2.get('Message-Id'),
            reply_3.get('Message-Id'),
            reply_2.get('Message-Id'),
            reply_1.get('Message-Id'), mails[2].get('Message-Id'),
            mails[0].get('Message-Id')
        ])
Exemplo n.º 4
0
    def testPartialReferences(self):
        """Tests using the db to get the full list of references, for emails
        that only have partial list of ancestors in their References header"""
        series = TestSeries(3)
        mails = series.create_mails()
        self.setMessageId(mails[1], "patch_1_3_v1")
        self.setMessageId(mails[2], "patch_2_3_v1")
        self.setMessageId(mails[3], "patch_3_3_v1")
        # review of patch 2/3
        reply_1 = series.create_reply(mails[2])
        mails.append(reply_1)
        self.setMessageId(reply_1, "reply_1")
        # reply to the review
        reply_2 = series.create_reply(reply_1)
        mails.append(reply_2)
        self.setMessageId(reply_2, "reply_2")
        # let's add yet another reply
        reply_3 = series.create_reply(reply_2)
        mails.append(reply_3)
        self.setMessageId(reply_3, "reply_3")
        # now a revised patch (v2), which won't have the whole reference chain
        patch_v2 = series.create_patch(2, in_reply_to=reply_3, subject_prefix="PATCH v2")
        mails.append(patch_v2)
        self.setMessageId(patch_v2, "patch_2_3_v2")
        # for good measure, a reply to that new patch
        reply_4 = series.create_reply(patch_v2)
        mails.append(reply_4)
        self.setMessageId(reply_4, "reply_4")

        series.insert(mails)

        # and now the v3 of that patch, we'll need to reconstruct the full
        # list of references
        patch_v3 = series.create_patch(2, in_reply_to=reply_4, subject_prefix="PATCH v3")
        self.setMessageId(patch_v3, "patch_2_3_v3")
        self.assertEquals(
            build_references_list(patch_v3),
            [
                reply_4.get("Message-Id"),
                patch_v2.get("Message-Id"),
                reply_3.get("Message-Id"),
                reply_2.get("Message-Id"),
                reply_1.get("Message-Id"),
                mails[2].get("Message-Id"),
                mails[0].get("Message-Id"),
            ],
        )