Skip to content

Commit

Permalink
tests: Test we create events when new series change the number of pat…
Browse files Browse the repository at this point in the history
…ches

We had a bug where re-submitting a series with a different number of
patches wasn't correctly updated the number of patches of that series
and thus patchwork was never able to understand that the new series was
complete.

This had the unfortunate effect that CI systems listening for
"series-new-revision" events weren't ever able to see, and so test, the
new revision.

Since I moved the number of patches on the revision, this should now
work. Added a check on the number of patches and events to have some
coverage of that fix.

Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
  • Loading branch information
Damien Lespiau committed Feb 3, 2016
1 parent 4ff7a32 commit f287369
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions patchwork/tests/test_series.py
Original file line number Diff line number Diff line change
Expand Up @@ -547,10 +547,11 @@ def testSeriesAsReplyofSinglePatchCrossSeriesAwarePatchwork(self):

class FullSeriesUpdateTest(GeneratedSeriesTest):

def check_revision(self, series, revision, mails):
def check_revision(self, series, revision, mails, ref_n_patches):
n_patches = len(mails)
if self.has_cover_letter:
n_patches -= 1
self.assertEquals(n_patches, ref_n_patches)

self.assertEquals(revision.series_id, series.id)
self.assertEquals(revision.root_msgid, mails[0].get('Message-Id'))
Expand All @@ -562,16 +563,20 @@ def check_revision(self, series, revision, mails):
self.assertEquals(patch.msgid, patch_mail.get('Message-Id'))
i += 1

def check(self, series1_mails, series2_mails):
def check(self, series1_mails, series2_mails, n_patches):
self.assertEquals(Series.objects.count(), 1)
series = Series.objects.all()[0]
self.assertEquals(series.last_revision.version, 2)

revisions = SeriesRevision.objects.all()
self.assertEquals(revisions.count(), 2)

self.check_revision(series, revisions[0], series1_mails)
self.check_revision(series, revisions[1], series2_mails)
self.check_revision(series, revisions[0], series1_mails, n_patches[0])
self.check_revision(series, revisions[1], series2_mails, n_patches[1])

# Make sure we've created an event per revision (and so we've correctly
# picked up the 2 revisions even if the number of patches changes)
self.assertEquals(EventLog.objects.all().count(), 2)

def _set_cover_letter_subject(self, mail, n_patches, subject):
del mail['Subject']
Expand All @@ -591,7 +596,7 @@ def _test_internal(self, n_patches, subjects):
subjects[1])
series2.insert(series2_mails)

self.check(series1_mails, series2_mails)
self.check(series1_mails, series2_mails, n_patches)

def testCleanSeriesName(self):
cases = (
Expand Down

0 comments on commit f287369

Please sign in to comment.