Commit bfcf21a3 authored by Arkadiusz Hiler's avatar Arkadiusz Hiler

models.SeriesRevision: Add series completion date

Previously there was no way of telling when the series is complete other
than digging through the completion events, which is suboptimal.
Signed-off-by: default avatarArkadiusz Hiler <arkadiusz.hiler@intel.com>
parent dfc57136
# -*- coding: utf-8 -*-
# Generated by Django 1.11.20 on 2019-07-17 16:45
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('patchwork', '0031_auto_20190213_2200'),
]
operations = [
migrations.AddField(
model_name='seriesrevision',
name='completed',
field=models.DateTimeField(default=None, null=True),
),
]
......@@ -627,6 +627,7 @@ class SeriesRevision(models.Model):
test_state = models.SmallIntegerField(choices=TestState.STATE_CHOICES,
null=True, blank=True)
is_rerun = models.BooleanField(default=False)
completed = models.DateTimeField(null=True, default=None)
class Meta:
unique_together = [('series', 'version')]
......@@ -643,9 +644,12 @@ class SeriesRevision(models.Model):
sp = SeriesRevisionPatch.objects.create(revision=self, patch=patch,
order=order)
sp.save()
if self.patches_count == self.n_patches:
self.completed = datetime.datetime.now()
self.save()
series_revision_complete.send(sender=self.__class__, revision=self)
@property
......
......@@ -18,6 +18,7 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
import os
import datetime
from django.test import TestCase
......@@ -133,22 +134,34 @@ class RevisionStatus(GeneratedSeriesTest):
self.assertFalse(self.last_revision.is_complete)
self.assertFalse(self.last_revision.is_strange)
self.assertIsNone(self.last_revision.completed)
def testSeriesWithAllMailsShouldBeComplete(self):
pre_time = datetime.datetime.now()
self.test_series.insert(self.mails)
post_time = datetime.datetime.now()
self.assertTrue(self.last_revision.is_complete)
self.assertFalse(self.last_revision.is_strange)
self.assertGreaterEqual(self.last_revision.completed, pre_time)
self.assertLessEqual(self.last_revision.completed, post_time)
def testSeriesWithExtraEmailShouldBeCompleteAndStrange(self):
pre_time = datetime.datetime.now()
extra = self.test_series.create_patch(self.test_series.n_patches + 1,
in_reply_to=self.mails[0])
self.test_series.insert(self.mails)
post_time = datetime.datetime.now()
self.test_series.insert([extra])
self.assertTrue(self.last_revision.is_complete)
self.assertTrue(self.last_revision.is_strange)
self.assertGreaterEqual(self.last_revision.completed, pre_time)
self.assertLessEqual(self.last_revision.completed, post_time)
def testSeriesWithExtraEmailShouldNotCreateNewCompletionEvent(self):
extra = self.test_series.create_patch(self.test_series.n_patches + 1,
in_reply_to=self.mails[0])
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment