-
Notifications
You must be signed in to change notification settings - Fork 0
Fix job deletion error handling with specific JobDeletedException #69
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
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
041c5df
Initial plan
Copilot 0292e99
Initial investigation and plan
Copilot c0fecca
Implement JobDeletedException for more specific error handling
Copilot 770caf8
Add comprehensive tests for JobDeletedException handling
Copilot f080579
Address PR feedback: simplify JobDeletedException and remove unnecess…
Copilot be40e30
Move test_update_job_raises_job_deleted_exception to tests/unit/crud/…
Copilot b9e2665
Address PR feedback: improve exception handling and error messages
Copilot 0c8753f
Fix import organization in test_job_tracking.py for mypy compliance
Copilot f50b3ad
happy type checking
nolan1999 1d02012
happy mypy?
nolan1999 31010b2
fix error catch
nolan1999 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| # Empty init file |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| """Tests for job_tracking module.""" | ||
|
|
||
| from unittest.mock import MagicMock, patch | ||
|
|
||
| import pytest | ||
|
|
||
| from workerfacing_api.crud.job_tracking import update_job | ||
| from workerfacing_api.exceptions import JobDeletedException | ||
| from workerfacing_api.schemas.rds_models import JobStates | ||
|
|
||
|
|
||
| @patch("workerfacing_api.crud.job_tracking.requests.put") | ||
| def test_update_job_raises_job_deleted_exception(mock_put: MagicMock) -> None: | ||
| """Test that update_job raises JobDeletedException on 404 response.""" | ||
| # Mock a 404 response | ||
| mock_response = MagicMock() | ||
| mock_response.status_code = 404 | ||
| mock_put.return_value = mock_response | ||
|
|
||
| job_id = 789 | ||
|
|
||
| with pytest.raises(JobDeletedException) as exc_info: | ||
| update_job(job_id, JobStates.running) | ||
|
|
||
| assert f"Job {job_id} not found; it was probably deleted by the user." in str( | ||
| exc_info.value | ||
| ) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| """Custom exceptions for the workerfacing API.""" | ||
|
|
||
|
|
||
| class JobDeletedException(Exception): | ||
nolan1999 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| """Exception raised when a job has been deleted by the user.""" | ||
|
|
||
| pass | ||
|
|
||
|
|
||
| class JobNotAssignedException(Exception): | ||
| """Exception raised when a job is not assigned to the current user.""" | ||
|
|
||
| pass | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.