Exemplo n.º 1
0
    def test_create_host_instance(self):

        host = smoker_client.Host('%s:8086' % self.hostname)
        assert host.url == 'http://%s:8086' % self.hostname
        assert not host.links

        host = smoker_client.Host('%s' % self.hostname)
        assert host.url == 'http://%s:8086' % self.hostname
        assert not host.links
Exemplo n.º 2
0
 def test_load_about_before_open_resource(self):
     # Mock: http://${hostname}:8089/  load_about
     # Mock: http://${hostname}:8089/plugins  open(resource='plugins')
     host = smoker_client.Host('%s:8086' % self.hostname)
     assert not host.open(resource='plugins')
     host.load_about()
     assert host.open(resource='plugins')
Exemplo n.º 3
0
 def test_load_about(self):
     # Mock: http://${hostname}:8089/  load_about
     host = smoker_client.Host('%s:8086' % self.hostname)
     assert not host.links
     assert host.load_about() == client_mock_result.about_response
     assert host.links == client_mock_result.links
     assert host.name == client_mock_result.about_response['about']['host']
Exemplo n.º 4
0
 def test_force_run_with_invalid_plugin_name(self):
     # Mock: http://${hostname}:8089/  load_about
     # Mock: http://${hostname}:8089/processes  open(resource='processes')
     host = smoker_client.Host('%s:8086' % self.hostname)
     host.load_about()
     plugins = {'InvalidPlugin': dict()}
     assert host.force_run(plugins) is False
     assert host.get_result() == client_mock_result.about_response
Exemplo n.º 5
0
 def test_force_run(self):
     # Mock: http://${hostname}:8089/  load_about
     # Mock: http://${hostname}:8089/processes  open(resource='processes')
     # Mock: http://${hostname}:8089/processes/#  open(uri='/processes/#')
     expected = client_mock_result.force_plugin_run_response['Uptime']
     host = smoker_client.Host('%s:8086' % self.hostname)
     host.load_about()
     plugins = {'Uptime': dict()}
     assert host.force_run(plugins)['plugins']['items'][0] == expected
Exemplo n.º 6
0
 def test_open_with_invalid_uri_and_resource(self):
     # Mock: http://${hostname}:8089/  load_about
     # Mock: http://${hostname}:8089/InvalidUri  open(uri='/InvalidUri')
     # Mock: http://${hostname}:8089/InvalidResource
     #   open(resource='InvalidResource')
     expected_exc = 'Argument uri or resource have to be submitted'
     host = smoker_client.Host('%s:8086' % self.hostname)
     host.load_about()
     assert not host.open(uri='/InvalidUri')
     assert not host.open(resource='InvalidResource')
     with pytest.raises(Exception) as exc_info:
         host.open()
     assert expected_exc in repr(exc_info.value)
Exemplo n.º 7
0
 def test_result_will_be_cleared_after_getting(self):
     # Mock: http://${hostname}:8089/  load_about
     host = smoker_client.Host('%s:8086' % self.hostname)
     host.load_about()
     assert host.get_result() == client_mock_result.about_response
     assert not host.get_result()