def testCGIScript(self): config = yaml.load(APP_YAML) handler = {'url': '/', 'script': 'main.py'} config['handlers'] = [handler] # CGI handlers supported only when threadsafe is false config['threadsafe'] = False target_info._ValidateConfig(config)
def testMimeTypeOnStaticFiles(self): config = yaml.load(APP_YAML) handler = {'url': '/x(.*)x', 'static_files': r'static/\1', 'upload': 'static/.*', 'mime_type': 'image/gif', 'expiration': '10m'} config['handlers'] = [handler] target_info._ValidateConfig(config)
def testSkipFiles(self): config = yaml.load(APP_YAML + r""" skip_files: - ^(.*/)?skip_folder.* - ^(.*/)?README\.txt """) target_info._ValidateConfig(config)
def testStaticFiles(self): config = yaml.load(APP_YAML) handler = {'url': '/x(.*)x', 'static_files': r'static/\1', 'expiration': '10m'} config['handlers'] = [handler] self.CheckError(config) handler['upload'] = 'static/.*' target_info._ValidateConfig(config)
def testCGIModuleValidation(self): config = yaml.load(APP_YAML) handler = {'url': '/', 'script': 'foo/bar'} config['handlers'] = [handler] # CGI handlers aren't supported when threadsafe is true self.assertRaises(target_info.ValidationError, target_info._ValidateConfig, config) # should pass if threadsafe is false config['threadsafe'] = False target_info._ValidateConfig(config)
def Check(handler): config = yaml.load(APP_YAML) config['handlers'] = [handler] handler['login'] = '******' target_info._ValidateConfig(config) handler['login'] = '******' target_info._ValidateConfig(config) handler['login'] = '******' self.assertRaises(target_info.ValidationError, target_info._ValidateConfig, config)
def testLibraries(self): config = yaml.load(APP_YAML + """ libraries: - name: webapp2 version: to_be_set """) valid_versions = ('latest', '2.5.2') for version in valid_versions: config['libraries'][0]['version'] = version target_info._ValidateConfig(config)
def testMimeTypeOnStaticFiles(self): config = yaml.load(APP_YAML) handler = { 'url': '/x(.*)x', 'static_files': r'static/\1', 'upload': 'static/.*', 'mime_type': 'image/gif', 'expiration': '10m' } config['handlers'] = [handler] target_info._ValidateConfig(config)
def testStaticFiles(self): config = yaml.load(APP_YAML) handler = { 'url': '/x(.*)x', 'static_files': r'static/\1', 'expiration': '10m' } config['handlers'] = [handler] self.CheckError(config) handler['upload'] = 'static/.*' target_info._ValidateConfig(config)
def testHandlerExpiration(self): config = yaml.load(APP_YAML) config['handlers'].append({ 'url': '/x(.*)x', 'static_files': r'static/\1', 'upload': 'static/.*' }) for value in VALID_EXPIRATIONS: for config_handler in config['handlers']: config_handler['expiration'] = value # should pass target_info._ValidateConfig(config)
def testHandlerSecure(self): config = yaml.load(APP_YAML) config['handlers'].extend([{ 'url': '/x(.*)x', 'static_files': r'static/\1', 'upload': 'static/.*' }, { 'url': '/y(.*)y', 'script': 'y.app', }]) for value in VALID_SECURES: for config_handler in config['handlers']: config_handler['secure'] = value # should pass target_info._ValidateConfig(config)
def testBuiltinDeferred(self): config = yaml.load(APP_YAML + """ builtins: - deferred: on """) target_info._ValidateConfig(config)
def testMimeTypeOnStaticDir(self): config = yaml.load(APP_YAML + """ mime_type: text/plain; charset=utf-8 """) target_info._ValidateConfig(config)
def testBuiltinDatastoreAdmin(self): config = yaml.load(APP_YAML + """ builtins: - datastore_admin: on """) target_info._ValidateConfig(config)
def testBuiltinAdminRedirect(self): config = yaml.load(APP_YAML + """ builtins: - admin_redirect: on """) target_info._ValidateConfig(config)
def testBuiltinRemoteApi(self): config = yaml.load(APP_YAML + """ builtins: - remote_api: on """) target_info._ValidateConfig(config)
def testBuiltinAppstats(self): config = yaml.load(APP_YAML + """ builtins: - appstats: on """) target_info._ValidateConfig(config)
def testDefaultExpiration(self): config = yaml.load(APP_YAML) for value in VALID_EXPIRATIONS: config['default_expiration'] = value # should pass target_info._ValidateConfig(config)
def testWSGIScript(self): config = yaml.load(APP_YAML) handler = {'url': '/', 'script': 'main.app'} config['handlers'] = [handler] target_info._ValidateConfig(config)
def testOk(self): target_info._ValidateConfig(yaml.load(APP_YAML))