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


Python PropertyMock.livestatus_socket方法代码示例

本文整理汇总了Python中mock.PropertyMock.livestatus_socket方法的典型用法代码示例。如果您正苦于以下问题:Python PropertyMock.livestatus_socket方法的具体用法?Python PropertyMock.livestatus_socket怎么用?Python PropertyMock.livestatus_socket使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在mock.PropertyMock的用法示例。


在下文中一共展示了PropertyMock.livestatus_socket方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test

# 需要导入模块: from mock import PropertyMock [as 别名]
# 或者: from mock.PropertyMock import livestatus_socket [as 别名]
 def test(self, get_config):
     mock_configuration = PropertyMock()
     mock_configuration.livestatus_socket = './livestatus_socket'
     get_config.return_value = mock_configuration
     with LiveServer() as liveserver:
         with LiveSocket('./livestatus_socket', '{}') as livesocket:
             result = urlopen('{0}cmd?q=DISABLE_HOST_NOTIFICATIONS;devica01'.format(liveserver.url))
             self.assertEqual(result.read(), b'OK\n')
             written_to_socket = livesocket.incoming.get()
             self.assertTrue('DISABLE_HOST_NOTIFICATIONS;devica01' in written_to_socket)
开发者ID:ImmobilienScout24,项目名称:livestatus_service,代码行数:12,代码来源:should_respond_ok_and_write_to_livestatus_socket_when_command_is_posted_tests.py

示例2: test

# 需要导入模块: from mock import PropertyMock [as 别名]
# 或者: from mock.PropertyMock import livestatus_socket [as 别名]
 def test(self, get_config):
     mock_configuration = PropertyMock()
     mock_configuration.livestatus_socket = './livestatus_socket'
     get_config.return_value = mock_configuration
     with LiveServer() as liveserver:
         socket_response = '[["host_name","notifications_enabled"],["devica01", 1], ["tuvdbs05",1], ["tuvdbs06",1]]'
         with LiveSocket('./livestatus_socket', socket_response) as livesocket:
             api_call_result = urlopen('{0}query?q=GET%20hosts&key=host_name'.format(liveserver.url))
             actual_api_response = json.loads(api_call_result.read().decode('utf-8'))
             self.assertEqual(expected_api_call_response, actual_api_response)
             written_to_socket = livesocket.incoming.get()
             self.assertTrue('GET hosts' in written_to_socket and 'OutputFormat: json' in written_to_socket)
开发者ID:ImmobilienScout24,项目名称:livestatus_service,代码行数:14,代码来源:should_parse_socket_output_when_query_with_key_is_executed_tests.py

示例3: test

# 需要导入模块: from mock import PropertyMock [as 别名]
# 或者: from mock.PropertyMock import livestatus_socket [as 别名]
 def test(self, get_config):
     mock_configuration = PropertyMock()
     mock_configuration.livestatus_socket = "./livestatus_socket"
     get_config.return_value = mock_configuration
     with LiveServer() as liveserver:
         socket_response = '[["host_name","notifications_enabled"],["devica01", 1], ["tuvdbs05",1], ["tuvdbs06",1]]'
         with LiveSocket("./livestatus_socket", socket_response) as livesocket:
             api_call_result = urlopen("{0}query?q=GET%20hosts".format(liveserver.url))
             actual_result = json.loads(api_call_result.read().decode("utf-8"))
             expected_result = json.loads(expected_api_call_response)
             diff = [element for element in actual_result if element not in expected_result]
             diff.extend([element for element in expected_result if element not in actual_result])
             self.assertEqual(diff, [], "Found difference between expected and actual result : %s" % diff)
             written_to_socket = livesocket.incoming.get()
             self.assertTrue("GET hosts" in written_to_socket and "OutputFormat: json" in written_to_socket)
开发者ID:jfrome,项目名称:livestatus_service,代码行数:17,代码来源:should_parse_socket_output_when_query_is_executed_tests.py

示例4: test

# 需要导入模块: from mock import PropertyMock [as 别名]
# 或者: from mock.PropertyMock import livestatus_socket [as 别名]
    def test(self, get_config):
        mock_configuration = PropertyMock()
        mock_configuration.livestatus_socket = './livestatus_socket'
        get_config.return_value = mock_configuration
        with LiveServer() as liveserver:
            with LiveSocket('./livestatus_socket', '{}') as livesocket:

                url = '{0}cmd'.format(liveserver.url)
                parameters = {'q': 'DISABLE_HOST_NOTIFICATIONS;devica01',
                              }
                data = urlencode(parameters)
                binary_data = data.encode('utf-8')
                request = Request(url, binary_data)
                response = urlopen(request)
                self.assertEquals(response.read(), b'OK\n')
                written_to_socket = livesocket.incoming.get()
                self.assertTrue('DISABLE_HOST_NOTIFICATIONS;devica01' in written_to_socket)
开发者ID:tklein,项目名称:livestatus_service,代码行数:19,代码来源:should_respond_ok_and_write_to_livestatus_socket_when_command_is_executed_tests.py


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