-
Notifications
You must be signed in to change notification settings - Fork 2
fixed issue #14 : Improve handling of jobs being deleted #15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It seems to me, that your test should be located in the |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
|
|
||
| import datetime | ||
| from unittest.mock import MagicMock, patch | ||
|
|
||
| import pytest | ||
| from kubernetes.client import V1PodList | ||
|
|
||
| from pygeoapi_k8s_manager.finalizer import KubernetesFinalizerController | ||
|
|
||
| @pytest.fixture() | ||
| def finalizer(): | ||
| return KubernetesFinalizerController("") | ||
|
|
||
| def test_handle_job_ended_event_handles_deleted_job(finalizer): | ||
| finalizer.is_upload_logs_to_s3 = False | ||
| k8s_core_api = MagicMock() | ||
| k8s_core_api.list_namespaced_pod.return_value = V1PodList(items=[]) | ||
|
|
||
| test_job = MagicMock() | ||
| test_job.metadata.name = "test-job" | ||
| test_job.metadata.deletion_timestamp = datetime.datetime.now() | ||
|
|
||
| with ( | ||
| patch( | ||
| "pygeoapi_k8s_manager.finalizer.KubernetesFinalizerController.upload_logs_to_s3" | ||
| ) as mocked_upload_logs_to_s3, | ||
| patch("pygeoapi_k8s_manager.util.get_logs_for_pod") as mocked_get_logs_for_pod, | ||
| ): | ||
| finalizer.handle_job_ended_event( | ||
| k8s_core_api=k8s_core_api, | ||
| job=test_job, | ||
| ) | ||
|
|
||
| mocked_get_logs_for_pod.assert_not_called() | ||
| mocked_upload_logs_to_s3.assert_not_called() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please move your new if out of the existing one. I think, having it before line 168 is better.
What do you think?