當前位置: 首頁>>代碼示例>>Python>>正文


Python Interpreter.do_update方法代碼示例

本文整理匯總了Python中ansibledebugger.interpreter.simple_interpreter.Interpreter.do_update方法的典型用法代碼示例。如果您正苦於以下問題:Python Interpreter.do_update方法的具體用法?Python Interpreter.do_update怎麽用?Python Interpreter.do_update使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在ansibledebugger.interpreter.simple_interpreter.Interpreter的用法示例。


在下文中一共展示了Interpreter.do_update方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_update_module_args_ignore_nonkv

# 需要導入模塊: from ansibledebugger.interpreter.simple_interpreter import Interpreter [as 別名]
# 或者: from ansibledebugger.interpreter.simple_interpreter.Interpreter import do_update [as 別名]
    def test_update_module_args_ignore_nonkv(self, mock_stdout):
        module_args = 'key1=v1 key2=v2'
        interpreter = Interpreter(TaskInfo('', module_args, None, None),
                                  ErrorInfo(), None)
        arg = 'nonkv_args'
        interpreter.do_update('module_args %s' % (arg))

        expected_kv = '%s' % (module_args)  # should not include arg
        self.assertEqual(expected_kv, interpreter.task_info.module_args)
開發者ID:logic855,項目名稱:ansible-playbook-debugger,代碼行數:11,代碼來源:interpreter_test.py

示例2: test_update_module_args_skip_quote

# 需要導入模塊: from ansibledebugger.interpreter.simple_interpreter import Interpreter [as 別名]
# 或者: from ansibledebugger.interpreter.simple_interpreter.Interpreter import do_update [as 別名]
    def test_update_module_args_skip_quote(self, mock_stdout):
        module_args = '"key1=v1" key2=v2'
        interpreter = Interpreter(TaskInfo('', module_args, None, None),
                                  ErrorInfo(), None)
        kv = 'key1=v3'
        interpreter.do_update('module_args %s' % (kv))

        expected_kv = '%s %s' % (module_args, kv)
        self.assertEqual(expected_kv, interpreter.task_info.module_args)
開發者ID:logic855,項目名稱:ansible-playbook-debugger,代碼行數:11,代碼來源:interpreter_test.py

示例3: test_update_module_args_replace_template

# 需要導入模塊: from ansibledebugger.interpreter.simple_interpreter import Interpreter [as 別名]
# 或者: from ansibledebugger.interpreter.simple_interpreter.Interpreter import do_update [as 別名]
    def test_update_module_args_replace_template(self, mock_stdout):
        module_args = 'key1={{ var1 }} key2=v2'
        interpreter = Interpreter(TaskInfo('', module_args, None, None),
                                  ErrorInfo(), None)
        kv = 'key1={{ var3 }}'
        interpreter.do_update('module_args %s' % (kv))

        expected_kv = '%s key2=v2' % kv
        self.assertEqual(expected_kv, interpreter.task_info.module_args)
開發者ID:logic855,項目名稱:ansible-playbook-debugger,代碼行數:11,代碼來源:interpreter_test.py

示例4: test_update_complex_args_empty_kv

# 需要導入模塊: from ansibledebugger.interpreter.simple_interpreter import Interpreter [as 別名]
# 或者: from ansibledebugger.interpreter.simple_interpreter.Interpreter import do_update [as 別名]
    def test_update_complex_args_empty_kv(self, mock_stdout):
        complex_args = {'key1': 'v1'}
        interpreter = Interpreter(TaskInfo('', '', None, complex_args),
                                  ErrorInfo(), None)

        with patch('__builtin__.raw_input', side_effect=['']):
            interpreter.do_update('complex_args')

        expect = {'key1': 'v1'}  # change nothing
        self.assertEqual(interpreter.task_info.complex_args, expect)
開發者ID:logic855,項目名稱:ansible-playbook-debugger,代碼行數:12,代碼來源:interpreter_test.py

示例5: test_update_complex_args_empty_value

# 需要導入模塊: from ansibledebugger.interpreter.simple_interpreter import Interpreter [as 別名]
# 或者: from ansibledebugger.interpreter.simple_interpreter.Interpreter import do_update [as 別名]
    def test_update_complex_args_empty_value(self, mock_stdout):
        complex_args = {'key1': 'v1'}
        interpreter = Interpreter(TaskInfo('', '', None, complex_args),
                                  ErrorInfo(), None)

        key = 'key1'
        with patch('__builtin__.raw_input', side_effect=['']):
            interpreter.do_update('complex_args %s:' % (key))

        expect = {'key1': None}
        self.assertEqual(interpreter.task_info.complex_args, expect)
開發者ID:logic855,項目名稱:ansible-playbook-debugger,代碼行數:13,代碼來源:interpreter_test.py

示例6: test_update_complex_args_wrong_key

# 需要導入模塊: from ansibledebugger.interpreter.simple_interpreter import Interpreter [as 別名]
# 或者: from ansibledebugger.interpreter.simple_interpreter.Interpreter import do_update [as 別名]
    def test_update_complex_args_wrong_key(self, mock_stdout):
        complex_args = {'key1': {'key2': 'v2'}}
        interpreter = Interpreter(TaskInfo('', '', None, complex_args),
                                  ErrorInfo(), None)

        key = 'key1[0]'
        value = 'v3'
        with patch('__builtin__.raw_input', side_effect=['']):
            interpreter.do_update('complex_args %s: %s' % (key, value))

        expect = {'key1': {'key2': 'v2'}}  # change nothing
        self.assertEqual(interpreter.task_info.complex_args, expect)
開發者ID:logic855,項目名稱:ansible-playbook-debugger,代碼行數:14,代碼來源:interpreter_test.py

示例7: test_update_complex_args_long_key

# 需要導入模塊: from ansibledebugger.interpreter.simple_interpreter import Interpreter [as 別名]
# 或者: from ansibledebugger.interpreter.simple_interpreter.Interpreter import do_update [as 別名]
    def test_update_complex_args_long_key(self, mock_stdout):
        complex_args = {'k1': [{'k2': [{'k3': ['v']}]}]}
        interpreter = Interpreter(TaskInfo('', '', None, complex_args),
                                  ErrorInfo(), None)

        key = 'k1[0].k2[0]'
        value = ['v2', '']
        with patch('__builtin__.raw_input', side_effect=value):
            interpreter.do_update('complex_args %s:' % (key))

        expect = {'k1': [{'k2': ['v2']}]}
        self.assertEqual(interpreter.task_info.complex_args, expect)
開發者ID:logic855,項目名稱:ansible-playbook-debugger,代碼行數:14,代碼來源:interpreter_test.py

示例8: test_update_complex_args_replace_dict

# 需要導入模塊: from ansibledebugger.interpreter.simple_interpreter import Interpreter [as 別名]
# 或者: from ansibledebugger.interpreter.simple_interpreter.Interpreter import do_update [as 別名]
    def test_update_complex_args_replace_dict(self, mock_stdout):
        complex_args = {'key1': {'k2': 'v2'}}
        interpreter = Interpreter(TaskInfo('', '', None, complex_args),
                                  ErrorInfo(), None)

        key = 'key1'
        value = ['k3: v3', '']
        with patch('__builtin__.raw_input', side_effect=value):
            interpreter.do_update('complex_args %s:' % (key))

        expect = {'key1': {'k3': 'v3'}}
        self.assertEqual(interpreter.task_info.complex_args, expect)
開發者ID:logic855,項目名稱:ansible-playbook-debugger,代碼行數:14,代碼來源:interpreter_test.py

示例9: test_update_complex_args_append_element

# 需要導入模塊: from ansibledebugger.interpreter.simple_interpreter import Interpreter [as 別名]
# 或者: from ansibledebugger.interpreter.simple_interpreter.Interpreter import do_update [as 別名]
    def test_update_complex_args_append_element(self, mock_stdout):
        complex_args = {'key1': ['v1', 'v2']}
        interpreter = Interpreter(TaskInfo('', '', None, complex_args),
                                  ErrorInfo(), None)

        key = 'key1[2]'
        value = 'v3'
        with patch('__builtin__.raw_input', side_effect=['']):
            interpreter.do_update('complex_args %s: %s' % (key, value))

        expect = {'key1': ['v1', 'v2', 'v3']}
        self.assertEqual(interpreter.task_info.complex_args, expect)
開發者ID:logic855,項目名稱:ansible-playbook-debugger,代碼行數:14,代碼來源:interpreter_test.py


注:本文中的ansibledebugger.interpreter.simple_interpreter.Interpreter.do_update方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。