# Path: hotness/config.py
# DEFAULTS = dict(
#     # PDC URL
#     pdc_url="https://pdc.fedoraproject.org",
#     # dist-git URL
#     dist_git_url="https://src.fedoraproject.org",
#     # mdapi URL
#     mdapi_url="https://apps.fedoraproject.org/mdapi",
#     # hotness issue tracker URL
#     hotness_issue_tracker="https://github.com/fedora-infra/the-new-hotness/issues",
#     # Repository id
#     repoid="rawhide",
#     # Distribution
#     distro="Fedora",
#     # The time in seconds the-new-hotness should wait for a socket to connect
#     # before giving up.
#     connect_timeout=15,
#     # The time in seconds the-new-hotness should wait for a read from a socket
#     # before giving up.
#     read_timeout=15,
#     # The number of times the-new-hotness should retry a network request
#     # that failed for any reason (e.g. read timeout, DNS error, etc)
#     requests_retries=3,
#     # Bugzilla configuration
#     bugzilla=dict(
#         enabled=True,
#         url="https://partner-bugzilla.redhat.com",
#         api_key="",
#         product="Fedora",
#         version="rawhide",
#         keywords="FutureFeature, Triaged",
#         bug_status="NEW",
#         explanation_url="https://fedoraproject.org/wiki/upstream_release_monitoring",
#         reporter="Upstream Release Monitoring",
#         reporter_email="upstream-release-monitoring@fedoraproject.org",
#         short_desc_template="%(name)s-%(latest_upstream)s is available",
#         description_template="""
# Latest upstream release: %(latest_upstream)s
# 
# Current version/release in %(repo_name)s: %(repo_version)s-%(repo_release)s
# 
# URL: %(url)s
# 
# 
#     Please consult the package updates policy before you
# issue an update to a stable branch:
#     https://docs.fedoraproject.org/en-US/fesco/Updates_Policy
# 
# 
# More information about the service that created this bug can be found at:
# 
#     %(explanation_url)s
# 
# 
#     Please keep in mind that with any upstream change, there may also be packaging
#     changes that need to be made. Specifically, please remember that it is your
#     responsibility to review the new version to ensure that the licensing is still
#     correct and that no non-free or legally problematic items have been added
#     upstream.
# 
# Based on the information from anitya: https://release-monitoring.org/project/%(projectid)s/
# """,
#     ),
#     # Koji configuration
#     koji=dict(
#         server="https://koji.fedoraproject.org/kojihub",
#         weburl="https://koji.fedoraproject.org/koji",
#         # Kerberos configuration to authenticate with Koji. In development
#         # environments, use `kinit <fas-name>@FEDORAPROJECT.ORG` to get a
#         # Kerberos ticket and use the default settings below.
#         krb_principal="",
#         krb_keytab="",
#         krb_ccache="",
#         krb_proxyuser="",
#         krb_sessionopts=dict(timeout=3600, krb_rdns=False),
#         git_url="https://src.fedoraproject.org/cgit/rpms/{package}.git",
#         user_email=[
#             "Upstream Monitor",
#             "<upstream-release-monitoring@fedoraproject.org>",
#         ],
#         opts=dict(scratch=True),
#         priority=30,
#         target_tag="rawhide",
#     ),
# )
# def _load_dict(config_dict: dict, defaults: dict) -> dict:
# def load(config_dict: dict) -> dict:


import unittest
from hotness import config as hotness_config
empty_dict_config = {"consumer_config": {"bugzilla": {}}}

bad_config = {"consumer_config": {"example_key": "value"}}


class TestLoad(unittest.TestCase):
    """
    Class for testing the `hotness.config.load` function.
    """

    maxDiff = None

    def test_load_full_config(self):
        """
        Assert that config will be changed when correct dictionary is provided.
        """
        config = hotness_config.load(full_config)
        self.assertEqual(config, full_config["consumer_config"])

    def test_load_empty_config(self):
        """
        Assert that default values will be used when empty dictionary is provided.
        """
        config = hotness_config.load(empty_config)
        self.assertEqual(config, hotness_config.DEFAULTS)

    def test_load_empty_inner_dict(self):
        """
        Assert that default values will be used when empty inner dictionary is provided.
        """

# Path: hotness/config.py
# DEFAULTS = dict(
#     # PDC URL
#     pdc_url="https://pdc.fedoraproject.org",
#     # dist-git URL
#     dist_git_url="https://src.fedoraproject.org",
#     # mdapi URL
#     mdapi_url="https://apps.fedoraproject.org/mdapi",
#     # hotness issue tracker URL
#     hotness_issue_tracker="https://github.com/fedora-infra/the-new-hotness/issues",
#     # Repository id
#     repoid="rawhide",
#     # Distribution
#     distro="Fedora",
#     # The time in seconds the-new-hotness should wait for a socket to connect
#     # before giving up.
#     connect_timeout=15,
#     # The time in seconds the-new-hotness should wait for a read from a socket
#     # before giving up.
#     read_timeout=15,
#     # The number of times the-new-hotness should retry a network request
#     # that failed for any reason (e.g. read timeout, DNS error, etc)
#     requests_retries=3,
#     # Bugzilla configuration
#     bugzilla=dict(
#         enabled=True,
#         url="https://partner-bugzilla.redhat.com",
#         api_key="",
#         product="Fedora",
#         version="rawhide",
#         keywords="FutureFeature, Triaged",
#         bug_status="NEW",
#         explanation_url="https://fedoraproject.org/wiki/upstream_release_monitoring",
#         reporter="Upstream Release Monitoring",
#         reporter_email="upstream-release-monitoring@fedoraproject.org",
#         short_desc_template="%(name)s-%(latest_upstream)s is available",
#         description_template="""
# Latest upstream release: %(latest_upstream)s
# 
# Current version/release in %(repo_name)s: %(repo_version)s-%(repo_release)s
# 
# URL: %(url)s
# 
# 
#     Please consult the package updates policy before you
# issue an update to a stable branch:
#     https://docs.fedoraproject.org/en-US/fesco/Updates_Policy
# 
# 
# More information about the service that created this bug can be found at:
# 
#     %(explanation_url)s
# 
# 
#     Please keep in mind that with any upstream change, there may also be packaging
#     changes that need to be made. Specifically, please remember that it is your
#     responsibility to review the new version to ensure that the licensing is still
#     correct and that no non-free or legally problematic items have been added
#     upstream.
# 
# Based on the information from anitya: https://release-monitoring.org/project/%(projectid)s/
# """,
#     ),
#     # Koji configuration
#     koji=dict(
#         server="https://koji.fedoraproject.org/kojihub",
#         weburl="https://koji.fedoraproject.org/koji",
#         # Kerberos configuration to authenticate with Koji. In development
#         # environments, use `kinit <fas-name>@FEDORAPROJECT.ORG` to get a
#         # Kerberos ticket and use the default settings below.
#         krb_principal="",
#         krb_keytab="",
#         krb_ccache="",
#         krb_proxyuser="",
#         krb_sessionopts=dict(timeout=3600, krb_rdns=False),
#         git_url="https://src.fedoraproject.org/cgit/rpms/{package}.git",
#         user_email=[
#             "Upstream Monitor",
#             "<upstream-release-monitoring@fedoraproject.org>",
#         ],
#         opts=dict(scratch=True),
#         priority=30,
#         target_tag="rawhide",
#     ),
# )
# def _load_dict(config_dict: dict, defaults: dict) -> dict:
# def load(config_dict: dict) -> dict:


# Path: tests/test_config.py
import unittest
from hotness import config as hotness_config

empty_dict_config = {"consumer_config": {"bugzilla": {}}}

bad_config = {"consumer_config": {"example_key": "value"}}


class TestLoad(unittest.TestCase):
    """
    Class for testing the `hotness.config.load` function.
    """

    maxDiff = None

    def test_load_full_config(self):
        """
        Assert that config will be changed when correct dictionary is provided.
        """
        config = hotness_config.load(full_config)
        self.assertEqual(config, full_config["consumer_config"])

    def test_load_empty_config(self):
        """
        Assert that default values will be used when empty dictionary is provided.
        """
        config = hotness_config.load(empty_config)
        self.assertEqual(config, hotness_config.DEFAULTS)

    def test_load_empty_inner_dict(self):
        """
        Assert that default values will be used when empty inner dictionary is provided.
        """

        config = hotness_config.load(empty_dict_config)