def test_read_cluster_value_exit(mock_get): response = mock.Mock(status_code=404, spec=requests.Response) request = mock_get.return_value request.result.return_value = response with pytest.raises(SystemExit): p, b = main.read_cluster_status(["host1"], 80, "jolokia")
def test_read_cluster_value_server_down(mock_get): request = mock_get.return_value request.result.side_effect = RequestException p, b = main.read_cluster_status(["host1"], 80, "jolokia") assert p == 0 # 0 missing partitions assert b == 1 # 1 missing brokers
def test_read_cluster_value_server_down(mock_get): request = mock_get.return_value request.result.side_effect = RequestException p, b = main.read_cluster_status(["host1"], 80, "jolokia") assert p == 0 # 0 missing partitions assert b == 1 # 1 missing brokers
def test_read_cluster_value_exit(mock_get): response = mock.Mock(status_code=404, spec=requests.Response) request = mock_get.return_value request.result.return_value = response with pytest.raises(SystemExit): p, b = main.read_cluster_status(["host1"], 80, "jolokia")
def test_read_cluster_value_no_key(mock_get): response = mock.Mock(status_code=200, spec=requests.Response) response.json.return_value = {'wrong_key': 1} request = mock_get.return_value request.result.return_value = response p, b = main.read_cluster_status(["host1"], 80, "jolokia") assert p == 0 # 0 missing partitions assert b == 1 # 1 missing brokers
def test_read_cluster_value_no_key(mock_get): response = mock.Mock(status_code=200, spec=requests.Response) response.json.return_value = {'wrong_key': 1} request = mock_get.return_value request.result.return_value = response p, b = main.read_cluster_status(["host1"], 80, "jolokia") assert p == 0 # 0 missing partitions assert b == 1 # 1 missing brokers
def test_read_cluster_value_partitions(mock_get): response = mock.Mock(status_code=200, spec=requests.Response) response.json.return_value = {'value': 1} request = mock_get.return_value request.result.return_value = response p, b = main.read_cluster_status(["host1", "host2", "host3"], 80, "jmxproxy") assert p == 3 # 3 missing partitions assert b == 0 # 0 missing brokers