aboutsummaryrefslogtreecommitdiffstats
path: root/lib/python2.7/site-packages/buildbot-0.8.8-py2.7.egg/buildbot/test/unit/test_scripts_tryserver.py
blob: 42ff72daf7f334d8098b809c28ac83e03b182f57 (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
# 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

from __future__ import with_statement

import os
import sys
from cStringIO import StringIO
from twisted.trial import unittest
from buildbot.scripts import tryserver
from buildbot.test.util import dirs

class TestStatusLog(dirs.DirsMixin, unittest.TestCase):

    def setUp(self):
        self.newdir = os.path.join('jobdir', 'new')
        self.tmpdir = os.path.join('jobdir', 'tmp')
        self.setUpDirs("jobdir", self.newdir, self.tmpdir)

    def test_trycmd(self):
        config = dict(jobdir='jobdir')
        inputfile = StringIO('this is my try job')
        self.patch(sys, 'stdin', inputfile)

        rc = tryserver.tryserver(config)

        self.assertEqual(rc, 0)

        newfiles = os.listdir(self.newdir)
        tmpfiles = os.listdir(self.tmpdir)
        self.assertEqual((len(newfiles), len(tmpfiles)),
                         (1, 0))
        with open(os.path.join(self.newdir, newfiles[0]), 'rt') as f:
            self.assertEqual(f.read(), 'this is my try job')