"Fossies" - the Fresh Open Source Software Archive

Member "buildbot-2.3.1/buildbot/test/unit/test_www_resource.py" (23 May 2019, 2084 Bytes) of package /linux/misc/buildbot-2.3.1.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Python source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file. See also the last Fossies "Diffs" side-by-side code changes report for "test_www_resource.py": 2.1.0_vs_2.2.0.

    1 # This file is part of Buildbot.  Buildbot is free software: you can
    2 # redistribute it and/or modify it under the terms of the GNU General Public
    3 # License as published by the Free Software Foundation, version 2.
    4 #
    5 # This program is distributed in the hope that it will be useful, but WITHOUT
    6 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
    7 # FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
    8 # details.
    9 #
   10 # You should have received a copy of the GNU General Public License along with
   11 # this program; if not, write to the Free Software Foundation, Inc., 51
   12 # Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
   13 #
   14 # Copyright Buildbot Team Members
   15 
   16 
   17 from twisted.trial import unittest
   18 
   19 from buildbot.test.util import www
   20 from buildbot.test.util.misc import TestReactorMixin
   21 from buildbot.www import resource
   22 
   23 
   24 class ResourceSubclass(resource.Resource):
   25 
   26     needsReconfig = True
   27 
   28 
   29 class Resource(TestReactorMixin, www.WwwTestMixin, unittest.TestCase):
   30 
   31     def setUp(self):
   32         self.setUpTestReactor()
   33 
   34     def test_base_url(self):
   35         master = self.make_master(url=b'h:/a/b/')
   36         rsrc = resource.Resource(master)
   37         self.assertEqual(rsrc.base_url, b'h:/a/b/')
   38 
   39     def test_reconfigResource_registration(self):
   40         master = self.make_master(url=b'h:/a/b/')
   41         rsrc = ResourceSubclass(master)
   42         master.www.resourceNeedsReconfigs.assert_called_with(rsrc)
   43 
   44 
   45 class RedirectResource(TestReactorMixin, www.WwwTestMixin, unittest.TestCase):
   46 
   47     def setUp(self):
   48         self.setUpTestReactor()
   49 
   50     def test_redirect(self):
   51         master = self.make_master(url=b'h:/a/b/')
   52         rsrc = resource.RedirectResource(master, b'foo')
   53         self.render_resource(rsrc, b'/')
   54         self.assertEqual(self.request.redirected_to, b'h:/a/b/foo')
   55 
   56     def test_redirect_cr_lf(self):
   57         master = self.make_master(url=b'h:/a/b/')
   58         rsrc = resource.RedirectResource(master, b'foo\r\nbar')
   59         self.render_resource(rsrc, b'/')
   60         self.assertEqual(self.request.redirected_to, b'h:/a/b/foo')