本文整理汇总了Python中shimehari.configuration.ConfigManager.removeConfig方法的典型用法代码示例。如果您正苦于以下问题:Python ConfigManager.removeConfig方法的具体用法?Python ConfigManager.removeConfig怎么用?Python ConfigManager.removeConfig使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类shimehari.configuration.ConfigManager
的用法示例。
在下文中一共展示了ConfigManager.removeConfig方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testStaticFile
# 需要导入模块: from shimehari.configuration import ConfigManager [as 别名]
# 或者: from shimehari.configuration.ConfigManager import removeConfig [as 别名]
def testStaticFile(self):
ConfigManager.removeConfig('development')
ConfigManager.addConfig(testConfig)
app = shimehari.Shimehari(__name__)
app.setStaticFolder('static')
with app.testRequestContext():
rv = app.sendStaticFile('index.html')
cc = parse_cache_control_header(rv.headers['Cache-Control'])
self.assertEqual(cc.max_age, 12 * 60 * 60)
rv = shimehari.sendFile(os.path.join(app.rootPath, 'static/index.html'))
cc = parse_cache_control_header(rv.headers['Cache-Control'])
self.assertEqual(cc.max_age, 12 * 60 * 60)
app.config['SEND_FILE_MAX_AGE_DEFAULT'] = 3600
with app.testRequestContext():
rv = app.sendStaticFile('index.html')
cc = parse_cache_control_header(rv.headers['Cache-Control'])
self.assertEqual(cc.max_age, 3600)
rv = shimehari.sendFile(os.path.join(app.rootPath, 'static/index.html'))
cc = parse_cache_control_header(rv.headers['Cache-Control'])
self.assertEqual(cc.max_age, 3600)
class StaticFileApp(shimehari.Shimehari):
def getSendFileMaxAge(self, filename):
return 10
app = StaticFileApp(__name__)
app.setStaticFolder('static')
with app.testRequestContext():
rv = app.sendStaticFile('index.html')
cc = parse_cache_control_header(rv.headers['Cache-Control'])
self.assertEqual(cc.max_age, 10)
rv = shimehari.sendFile(os.path.join(app.rootPath, 'static/index.html'))
cc = parse_cache_control_header(rv.headers['Cache-Control'])
self.assertEqual(cc.max_age, 10)
示例2: testSetup
# 需要导入模块: from shimehari.configuration import ConfigManager [as 别名]
# 或者: from shimehari.configuration.ConfigManager import removeConfig [as 别名]
def testSetup(self):
# ConfigManager.addConfig(testConfig)
ConfigManager.removeConfig('development')
ConfigManager.addConfig(Config('development', {'AUTO_SETUP': False, 'SERVER_NAME': 'localhost', 'PREFERRED_URL_SCHEME': 'https'}))
app = shimehari.Shimehari(__name__)
app.appPath = os.path.join(app.rootPath, 'testApp')
app.appFolder = 'shimehari.testsuite.testApp'
app.setupTemplater()
app.setupBindController()
app.setupBindRouter()
self.assertNotEqual(app.controllers, {})
self.assertNotEqual(app.router._rules, {})
pass
示例3: testHasChild
# 需要导入模块: from shimehari.configuration import ConfigManager [as 别名]
# 或者: from shimehari.configuration.ConfigManager import removeConfig [as 别名]
def testHasChild(self):
ConfigManager.removeConfig("development")
ConfigManager.addConfig(testConfig)
def index(*args, **kwargs):
return "index"
def show(*args, **kwargs):
return "show"
router = RESTfulRouter(
[Resource(IndexController, [Resource(ChildController)]), RESTfulRule("test", index, show)]
)
app = shimehari.Shimehari(__name__)
app.setupTemplater()
app.router = router
app.setControllerFromRouter(router)
c = app.testClient()
rv = c.get("/index/1", content_type="text/planetext")
self.assertEqual(rv.data, "response show")
示例4: testTryTriggerBeforeFirstRequest
# 需要导入模块: from shimehari.configuration import ConfigManager [as 别名]
# 或者: from shimehari.configuration.ConfigManager import removeConfig [as 别名]
def testTryTriggerBeforeFirstRequest(self):
ConfigManager.removeConfig('development')
ConfigManager.addConfig(testConfig)
app = shimehari.Shimehari(__name__)
app.testCnt = 0
@app.beforeFirstRequest
def doFirst():
app.testCnt = app.testCnt + 1
return app.testCnt
def returnHello(*args, **kwargs):
return 'Hello'
app.router = shimehari.Router([Rule('/hell', endpoint='returnHello', methods=['POST'])])
app.controllers['returnHello'] = returnHello
c = app.testClient()
self.assertEqual(app.testCnt, 0)
c.get('/hell', content_type='text/planetext')
self.assertEqual(app.testCnt, 1)
c.get('/hell', content_type='text/planetext')
self.assertEqual(app.testCnt, 1)