Example #1
0
 def setUp(self):
     project = create_project(listid='test.example.com')
     self.orig_patch = read_patch(self.patch_filename)
     email = create_email(self.test_content + '\n' + self.orig_patch,
                          project=project)
     email['Message-Id'] = '<*****@*****.**>'
     parse_mail(email)
Example #2
0
 def testSettingOffGitSendEmail(self):
     """git_send_email_only is false (default value) and email has been sent
        with git send-email"""
     email = self.get_email()
     email['X-Mailer'] = 'git-send-email 1.8.3.1'
     parse_mail(email)
     self._assertNPatches(1)
Example #3
0
 def testStripTag(self):
     self.project2.subject_prefix_tags = 'i-g-t'
     self.project2.save()
     email = create_email(defaults.patch, project=self.project1,
                          subject='[PATCH i-g-t] Subject')
     parse_mail(email)
     patch = Patch.objects.all()[0]
     self.assertEquals(patch.name, 'Subject')
Example #4
0
 def testSettingOnNoGitSendEmail(self):
     """git_send_email_only is true and email has been not sent with
        git send-email"""
     self.p1.git_send_email_only = True
     self.p1.save()
     email = self.get_email()
     parse_mail(email)
     self._assertNPatches(0)
Example #5
0
    def testPartialRevision(self):
        series, mails = self._create_series(3)
        # insert cover letter and 2 patches
        for i in range(0, 3):
            parse_mail(mails[i])

        revision = SeriesRevision.objects.all()[0]
        self.assertEqual(revision.state, RevisionState.INCOMPLETE)
        self.check_revision_summary(revision, {'New': 2})
Example #6
0
 def testSettingOnGitSendEmail(self):
     """git_send_email_only is true and email has been sent with
        git send-email"""
     self.p1.git_send_email_only = True
     self.p1.save()
     email = self.get_email()
     email['X-Mailer'] = 'git-send-email 1.8.3.1'
     parse_mail(email)
     self._assertNPatches(1)
Example #7
0
    def test_invalid_state(self):
        # make sure it's actually invalid
        with self.assertRaises(State.DoesNotExist):
            State.objects.get(name=self.invalid_state_name)

        email = self._get_email()
        email['X-Patchwork-State'] = self.invalid_state_name
        parse_mail(email)
        self.assertState(self.default_state)
Example #8
0
 def setUp(self):
     project = defaults.project
     project.listid = 'test.example.com'
     project.save()
     self.orig_patch = read_patch(self.patch_filename)
     email = create_email(self.test_comment + '\n' + self.orig_patch,
                          project=project)
     email['Message-Id'] = '<*****@*****.**>'
     parse_mail(email)
Example #9
0
def parse_mbox(path, list_id):
    mbox = mailbox.mbox(path)
    duplicates = 0
    for msg in mbox:
        try:
            parsemail.parse_mail(msg, list_id)
        except django.db.utils.IntegrityError:
            duplicates += 1
    LOGGER.info('Processed %d messages, %d duplicates',
                len(mbox), duplicates)
Example #10
0
    def setUp(self):
        self.assertTrue(self.project is not None)
        self.project.save()

        # insert the mails. 'mails' is an optional field, for subclasses
        # that do have a list of on-disk emails.
        if hasattr(self, 'mails'):
            self.n_mails = len(self.mails)
            for filename in self.mails:
                mail = read_mail(os.path.join('series', filename))
                parse_mail(mail)
Example #11
0
    def setUp(self):
        super(MultipleProjectPatchCommentTest, self).setUp()

        for project in [self.p1, self.p2]:
            email = MIMEText(self.comment_content)
            email['From'] = 'Patch Author <*****@*****.**>'
            email['Subject'] = 'Test Subject'
            email['Message-Id'] = self.comment_msgid
            email['List-ID'] = '<' + project.listid + '>'
            email['In-Reply-To'] = self.msgid
            parse_mail(email)
Example #12
0
    def setUp(self):
        super(MultipleProjectPatchCommentTest, self).setUp()

        for project in [self.p1, self.p2]:
            email = MIMEText(self.comment_content)
            email["From"] = defaults.sender
            email["Subject"] = defaults.subject
            email["Message-Id"] = self.comment_msgid
            email["List-ID"] = "<" + project.listid + ">"
            email["In-Reply-To"] = self.msgid
            parse_mail(email)
Example #13
0
    def setUp(self):
        super(MultipleProjectPatchCommentTest, self).setUp()

        for project in [self.p1, self.p2]:
            email = MIMEText(self.comment_content)
            email['From'] = defaults.sender
            email['Subject'] = defaults.subject
            email['Message-Id'] = self.comment_msgid
            email['List-ID'] = '<' + project.listid + '>'
            email['In-Reply-To'] = self.msgid
            parse_mail(email)
Example #14
0
    def setUp(self):
        super(MultipleProjectPatchCommentTest, self).setUp()

        for project in [self.p1, self.p2]:
            email = MIMEText(self.comment_content)
            email['From'] = defaults.sender
            email['Subject'] = defaults.subject
            email['Message-Id'] = self.comment_msgid
            email['List-ID'] = '<' + project.listid + '>'
            email['In-Reply-To'] = self.msgid
            parse_mail(email)
Example #15
0
 def testSettingOnGitSendEmailNoXMailer(self):
     """git_send_email_only is true and email has been sent with
        git send-email --no-xmailer"""
     self.p1.git_send_email_only = True
     self.p1.save()
     email = self.get_email()
     del email['Message-Id']
     email['Message-Id'] = \
             '<*****@*****.**>'
     parse_mail(email)
     self._assertNPatches(1)
Example #16
0
    def setUp(self):
        self.assertTrue(self.project is not None)
        self.project.save()

        # insert the mails. 'mails' is an optional field, for subclasses
        # that do have a list of on-disk emails.
        if hasattr(self, 'mails'):
            self.n_mails = len(self.mails)
            for filename in self.mails:
                mail = read_mail(os.path.join('series', filename))
                parse_mail(mail)
Example #17
0
 def testSettingOnGitSendEmailNoXMailer(self):
     """git_send_email_only is true and email has been sent with
        git send-email --no-xmailer"""
     self.p1.git_send_email_only = True
     self.p1.save()
     email = self.get_email()
     del email['Message-Id']
     email['Message-Id'] = \
             '<*****@*****.**>'
     parse_mail(email)
     self._assertNPatches(1)
Example #18
0
def parse_mbox(path, list_id):
    results = {models.Patch: 0, models.CoverLetter: 0, models.Comment: 0}
    duplicates = 0
    dropped = 0

    mbox = mailbox.mbox(path)
    for msg in mbox:
        try:
            obj = parsemail.parse_mail(msg, list_id)
            if obj:
                results[type(obj)] += 1
            else:
                dropped += 1
        except django.db.utils.IntegrityError:
            duplicates += 1
    print(
        "Processed %(total)d messages -->\n"
        "  %(covers)4d cover letters\n"
        "  %(patches)4d patches\n"
        "  %(comments)4d comments\n"
        "  %(duplicates)4d duplicates\n"
        "  %(dropped)4d dropped\n"
        "Total: %(new)s new entries"
        % {
            "total": len(mbox),
            "covers": results[models.CoverLetter],
            "patches": results[models.Patch],
            "comments": results[models.Comment],
            "duplicates": duplicates,
            "dropped": dropped,
            "new": len(mbox) - duplicates - dropped,
        }
    )
Example #19
0
    def setUp(self):
        self.p1 = create_project()
        self.p2 = create_project()

        patch = read_patch(self.patch_filename)
        email = create_email(self.test_content + '\n' + patch)
        del email['Message-Id']
        email['Message-Id'] = self.msgid

        del email['List-ID']
        email['List-ID'] = '<' + self.p1.listid + '>'
        parse_mail(email)

        del email['List-ID']
        email['List-ID'] = '<' + self.p2.listid + '>'
        parse_mail(email)
Example #20
0
    def setUp(self):
        self.p1 = Project(linkname = 'test-project-1', name = 'Project 1',
                listid = '1.example.com', listemail='*****@*****.**')
        self.p2 = Project(linkname = 'test-project-2', name = 'Project 2',
                listid = '2.example.com', listemail='*****@*****.**')

        self.p1.save()
        self.p2.save()

        patch = read_patch(self.patch_filename)
        email = create_email(self.test_comment + '\n' + patch)
        email['Message-Id'] = self.msgid

        del email['List-ID']
        email['List-ID'] = '<' + self.p1.listid + '>'
        parse_mail(email)

        del email['List-ID']
        email['List-ID'] = '<' + self.p2.listid + '>'
        parse_mail(email)
Example #21
0
    def testGitPullRequest(self):
        self.assertEqual(parse_mail(self.mail), 0)
        self.patch = Patch.objects.filter(project=self.p1)[0]

        self.assertTrue(self.patch.pull_url is not None)

        events = EventLog.objects.filter(patch=self.patch)
        self.assertEqual(len(events), 1)

        el = events[0]
        self.assertEqual(Event.objects.get(name='pull-request-new'), el.event)
        self.assertEqual(self.patch.pull_url, el.parameters['pull_url'])
Example #22
0
    def setUp(self):
        self.p1 = Project(linkname='test-project-1', name='Project 1',
                          listid='1.example.com', listemail='*****@*****.**')
        self.p2 = Project(linkname='test-project-2', name='Project 2',
                          listid='2.example.com', listemail='*****@*****.**')

        self.p1.save()
        self.p2.save()

        patch = read_patch(self.patch_filename)
        email = create_email(self.test_comment + '\n' + patch)
        del email['Message-Id']
        email['Message-Id'] = self.msgid

        del email['List-ID']
        email['List-ID'] = '<' + self.p1.listid + '>'
        parse_mail(email)

        del email['List-ID']
        email['List-ID'] = '<' + self.p2.listid + '>'
        parse_mail(email)
Example #23
0
    def setUp(self):
        self.p1 = Project(
            linkname="test-project-1", name="Project 1", listid="1.example.com", listemail="*****@*****.**"
        )
        self.p2 = Project(
            linkname="test-project-2", name="Project 2", listid="2.example.com", listemail="*****@*****.**"
        )

        self.p1.save()
        self.p2.save()

        patch = read_patch(self.patch_filename)
        email = create_email(self.test_comment + "\n" + patch)
        email["Message-Id"] = self.msgid

        del email["List-ID"]
        email["List-ID"] = "<" + self.p1.listid + ">"
        parse_mail(email)

        del email["List-ID"]
        email["List-ID"] = "<" + self.p2.listid + ">"
        parse_mail(email)
Example #24
0
 def testSettingOffNoGitSendEmail(self):
     """git_send_email_only is false (default value) and email has not been
        sent with git send-email"""
     email = self.get_email()
     parse_mail(email)
     self._assertNPatches(1)
Example #25
0
 def insert(self, mails=[]):
     if not mails:
         mails = self.create_mails()
     for mail in mails:
         parse_mail(mail)
Example #26
0
 def testInvalidStateRequestFallsBackToDefaultState(self):
     email = self.get_email()
     email['X-Patchwork-State'] = self.invalid_state_name
     parse_mail(email)
     self._assertState(self.default_state)
Example #27
0
 def testImplicitDefaultStateRequest(self):
     email = self.get_email()
     parse_mail(email)
     self._assertState(self.default_state)
Example #28
0
 def testExplicitDefaultStateRequest(self):
     email = self.get_email()
     email['X-Patchwork-State'] = self.default_state.name
     parse_mail(email)
     self._assertState(self.default_state)
Example #29
0
 def testInvalidDelegateFallsBackToNoDelegate(self):
     email = self.get_email()
     email['X-Patchwork-Delegate'] = self.invalid_delegate_email
     parse_mail(email)
     self._assertDelegate(None)
Example #30
0
 def testDelegate(self):
     email = self.get_email()
     email['X-Patchwork-Delegate'] = self.user.email
     parse_mail(email)
     self._assertDelegate(self.user)
Example #31
0
 def test_no_delegate(self):
     email = self._get_email()
     parse_mail(email)
     self.assertDelegate(None)
Example #32
0
 def test_implicit_default_state_request(self):
     email = self._get_email()
     parse_mail(email)
     self.assertState(self.default_state)
Example #33
0
 def insert(self, mails=[]):
     if not mails:
         mails = self.create_mails()
     for mail in mails:
         parse_mail(mail)
Example #34
0
 def test_invalid_delegate(self):
     email = self._get_email()
     email['X-Patchwork-Delegate'] = self.invalid_delegate_email
     parse_mail(email)
     self.assertDelegate(None)
Example #35
0
 def testNoDelegate(self):
     email = self.get_email()
     parse_mail(email)
     self._assertDelegate(None)
Example #36
0
    def testPatchUpdateShouldCreateNewRevision(self):
        revisions_num = SeriesRevision.objects.count()

        parse_mail(self.patch_update)

        self.assertEqual(revisions_num + 1, SeriesRevision.objects.count())
Example #37
0
    def testNormalCommentShouldNOTCreateNewRevision(self):
        revisions_num = SeriesRevision.objects.count()

        parse_mail(self.comment)

        self.assertEqual(revisions_num, SeriesRevision.objects.count())
Example #38
0
 def test_explicit_default_state_request(self):
     email = self._get_email()
     email['X-Patchwork-State'] = self.default_state.name
     parse_mail(email)
     self.assertState(self.default_state)