def test_send_pull_request_invalid_target_branch(
    mock_get, mock_issue, mock_output_dir, mock_llm_config
):
    """Test that an error is raised when specifying a non-existent target branch"""
    repo_path = os.path.join(mock_output_dir, 'repo')

    # Mock API response for non-existent branch
    mock_get.side_effect = [
        MagicMock(status_code=404),  # Branch doesn't exist
        MagicMock(status_code=404),  # Target branch doesn't exist
    ]

    # Test that ValueError is raised when target branch doesn't exist
    with pytest.raises(
        ValueError, match='Target branch nonexistent-branch does not exist'
    ):
        send_pull_request(
            issue=mock_issue,
            token='test-token',
            username='test-user',
            platform=ProviderType.GITHUB,
            patch_dir=repo_path,
            pr_type='ready',
            target_branch='nonexistent-branch',
        )

    # Verify API calls
    assert mock_get.call_count == 2
Test that an error is raised when specifying a non-existent target branch
tests/unit/resolver/github/test_send_pull_request.py