mirror of
https://github.com/OpenHands/OpenHands.git
synced 2026-03-22 13:47:19 +08:00
Co-authored-by: Engel Nyst <enyst@users.noreply.github.com>
This commit is contained in:
@@ -167,12 +167,17 @@ class IssueHandler(IssueHandlerInterface):
|
||||
|
||||
converted_issues = []
|
||||
for issue in all_issues:
|
||||
if any([issue.get(key) is None for key in ['number', 'title', 'body']]):
|
||||
# Check for required fields (number and title)
|
||||
if any([issue.get(key) is None for key in ['number', 'title']]):
|
||||
logger.warning(
|
||||
f'Skipping issue {issue} as it is missing number, title, or body.'
|
||||
f'Skipping issue {issue} as it is missing number or title.'
|
||||
)
|
||||
continue
|
||||
|
||||
# Handle empty body by using empty string
|
||||
if issue.get('body') is None:
|
||||
issue['body'] = ''
|
||||
|
||||
# Get issue thread comments
|
||||
thread_comments = self._get_issue_comments(
|
||||
issue['number'], comment_id=comment_id
|
||||
|
||||
@@ -46,6 +46,48 @@ def test_get_converted_issues_initializes_review_comments():
|
||||
assert issues[0].repo == 'test-repo'
|
||||
|
||||
|
||||
def test_get_converted_issues_handles_empty_body():
|
||||
# Mock the necessary dependencies
|
||||
with patch('requests.get') as mock_get:
|
||||
# Mock the response for issues
|
||||
mock_issues_response = MagicMock()
|
||||
mock_issues_response.json.return_value = [
|
||||
{'number': 1, 'title': 'Test Issue', 'body': None}
|
||||
]
|
||||
# Mock the response for comments
|
||||
mock_comments_response = MagicMock()
|
||||
mock_comments_response.json.return_value = []
|
||||
|
||||
# Set up the mock to return different responses
|
||||
mock_get.side_effect = [
|
||||
mock_issues_response,
|
||||
mock_comments_response,
|
||||
mock_comments_response,
|
||||
]
|
||||
|
||||
# Create an instance of IssueHandler
|
||||
llm_config = LLMConfig(model='test', api_key='test')
|
||||
handler = IssueHandler('test-owner', 'test-repo', 'test-token', llm_config)
|
||||
|
||||
# Get converted issues
|
||||
issues = handler.get_converted_issues(issue_numbers=[1])
|
||||
|
||||
# Verify that we got exactly one issue
|
||||
assert len(issues) == 1
|
||||
|
||||
# Verify that body is empty string when None
|
||||
assert issues[0].body == ''
|
||||
|
||||
# Verify other fields are set correctly
|
||||
assert issues[0].number == 1
|
||||
assert issues[0].title == 'Test Issue'
|
||||
assert issues[0].owner == 'test-owner'
|
||||
assert issues[0].repo == 'test-repo'
|
||||
|
||||
# Verify that review_comments is initialized as None
|
||||
assert issues[0].review_comments is None
|
||||
|
||||
|
||||
def test_pr_handler_get_converted_issues_with_comments():
|
||||
# Mock the necessary dependencies
|
||||
with patch('requests.get') as mock_get:
|
||||
|
||||
Reference in New Issue
Block a user