def testSecondMatch(self): app_yaml = APP_YAML + """ - url: /foo static_dir: bar """ config = yaml.load(app_yaml) self.assertEquals(target_info.StaticPage('bar/x'), target_info.FindPage(config, '/foo/x'))
def CheckMimeType(mime_type): handler = {'url': '/foo', 'static_dir': 'bar', 'expiration': '6m'} if mime_type is not None: handler['mime_type'] = mime_type self.assertEquals( target_info.StaticPage('bar/x.html', mime_type=mime_type, expiration='6m'), target_info._MatchHandler(handler, '/foo/x.html'))
def testStaticFiles(self): handler = { 'url': '/x(.*)x', 'static_files': r'static/\1', 'expiration': '13m' } self.assertEquals( target_info.StaticPage('static/foo', expiration='13m'), target_info._MatchHandler(handler, '/xfoox')) self.assertIsNone(target_info._MatchHandler(handler, '/abc'))
def CheckHandler(url, static_dir): handler = { 'url': url, 'static_dir': static_dir, 'expiration': '5m' } self.assertEquals( target_info.StaticPage('bar/x.html', expiration='5m'), target_info._MatchHandler(handler, '/foo/x.html')) self.assertIsNone( target_info._MatchHandler(handler, '/notfoo/x.html')) self.assertIsNone(target_info._MatchHandler(handler, '/foox.html'))
def CheckMimeType(mime_type): handler = { 'url': '/x(.*)', 'static_files': r'static/\1', 'expiration': '7m' } if mime_type is not None: handler['mime_type'] = mime_type self.assertEquals( target_info.StaticPage('static/foo.xyz', mime_type=mime_type, expiration='7m'), target_info._MatchHandler(handler, '/xfoo.xyz'))
def testMatch(self): config = yaml.load(APP_YAML) self.assertEquals(target_info.StaticPage('static/images/foo.png'), target_info.FindPage(config, '/images/foo.png'))