Exemple #1
0
    def test_simple_path(self):
        url_map = appinfo.URLMap(url='/', static_files='index.html')
        h = static_files_handler.StaticFilesHandler(root_path='/appdir',
                                                    url_map=url_map)
        match = h.match('/')
        self.assertTrue(match)
        self.assertFalse(h.match('/other'))

        static_files_handler.StaticContentHandler._handle_path(
            os.path.join('/appdir', 'index.html'), {},
            mox.IgnoreArg()).AndReturn('<output>')
        self.mox.ReplayAll()
        self.assertEqual('<output>', h.handle(match, {}, None))
        self.mox.VerifyAll()
Exemple #2
0
    def test_patterned_path(self):
        url_map = appinfo.URLMap(url=r'/(.*)/(.*)',
                                 static_files=r'static/\1/subdir/\2')
        h = static_files_handler.StaticFilesHandler(root_path='/appdir',
                                                    url_map=url_map)
        match = h.match('/hello/foo.jpg')
        self.assertTrue(match)
        self.assertFalse(h.match('/'))

        static_files_handler.StaticContentHandler._handle_path(
            os.path.join('/appdir', 'static/hello/subdir/foo.jpg'), {},
            mox.IgnoreArg()).AndReturn('<output>')
        self.mox.ReplayAll()
        self.assertEqual('<output>', h.handle(match, {}, None))
        self.mox.VerifyAll()