~cr3/launchpad-results/trunk

« back to all changes in this revision

Viewing changes to lib/lp/results/models/tests/test_testrank.py

  • Committer: Marc Tardif
  • Date: 2010-12-07 01:16:17 UTC
  • Revision ID: marc.tardif@canonical.com-20101207011617-cqcv0240ca3cs5ba
Added TestStat for statistics about test runs and TestRank for ranking of projects.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Copyright 2010 Canonical Ltd.  This software is licensed under the
 
2
# GNU Affero General Public License version 3 (see the file LICENSE).
 
3
 
 
4
__metaclass__ = type
 
5
 
 
6
__all__ = [
 
7
    "HasTestRankProjectsMixin",
 
8
    ]
 
9
 
 
10
from unittest import defaultTestLoader
 
11
 
 
12
from lp.results.testing.layers import FunctionalDatabaseLayer
 
13
 
 
14
 
 
15
class HasTestRankProjectsMixin:
 
16
 
 
17
    layer = FunctionalDatabaseLayer
 
18
 
 
19
    def test_getRecommendedTestProjectsNone(self):
 
20
        self.factory.makeTestPerson(name=u"container1")
 
21
        self.factory.makeTestProject(name=u"container1")
 
22
 
 
23
        container1 = self.getContainerByName(u"container1")
 
24
        projects = container1.getRecommendedTestProjects()
 
25
        self.assertEquals(projects.count(), 0)
 
26
 
 
27
    def test_getRecommendedTestProjectsOne(self):
 
28
        person1 = self.factory.makeTestPerson(name=u"container1")
 
29
        person2 = self.factory.makeTestPerson(name=u"container2")
 
30
        project1 = self.factory.makeTestProject(name=u"container1")
 
31
        project2 = self.factory.makeTestProject(name=u"container2")
 
32
 
 
33
        project1.incrementTestStat(person1)
 
34
        project1.incrementTestStat(person2)
 
35
        project2.incrementTestStat(person2)
 
36
 
 
37
        container1 = self.getContainerByName(u"container1")
 
38
        projects = container1.getRecommendedTestProjects()
 
39
        self.assertEquals(projects.count(), 1)
 
40
        self.assertEquals(projects[0], project2)
 
41
 
 
42
 
 
43
def test_suite():
 
44
    return defaultTestLoader.loadTestsFromName(__name__)