本文整理汇总了Python中MilkCheck.Engine.BaseEntity.BaseEntity._resolve方法的典型用法代码示例。如果您正苦于以下问题:Python BaseEntity._resolve方法的具体用法?Python BaseEntity._resolve怎么用?Python BaseEntity._resolve使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MilkCheck.Engine.BaseEntity.BaseEntity
的用法示例。
在下文中一共展示了BaseEntity._resolve方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_resolve_2_command_substitutions
# 需要导入模块: from MilkCheck.Engine.BaseEntity import BaseEntity [as 别名]
# 或者: from MilkCheck.Engine.BaseEntity.BaseEntity import _resolve [as 别名]
def test_resolve_2_command_substitutions(self):
'''Test 2 command substitutions'''
service = BaseEntity('test_service')
service.add_var('EXCLUDED_NODES', 'foo')
service.add_var('SELECTED_NODES', 'bar')
expr = '%([ -n "%SELECTED_NODES" ] && echo "-n %SELECTED_NODES")' + \
' %([ -n "%EXCLUDED_NODES" ] && echo "-x %EXCLUDED_NODES")'
self.assertEqual(service._resolve(expr), '-n bar -x foo')
示例2: test_resolve_list_value
# 需要导入模块: from MilkCheck.Engine.BaseEntity import BaseEntity [as 别名]
# 或者: from MilkCheck.Engine.BaseEntity.BaseEntity import _resolve [as 别名]
def test_resolve_list_value(self):
"""resolve a variable with a non-string value (list)"""
service = BaseEntity('test_service')
service.add_var('list', ['a', 'b'])
self.assertEqual(service._resolve("%list"), ['a', 'b'])
示例3: test_resolve_recurse
# 需要导入模块: from MilkCheck.Engine.BaseEntity import BaseEntity [as 别名]
# 或者: from MilkCheck.Engine.BaseEntity.BaseEntity import _resolve [as 别名]
def test_resolve_recurse(self):
'''Test recursive variable resolution'''
service = BaseEntity('test_service')
service.add_var('foo', 'key')
service.add_var('bar', 'Keep my %foo')
self.assertEqual(service._resolve('%bar'), 'Keep my key')
示例4: test_resolve_command_substitution
# 需要导入模块: from MilkCheck.Engine.BaseEntity import BaseEntity [as 别名]
# 或者: from MilkCheck.Engine.BaseEntity.BaseEntity import _resolve [as 别名]
def test_resolve_command_substitution(self):
'''Test command substitution'''
service = BaseEntity('test_service')
service.add_var('EXCLUDED_NODES', 'foo')
expr = '%([ -n "%EXCLUDED_NODES" ] && echo "-n %EXCLUDED_NODES")'
self.assertEqual(service._resolve(expr), '-n foo')
示例5: test_resolve_2_variables
# 需要导入模块: from MilkCheck.Engine.BaseEntity import BaseEntity [as 别名]
# 或者: from MilkCheck.Engine.BaseEntity.BaseEntity import _resolve [as 别名]
def test_resolve_2_variables(self):
'''Test resolution with two adjacent variables'''
service = BaseEntity('test_service')
service.add_var('FOO', 'foo')
service.add_var('BAR', 'bar')
self.assertEqual(service._resolve('%FOO%BAR'), 'foobar')
示例6: test_resolve_escape_char
# 需要导入模块: from MilkCheck.Engine.BaseEntity import BaseEntity [as 别名]
# 或者: from MilkCheck.Engine.BaseEntity.BaseEntity import _resolve [as 别名]
def test_resolve_escape_char(self):
'''Test resolution with a variable escaping %'''
service = BaseEntity('test_service')
service.add_var('FOO', 'Keep my %%noeval!')
self.assertEqual(service._resolve('%FOO'), 'Keep my %noeval!')
示例7: test_resolve_double_exec
# 需要导入模块: from MilkCheck.Engine.BaseEntity import BaseEntity [as 别名]
# 或者: from MilkCheck.Engine.BaseEntity.BaseEntity import _resolve [as 别名]
def test_resolve_double_exec(self):
"""Test resolution of 2 successive expressions."""
service = BaseEntity('base')
self.assertEqual(service._resolve('%(echo foo) %(echo bar)'), 'foo bar')
示例8: test_resolve_property4
# 需要导入模块: from MilkCheck.Engine.BaseEntity import BaseEntity [as 别名]
# 或者: from MilkCheck.Engine.BaseEntity.BaseEntity import _resolve [as 别名]
def test_resolve_property4(self):
'''Command substitution with a non-zero exit code should be ok'''
service = BaseEntity('test_service')
service.add_var('NODES', '%(/bin/false)')
self.assertEqual(service._resolve('%NODES'), '')
示例9: test_resolve_value6
# 需要导入模块: from MilkCheck.Engine.BaseEntity import BaseEntity [as 别名]
# 或者: from MilkCheck.Engine.BaseEntity.BaseEntity import _resolve [as 别名]
def test_resolve_value6(self):
'''Test resolution of variable inside an expression'''
service = BaseEntity('test_service')
self.assertEqual(service._resolve('%(echo %NAME)'),
'test_service')
示例10: test_resolve_value7
# 需要导入模块: from MilkCheck.Engine.BaseEntity import BaseEntity [as 别名]
# 或者: from MilkCheck.Engine.BaseEntity.BaseEntity import _resolve [as 别名]
def test_resolve_value7(self):
'''Test resolution of variable inside an expression (2)'''
service = BaseEntity('test_service')
service.add_var('CMD', 'echo')
self.assertEqual(service._resolve('%(%CMD foo)'), 'foo')
示例11: test_resolve_value5
# 需要导入模块: from MilkCheck.Engine.BaseEntity import BaseEntity [as 别名]
# 或者: from MilkCheck.Engine.BaseEntity.BaseEntity import _resolve [as 别名]
def test_resolve_value5(self):
'''Test combining resolution of variables and expressions'''
service = BaseEntity('test_service')
service.add_var('NODES', 'localhost,127.0.0.1')
self.assertEqual(service._resolve('%NODES %(echo hello world) %NAME'),
'localhost,127.0.0.1 hello world test_service')
示例12: test_resolve_value4
# 需要导入模块: from MilkCheck.Engine.BaseEntity import BaseEntity [as 别名]
# 或者: from MilkCheck.Engine.BaseEntity.BaseEntity import _resolve [as 别名]
def test_resolve_value4(self):
'''Test resolution of an expression'''
service = BaseEntity('test_service')
self.assertEqual(service._resolve('%(echo hello world)'),
'hello world')
示例13: test_resolve_value3
# 需要导入模块: from MilkCheck.Engine.BaseEntity import BaseEntity [as 别名]
# 或者: from MilkCheck.Engine.BaseEntity.BaseEntity import _resolve [as 别名]
def test_resolve_value3(self):
'''Test multiple variable replacements'''
service = BaseEntity('test_service')
service.add_var('NODES', 'localhost,127.0.0.1')
self.assertEqual(service._resolve('%NODES %NAME'),
'localhost,127.0.0.1 test_service')
示例14: test_resolve_value2
# 需要导入模块: from MilkCheck.Engine.BaseEntity import BaseEntity [as 别名]
# 或者: from MilkCheck.Engine.BaseEntity.BaseEntity import _resolve [as 别名]
def test_resolve_value2(self):
'''Test replacement of variable referenced in the entity'''
service = BaseEntity('test_service')
service.add_var('NODES', 'localhost,127.0.0.1')
self.assertEqual(service._resolve('%NODES'), 'localhost,127.0.0.1')
示例15: test_resolve_value1
# 需要导入模块: from MilkCheck.Engine.BaseEntity import BaseEntity [as 别名]
# 或者: from MilkCheck.Engine.BaseEntity.BaseEntity import _resolve [as 别名]
def test_resolve_value1(self):
'''Test no replacement to do so just return the initial value'''
service = BaseEntity('test_service')
self.assertEqual(service._resolve('hello world'), 'hello world')