当前位置: 首页>>代码示例>>Python>>正文


Python BaseEntity._resolve方法代码示例

本文整理汇总了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')
开发者ID:cea-hpc,项目名称:milkcheck,代码行数:10,代码来源:BaseEntityTest.py

示例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'])
开发者ID:cea-hpc,项目名称:milkcheck,代码行数:7,代码来源:BaseEntityTest.py

示例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')
开发者ID:cea-hpc,项目名称:milkcheck,代码行数:8,代码来源:BaseEntityTest.py

示例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')
开发者ID:cea-hpc,项目名称:milkcheck,代码行数:8,代码来源:BaseEntityTest.py

示例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')
开发者ID:cea-hpc,项目名称:milkcheck,代码行数:8,代码来源:BaseEntityTest.py

示例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!')
开发者ID:cea-hpc,项目名称:milkcheck,代码行数:7,代码来源:BaseEntityTest.py

示例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')
开发者ID:cea-hpc,项目名称:milkcheck,代码行数:6,代码来源:BaseEntityTest.py

示例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'), '')
开发者ID:cea-hpc,项目名称:milkcheck,代码行数:7,代码来源:BaseEntityTest.py

示例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')
开发者ID:cea-hpc,项目名称:milkcheck,代码行数:7,代码来源:BaseEntityTest.py

示例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')
开发者ID:cea-hpc,项目名称:milkcheck,代码行数:7,代码来源:BaseEntityTest.py

示例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')
开发者ID:cea-hpc,项目名称:milkcheck,代码行数:8,代码来源:BaseEntityTest.py

示例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')
开发者ID:cea-hpc,项目名称:milkcheck,代码行数:7,代码来源:BaseEntityTest.py

示例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')
开发者ID:cea-hpc,项目名称:milkcheck,代码行数:8,代码来源:BaseEntityTest.py

示例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')
开发者ID:cea-hpc,项目名称:milkcheck,代码行数:7,代码来源:BaseEntityTest.py

示例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')
开发者ID:cea-hpc,项目名称:milkcheck,代码行数:6,代码来源:BaseEntityTest.py


注:本文中的MilkCheck.Engine.BaseEntity.BaseEntity._resolve方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。