import mock
import unittest

from cumulusci.core.config import ServiceConfig
from cumulusci.core.config import TaskConfig
from cumulusci.tasks.github import PullRequests
from cumulusci.tests.util import create_project_config


@mock.patch("cumulusci.tasks.github.base.get_github_api_for_user", mock.Mock())
class TestPullRequests(unittest.TestCase):
    project_config = create_project_config()
    project_config.keychain.set_service(
        "github",
        ServiceConfig(
            {
                "username": "TestUser",
                "password": "TestPass",
                "email": "testuser@testdomain.com",
            }
        ),
    )
    task_config = TaskConfig()
    task = PullRequests(project_config, task_config)
    repo = mock.Mock()
    repo.pull_requests.return_value = [mock.Mock(number=1, title="Test PR")]
    task.get_repo = mock.Mock(return_value=repo)
    task.logger = mock.Mock()
    task()
    task.logger.info.assert_called_with("#1: Test PR")

import mock
import unittest

from cumulusci.core.config import ServiceConfig
from cumulusci.core.config import TaskConfig
from cumulusci.tasks.github import PullRequests
from cumulusci.tests.util import create_project_config


class TestPullRequests(unittest.TestCase):
    def test_run_task(self):
        project_config = create_project_config()
        project_config.keychain.set_service(
            "github",
            ServiceConfig(
                {
                    "username": "TestUser",
                    "password": "TestPass",
                    "email": "testuser@testdomain.com",
                }
            ),
        )
        task_config = TaskConfig()
        task = PullRequests(project_config, task_config)
        repo = mock.Mock()
        repo.pull_requests.return_value = [mock.Mock(number=1, title="Test PR")]
        task.get_repo = mock.Mock(return_value=repo)
        task.logger = mock.Mock()
        task()
        task.logger.info.assert_called_with("#1: Test PR")

Fix test that wasn't running
Fix test that wasn't running

  import mock
  import unittest
  
  from cumulusci.core.config import ServiceConfig
  from cumulusci.core.config import TaskConfig
  from cumulusci.tasks.github import PullRequests
  from cumulusci.tests.util import create_project_config
  
  
- @mock.patch("cumulusci.tasks.github.base.get_github_api_for_user", mock.Mock())
  class TestPullRequests(unittest.TestCase):
+     def test_run_task(self):
-     project_config = create_project_config()
+         project_config = create_project_config()
-     project_config.keychain.set_service(
+         project_config.keychain.set_service(
-         "github",
+             "github",
-         ServiceConfig(
+             ServiceConfig(
-             {
+                 {
-                 "username": "TestUser",
+                     "username": "TestUser",
-                 "password": "TestPass",
+                     "password": "TestPass",
-                 "email": "testuser@testdomain.com",
+                     "email": "testuser@testdomain.com",
+                 }
-             }
+             ),
-         ),
+         )
-     )
-     task_config = TaskConfig()
+         task_config = TaskConfig()
-     task = PullRequests(project_config, task_config)
+         task = PullRequests(project_config, task_config)
-     repo = mock.Mock()
+         repo = mock.Mock()
-     repo.pull_requests.return_value = [mock.Mock(number=1, title="Test PR")]
+         repo.pull_requests.return_value = [mock.Mock(number=1, title="Test PR")]
-     task.get_repo = mock.Mock(return_value=repo)
+         task.get_repo = mock.Mock(return_value=repo)
-     task.logger = mock.Mock()
+         task.logger = mock.Mock()
-     task()
+         task()
-     task.logger.info.assert_called_with("#1: Test PR")
+         task.logger.info.assert_called_with("#1: Test PR")
  
Fix test that wasn't running
## Code Before:
import mock
import unittest

from cumulusci.core.config import ServiceConfig
from cumulusci.core.config import TaskConfig
from cumulusci.tasks.github import PullRequests
from cumulusci.tests.util import create_project_config


@mock.patch("cumulusci.tasks.github.base.get_github_api_for_user", mock.Mock())
class TestPullRequests(unittest.TestCase):
    project_config = create_project_config()
    project_config.keychain.set_service(
        "github",
        ServiceConfig(
            {
                "username": "TestUser",
                "password": "TestPass",
                "email": "testuser@testdomain.com",
            }
        ),
    )
    task_config = TaskConfig()
    task = PullRequests(project_config, task_config)
    repo = mock.Mock()
    repo.pull_requests.return_value = [mock.Mock(number=1, title="Test PR")]
    task.get_repo = mock.Mock(return_value=repo)
    task.logger = mock.Mock()
    task()
    task.logger.info.assert_called_with("#1: Test PR")

## Instruction:
Fix test that wasn't running
## Code After:
import mock
import unittest

from cumulusci.core.config import ServiceConfig
from cumulusci.core.config import TaskConfig
from cumulusci.tasks.github import PullRequests
from cumulusci.tests.util import create_project_config


class TestPullRequests(unittest.TestCase):
    def test_run_task(self):
        project_config = create_project_config()
        project_config.keychain.set_service(
            "github",
            ServiceConfig(
                {
                    "username": "TestUser",
                    "password": "TestPass",
                    "email": "testuser@testdomain.com",
                }
            ),
        )
        task_config = TaskConfig()
        task = PullRequests(project_config, task_config)
        repo = mock.Mock()
        repo.pull_requests.return_value = [mock.Mock(number=1, title="Test PR")]
        task.get_repo = mock.Mock(return_value=repo)
        task.logger = mock.Mock()
        task()
        task.logger.info.assert_called_with("#1: Test PR")
