def test_deployments(monkeypatch, kwargs, filter_kwargs, res): client_mock(monkeypatch) get_resources = get_resources_mock(res) deployment = MagicMock() query = deployment.objects.return_value.filter.return_value monkeypatch.setattr( 'zmon_worker_monitor.builtins.plugins.kubernetes.KubernetesWrapper._get_resources', get_resources) monkeypatch.setattr('pykube.Deployment', deployment) k = KubernetesWrapper() deployments = k.deployments(**kwargs) assert [r.obj for r in res] == deployments get_resources.assert_called_with(query) deployment.objects.return_value.filter.assert_called_with(**filter_kwargs)
def test_deployments(monkeypatch, kwargs, filter_kwargs, res): client_mock(monkeypatch) get_resources = get_resources_mock(res) deployment = MagicMock() query = deployment.objects.return_value.filter.return_value monkeypatch.setattr( 'zmon_worker_monitor.builtins.plugins.kubernetes.KubernetesWrapper._get_resources', get_resources) monkeypatch.setattr('pykube.Deployment', deployment) k = KubernetesWrapper() deployments = k.deployments(**kwargs) assert [r.obj for r in res] == deployments get_resources.assert_called_with(query) deployment.objects.return_value.filter.assert_called_with(**filter_kwargs)
def test_deployments_error(monkeypatch, kwargs): k = KubernetesWrapper() with pytest.raises(CheckError): k.deployments(**kwargs)
def test_deployments_error(monkeypatch, kwargs): k = KubernetesWrapper() with pytest.raises(CheckError): k.deployments(**kwargs)
def test_deployments_error(kwargs): k = KubernetesWrapper(check_id='<test>') with pytest.raises(CheckError): k.deployments(**kwargs)