aboutsummaryrefslogtreecommitdiffstats
path: root/lib/python2.7/site-packages/buildbot-0.8.8-py2.7.egg/buildbot/test/unit/test_status_client.py
blob: 75e93fb4c29de8de36935ee1e68ea4375f6e1829 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# This file is part of Buildbot.  Buildbot is free software: you can
# redistribute it and/or modify it under the terms of the GNU General Public
# License as published by the Free Software Foundation, version 2.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
# details.
#
# You should have received a copy of the GNU General Public License along with
# this program; if not, write to the Free Software Foundation, Inc., 51
# Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Copyright Buildbot Team Members

import mock
from twisted.trial import unittest
from buildbot.status import master, client
from buildbot.test.fake import fakedb

class TestStatusClientPerspective(unittest.TestCase):

    def makeStatusClientPersp(self):
        m = mock.Mock(name='master')
        self.db = m.db = fakedb.FakeDBConnector(self)
        m.basedir = r'C:\BASEDIR'
        s = master.Status(m) 
        persp = client.StatusClientPerspective(s)
        return persp

    def test_getBuildSets(self):
        persp = self.makeStatusClientPersp()
        self.db.insertTestData([
            fakedb.SourceStampSet(id=234),
            fakedb.Buildset(id=91, sourcestampsetid=234, complete=0,
                    complete_at=298297875, results=-1, submitted_at=266761875,
                    external_idstring='extid', reason='rsn1'),
        ])

        d = persp.perspective_getBuildSets()
        def check(bslist):
            self.assertEqual(len(bslist), 1)
            self.assertEqual(bslist[0][1], 91)
            self.failUnlessIsInstance(bslist[0][0], client.RemoteBuildSet)
        d.addCallback(check)
        return d