import mock
import unittest

from cumulusci.core.config import ServiceConfig
from cumulusci.core.config import TaskConfig
from cumulusci.tasks.release_notes.task import GithubReleaseNotes
from cumulusci.tests.util import create_project_config


class TestGithubReleaseNotes(unittest.TestCase):
    @mock.patch("cumulusci.tasks.release_notes.task.GithubReleaseNotesGenerator")
    def test_run_task(self, GithubReleaseNotesGenerator):
        generator = mock.Mock(return_value="notes")
        GithubReleaseNotesGenerator.return_value = generator
        project_config = create_project_config()
        project_config.keychain.set_service(
            "github",
            ServiceConfig(
                {
                    "username": "TestUser",
                    "password": "TestPass",
                    "email": "testuser@testdomain.com",
                }
            ),
        )
        task_config = TaskConfig({"options": {"tag": "release/1.0"}})
        task = GithubReleaseNotes(project_config, task_config)
        task.github = mock.Mock()
        task.get_repo = mock.Mock()
        task()
        generator.assert_called_once()

import mock
from cumulusci.core.config import TaskConfig
from cumulusci.core.config import ServiceConfig
from cumulusci.tests.util import create_project_config
from cumulusci.tasks.release_notes.task import GithubReleaseNotes
from cumulusci.tasks.release_notes.task import ParentPullRequestNotes


@mock.patch("cumulusci.tasks.release_notes.task.GithubReleaseNotesGenerator")
def test_run_task(GithubReleaseNotesGenerator):
    generator = mock.Mock(return_value="notes")
    GithubReleaseNotesGenerator.return_value = generator
    project_config = create_project_config()
    project_config.keychain.set_service(
        "github",
        ServiceConfig(
            {
                "username": "TestUser",
                "password": "TestPass",
                "email": "testuser@testdomain.com",
            }
        ),
    )
    task_config = TaskConfig({"options": {"tag": "release/1.0"}})
    task = GithubReleaseNotes(project_config, task_config)
    task.github = mock.Mock()
    task.get_repo = mock.Mock()
    task()
    generator.assert_called_once()


def test_run_parent_pull_request_notes_task():
    pass

remove unittest