diff options
Diffstat (limited to 'lib/python2.7/site-packages/buildbot-0.8.8-py2.7.egg/buildbot/test/unit/test_status_web_base.py')
-rw-r--r-- | lib/python2.7/site-packages/buildbot-0.8.8-py2.7.egg/buildbot/test/unit/test_status_web_base.py | 98 |
1 files changed, 0 insertions, 98 deletions
diff --git a/lib/python2.7/site-packages/buildbot-0.8.8-py2.7.egg/buildbot/test/unit/test_status_web_base.py b/lib/python2.7/site-packages/buildbot-0.8.8-py2.7.egg/buildbot/test/unit/test_status_web_base.py deleted file mode 100644 index a7d007c0..00000000 --- a/lib/python2.7/site-packages/buildbot-0.8.8-py2.7.egg/buildbot/test/unit/test_status_web_base.py +++ /dev/null @@ -1,98 +0,0 @@ -# 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 buildbot.status.web import base -from twisted.internet import defer -from twisted.trial import unittest - -from buildbot.test.fake.web import FakeRequest - -class ActionResource(unittest.TestCase): - - def test_ActionResource_success(self): - - class MyActionResource(base.ActionResource): - def performAction(self, request): - self.got_request = request - return defer.succeed('http://buildbot.net') - - rsrc = MyActionResource() - request = FakeRequest() - rsrc.render(request) - d = request.deferred - - def check(_): - self.assertIdentical(rsrc.got_request, request) - self.assertTrue(request.finished) - self.assertIn('buildbot.net', request.written) - self.assertEqual(request.redirected_to, 'http://buildbot.net') - d.addCallback(check) - return d - - def test_ActionResource_exception(self): - - class MyActionResource(base.ActionResource): - def performAction(self, request): - return defer.fail(RuntimeError('sacrebleu')) - - rsrc = MyActionResource() - request = FakeRequest() - rsrc.render(request) - d = request.deferred - - def check(f): - f.trap(RuntimeError) - # pass - all good! - d.addErrback(check) - return d - -class Functions(unittest.TestCase): - - def do_test_getRequestCharset(self, hdr, exp): - req = mock.Mock() - req.getHeader.return_value = hdr - - self.assertEqual(base.getRequestCharset(req), exp) - - def fakeRequest(self, prepath): - r = mock.Mock() - r.prepath = prepath - return r - - def test_getRequestCharset_empty(self): - return self.do_test_getRequestCharset(None, 'utf-8') - - def test_getRequestCharset_specified(self): - return self.do_test_getRequestCharset( - 'application/x-www-form-urlencoded ; charset=ISO-8859-1', - 'ISO-8859-1') - - def test_getRequestCharset_other_params(self): - return self.do_test_getRequestCharset( - 'application/x-www-form-urlencoded ; charset=UTF-16 ; foo=bar', - 'UTF-16') - - def test_path_to_root_from_root(self): - self.assertEqual(base.path_to_root(self.fakeRequest([])), - './') - - def test_path_to_root_from_one_level(self): - self.assertEqual(base.path_to_root(self.fakeRequest(['waterfall'])), - './') - - def test_path_to_root_from_two_level(self): - self.assertEqual(base.path_to_root(self.fakeRequest(['a', 'b'])), - '../') |