def test_pods(monkeypatch, kwargs, filter_kwargs, res):
    client_mock(monkeypatch)
    get_resources = get_resources_mock(res)

    pod = MagicMock()
    query = pod.objects.return_value.filter.return_value

    monkeypatch.setattr(
        'zmon_worker_monitor.builtins.plugins.kubernetes.KubernetesWrapper._get_resources', get_resources)
    monkeypatch.setattr('pykube.Pod', pod)

    k = KubernetesWrapper()

    pods = k.pods(**kwargs)

    assert [r.obj for r in res] == pods

    get_resources.assert_called_with(query)
    pod.objects.return_value.filter.assert_called_with(**filter_kwargs)
Esempio n. 2
0
def test_pods(monkeypatch, kwargs, filter_kwargs, res):
    client_mock(monkeypatch)
    get_resources = get_resources_mock(res)

    pod = MagicMock()
    query = pod.objects.return_value.filter.return_value

    monkeypatch.setattr(
        'zmon_worker_monitor.builtins.plugins.kubernetes.KubernetesWrapper._get_resources',
        get_resources)
    monkeypatch.setattr('pykube.Pod', pod)

    k = KubernetesWrapper()

    pods = k.pods(**kwargs)

    assert [r.obj for r in res] == pods

    get_resources.assert_called_with(query)
    pod.objects.return_value.filter.assert_called_with(**filter_kwargs)
Esempio n. 3
0
def test_pods_error(monkeypatch, kwargs):
    k = KubernetesWrapper()

    with pytest.raises(CheckError):
        k.pods(**kwargs)
def test_pods_error(monkeypatch, kwargs):
    k = KubernetesWrapper()

    with pytest.raises(CheckError):
        k.pods(**kwargs)
Esempio n. 5
0
def test_pods_error(kwargs):
    k = KubernetesWrapper(check_id='<test>')

    with pytest.raises(CheckError):
        k.pods(**kwargs)