Commit 5ae002be authored by Stephen Finucane's avatar Stephen Finucane Committed by Damien Lespiau
Browse files

testresult: Add Test and TestResult models



The idea is to store test results in patchwork itself so the series and
patch pages can show a summary of the testing done.

Tests are defined per-project, so they can be administrated at the
project level (eg. configure the mailing policy).

We only store one test results per test, the latest state updated by the
testing system.
Signed-off-by: default avatarDamien Lespiau <damien.lespiau@intel.com>
parent e40cea0f
......@@ -20,8 +20,9 @@
from django.contrib import admin
from patchwork.models import (
Project, Person, UserProfile, State, Patch, Comment, Bundle, Tag)
Project, Person, UserProfile, State, Patch, Comment, Bundle, Tag, Test,
TestResult
)
class ProjectAdmin(admin.ModelAdmin):
list_display = ('name', 'linkname', 'listid', 'listemail')
......@@ -74,6 +75,20 @@ class CommentAdmin(admin.ModelAdmin):
admin.site.register(Comment, CommentAdmin)
class TestAdmin(admin.ModelAdmin):
pass
admin.site.register(Test, TestAdmin)
class TestResultAdmin(admin.ModelAdmin):
list_display = ('test', 'revision', 'patch', 'user', 'state', 'url',
'summary')
search_fields = ('test__name', 'patch__name', 'revision__series__name',
'test__project__name')
date_hierarchy = 'date'
admin.site.register(TestResult, TestResultAdmin)
class BundleAdmin(admin.ModelAdmin):
list_display = ('name', 'owner', 'project', 'public')
list_filter = ('public', 'project')
......
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import migrations, models
import datetime
from django.conf import settings
class Migration(migrations.Migration):
dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
('patchwork', '0007_multiple_projects_same_ml'),
]
operations = [
migrations.CreateModel(
name='Test',
fields=[
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('name', models.CharField(max_length=255)),
('project', models.ForeignKey(to='patchwork.Project')),
],
),
migrations.CreateModel(
name='TestResult',
fields=[
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('date', models.DateTimeField(default=datetime.datetime.now)),
('state', models.SmallIntegerField(choices=[(0, b'pending'), (1, b'success'), (2, b'warning'), (3, b'failure')])),
('url', models.URLField(null=True, blank=True)),
('summary', models.TextField(null=True, blank=True)),
('patch', models.ForeignKey(blank=True, to='patchwork.Patch', null=True)),
('revision', models.ForeignKey(blank=True, to='patchwork.SeriesRevision', null=True)),
('test', models.ForeignKey(to='patchwork.Test')),
('user', models.ForeignKey(to=settings.AUTH_USER_MODEL)),
],
),
migrations.AlterUniqueTogether(
name='testresult',
unique_together=set([('test', 'patch'), ('test', 'revision')]),
),
migrations.AlterUniqueTogether(
name='test',
unique_together=set([('project', 'name')]),
),
]
# Patchwork - automated patch tracking system
# Copyright (C) 2008 Jeremy Kerr <jk@ozlabs.org>
# Copyright (C) 2015 Intel Corporation
#
# This file is part of the Patchwork package.
#
......@@ -565,6 +566,43 @@ class EventLog(models.Model):
class Meta:
ordering = ['-event_time']
class Test(models.Model):
project = models.ForeignKey(Project)
name = models.CharField(max_length=255)
class Meta:
unique_together = [('project', 'name')]
def __unicode__(self):
return self.name
class TestResult(models.Model):
STATE_PENDING = 0
STATE_SUCCESS = 1
STATE_WARNING = 2
STATE_FAILURE = 3
STATE_CHOICES = (
(STATE_PENDING, 'pending'),
(STATE_SUCCESS, 'success'),
(STATE_WARNING, 'warning'),
(STATE_FAILURE, 'failure'),
)
test = models.ForeignKey(Test)
revision = models.ForeignKey(SeriesRevision, blank=True, null=True)
patch = models.ForeignKey(Patch, blank=True, null=True)
user = models.ForeignKey(User)
date = models.DateTimeField(default=datetime.datetime.now)
state = models.SmallIntegerField(choices=STATE_CHOICES)
url = models.URLField(blank=True, null=True)
summary = models.TextField(blank=True, null=True)
class Meta:
unique_together = [('test', 'revision'), ('test', 'patch')]
def __unicode__(self):
return self.get_state_display()
class EmailConfirmation(models.Model):
validity = datetime.timedelta(days = settings.CONFIRMATION_VALIDITY_DAYS)
type = models.CharField(max_length = 20, choices = [
......
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