def test_get_deployment_raises_not_found_api_exception(mocker, k8s_api_client_mock: K8SAPIClient): mocker.patch.object(k8s_api_client_mock.apps_api_client, 'read_namespaced_deployment').side_effect = \ ApiException(status=HTTPStatus.NOT_FOUND) deployment = k8s_api_client_mock.get_deployment(name='fake-name', namespace=MY_FAKE_NAMESPACE) assert deployment is None
def test_get_deployment(mocker, k8s_api_client_mock: K8SAPIClient): fake_deployment = k8s_models.V1Deployment(metadata=k8s_models.V1ObjectMeta(name='fake-deployment')) mocker.patch.object(k8s_api_client_mock.apps_api_client, 'read_namespaced_deployment').return_value = \ fake_deployment deployment = k8s_api_client_mock.get_deployment(name='fake-name', namespace=MY_FAKE_NAMESPACE) assert deployment == fake_deployment
def test_get_deployment_raises_other_api_exception(mocker, k8s_api_client_mock: K8SAPIClient): mocker.patch.object(k8s_api_client_mock.apps_api_client, 'read_namespaced_deployment').side_effect = \ ApiException(status=HTTPStatus.INTERNAL_SERVER_ERROR) with raises(ApiException): k8s_api_client_mock.get_deployment(name='fake-name', namespace=MY_FAKE_NAMESPACE)