~cr3/launchpad-results/trunk

« back to all changes in this revision

Viewing changes to lib/lp/results/models/tests/test_project.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:
3
3
 
4
4
__metaclass__ = type
5
5
 
 
6
__all__ = []
 
7
 
6
8
from unittest import defaultTestLoader
7
9
 
8
10
from zope.component import getUtility
9
11
 
10
 
from lp.results.interfaces import IProjectSet
 
12
from lp.results.interfaces import (
 
13
    IProjectSet,
 
14
    ProjectSearchParams,
 
15
    )
11
16
 
12
17
from lp.results.testing.cases import TestCaseWithFactory
13
18
from lp.results.testing.layers import FunctionalDatabaseLayer
23
28
        self.assertNotEquals(project, None)
24
29
        self.assertEquals(project.name, u"hello")
25
30
 
26
 
    def test_dateLastTested(self):
27
 
        person = self.factory.makePerson()
28
 
        project = getUtility(IProjectSet).create(person, u"hello")
29
 
        self.assertEquals(project.date_last_tested, None)
30
 
        project.createTestRun(person)
31
 
        self.assertNotEquals(project.date_last_tested, None)
 
31
    def test_get(self):
 
32
        project = self.factory.makeProject()
 
33
        other = getUtility(IProjectSet).get(project.id)
 
34
        self.assertNotEquals(other, None)
 
35
        self.assertEquals(other, project)
 
36
 
 
37
    def test_getByName(self):
 
38
        name = self.factory.getUniqueString(u"project-name")
 
39
        other = getUtility(IProjectSet).getByName(name)
 
40
        self.assertEquals(other, None)
 
41
 
 
42
        project = self.factory.makeProject(name=name)
 
43
        other = getUtility(IProjectSet).getByName(name)
 
44
        self.assertNotEquals(other, None)
 
45
        self.assertEquals(other, project)
 
46
 
 
47
    def test_searchName(self):
 
48
        name = self.factory.getUniqueString(u"project-name")
 
49
        params = ProjectSearchParams(name=name)
 
50
        other = getUtility(IProjectSet).search(params).one()
 
51
        self.assertEquals(other, None)
 
52
 
 
53
        project = self.factory.makeProject(name=name)
 
54
        other = getUtility(IProjectSet).search(params).one()
 
55
        self.assertNotEquals(other, None)
 
56
        self.assertEquals(other, project)
32
57
 
33
58
 
34
59
def test_suite():