1
# Copyright 2010 Canonical Ltd. This software is licensed under the
2
# GNU Affero General Public License version 3 (see the file LICENSE).
8
from unittest import defaultTestLoader
10
from lp.results.models.store import get_store
12
from lp.results.testing.cases import TestCaseWithFactory
13
from lp.results.testing.layers import DatabaseLayer
16
class TestProject(TestCaseWithFactory):
21
super(TestProject, self).setUp()
23
self.store = get_store("main")
25
def assertTestRankCount(self, name, count):
26
test_rank_count = self.store.execute(
27
"SELECT COUNT(*) FROM test_rank tr "
28
"JOIN project p ON p.id = tr.project_i_id "
32
self.assertEquals(test_rank_count, count)
34
def test_insert(self):
35
# Insert a first project which should still have a count of zero
36
name = self.factory.getUniqueString(u"project1-name")
38
"INSERT INTO project (name) VALUES (?)",
41
self.assertTestRankCount(name, 0)
43
# Insert a second project which should increase the count to one
44
name = self.factory.getUniqueString(u"project2-name")
46
"INSERT INTO project (name) VALUES (?)",
49
self.assertTestRankCount(name, 1)
53
return defaultTestLoader.loadTestsFromName(__name__)