Fix TestJiraLink unit tests failing with HTTP 503#4699
Open
vaibhavdaren wants to merge 2 commits intomainfrom
Open
Fix TestJiraLink unit tests failing with HTTP 503#4699vaibhavdaren wants to merge 2 commits intomainfrom
vaibhavdaren wants to merge 2 commits intomainfrom
Conversation
The three TestJiraLink tests were making real network requests to https://issues.redhat.com/rest/api/2/serverInfo because the jira.JIRA() constructor validates the connection on init. Only add_simple_link was mocked, so the constructor hit the live server and failed with 503. Fix by mocking the entire jira.JIRA class instead of only add_simple_link. This prevents the constructor from making any network call and fully isolates the tests from the network. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Move the repeated @patch decorators from each test method to the class level. All three tests share the same two mocks, so applying them once at the class level reduces duplication and makes it easier to add new tests in the future. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Code Review
This pull request fixes failing unit tests by mocking the jira.JIRA class to prevent network requests during test initialization. My review includes a suggestion to refactor repeated mock decorators to the class level for improved code clarity and maintainability.
5de2db6 to
34ed888
Compare
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
The three TestJiraLink tests were making real network requests to https://issues.redhat.com/rest/api/2/serverInfo because the jira.JIRA() constructor validates the connection on init. Only add_simple_link was mocked, so the constructor hit the live server and failed with 503.
Fix by mocking the entire jira.JIRA class instead of individual methods. This prevents the constructor from running at all, fully isolates the tests from the network, and removes the need for a separate init mock.
Tests on pull request were failing :