# Path: hotness/domain/package.py
# class Package:
#     """
#     Internal representation of package object.
# 
#     Attributes:
#         name (str): Name of the package
#         version (str): Latest version of the package
#         distro (str): Distribution assigned
#     """
# 
#     def __init__(self, name: str, version: str, distro: str) -> None:
#         """
#         Class constructor
#         """
#         self.name = name
#         self.version = version
#         self.distro = distro
# 
#     def to_dict(self) -> dict:
#         """
#         Convert object to dictionary.
# 
#         Return:
#             Dictionary created from package object.
#         """
#         return {"name": self.name, "version": self.version, "distro": self.distro}
# 
#     @classmethod
#     def from_dict(cls, package_dict: dict) -> object:
#         """
#         Convert dictionary to object.
# 
#         Params:
#             package_dict: Dictionary to create package from.
# 
#         Return:
#             Package object.
#         """
#         package = Package(
#             name=package_dict["name"],
#             version=package_dict["version"],
#             distro=package_dict["distro"],
#         )
#         return package
# 
#     def __eq__(self, other: object) -> bool:
#         """
#         Compare method for package object.
# 
#         Params:
#             other: object to compare with
# 
#         Return:
#             Compare result.
#         """
#         return self.to_dict() == other.to_dict()  # type: ignore
# 
# Path: hotness/validators/pagure.py
# class Pagure(Validator):
#     """
#     Wrapper around Pagure dist-git https://src.fedoraproject.org
# 
#     It inherits the Validator abstract class and implements the validate method.
# 
#     The Pagure wrapper is used to check if the package owner in Fedora wants to be notified
#     about new version and optionally run a scratch build.
# 
#     Attributes:
#         url: URL of the PDC server
#         requests_session: Session object which will be used for HTTP request
#         timeout: Timeouts to HTTP request in seconds (connect timeout, read timeout)
#     """
# 
#     def __init__(
#         self,
#         url: str,
#         requests_session: Session,
#         timeout: tuple,
#     ) -> None:
#         """
#         Class constructor.
#         """
#         self.url = url
#         self.requests_session = requests_session
#         self.timeout = timeout
# 
#     def validate(self, package: Package) -> dict:
#         """
#         Implementation of `Validator.validate` method. It calls the Pagure dist-git, checks if the
#         package owner wants to be monitored and returns the output.
# 
#         Params:
#             package: Package to check in Pagure
# 
#         Returns:
#             Dictionary containing output of response and validation.
#             Example:
#             {
#                 "monitoring": True,  # If the packager wants to be notified or not
#                 "scratch_build": False  # If the packager wants to run a scratch build or not
#             }
# 
#         Raises:
#             HTTPException: Is raised when HTTP status code of response isn't 200.
#         """
#         output = {"monitoring": False, "scratch_build": False}
#         dist_git_url = "{0}/_dg/anitya/rpms/{1}".format(self.url, package.name)
#         _logger.debug(
#             "Checking {} to see if {} is monitored.".format(dist_git_url, package.name)
#         )
#         response = self.requests_session.get(dist_git_url, timeout=self.timeout)
# 
#         if not response.status_code == 200:
#             raise HTTPException(
#                 response.status_code,
#                 "Error encountered on request {}".format(dist_git_url),
#             )
# 
#         data = response.json()
#         monitoring_value = data.get("monitoring", "no-monitoring")
# 
#         # Fill the output based on the monitoring value
#         # Invalid = monitoring: False; scrach_build: False
#         # monitoring-with-scratch = monitoring: True; scrach_build: True
#         # monitoring = monitoring: True; scrach_build: False
#         # no-monitoring = monitoring: False; scrach_build: False
#         if monitoring_value not in MONITORING_STATUSES:
#             _logger.info(
#                 "Unknown status '{}' recovered from {}".format(
#                     dist_git_url, monitoring_value
#                 )
#             )
# 
#         if monitoring_value == "monitoring-with-scratch":
#             output["monitoring"] = True
#             output["scratch_build"] = True
# 
#         if monitoring_value == "monitoring":
#             output["monitoring"] = True
# 
#         return output
# 
# Path: hotness/exceptions/http_exception.py
# class HTTPException(BaseHotnessException):
#     """
#     Class representing HTTP exception. This exception should be returned by any wrapper receiving
#     HTTP response when the error code is not 200.
# 
#     Attributes:
#         error_code: Error code of the response
#         message: Error message.
#     """
# 
#     def __init__(self, error_code: int, message: str):
#         """
#         Class constructor.
#         """
#         self.error_code = error_code
#         self.message = message
#         super(HTTPException, self).__init__(self.message)
# 
#     def __str__(self):
#         """
#         String representation of error.
#         """
#         return f"Error code: {self.error_code}\n" f"Error message: {self.message}"


import pytest
from unittest import mock
from hotness.domain import Package
from hotness.validators import Pagure
from hotness.exceptions import HTTPException

    def test_init(self):
        """
        Assert that Pagure class is initialized successfully.
        """
        url = "http://testing.url"
        timeout = (5, 20)
        requests_session = mock.Mock()

        validator = Pagure(url, requests_session, timeout)

        assert validator.url == url
        assert validator.requests_session == requests_session
        assert validator.timeout == timeout


class TestPagureValidate:
    """
    Test class for `hotness.validators.Pagure.validate` method.
    """

    def setup(self):
        """
        Setup phase before test.
        """
        # Initialize PDC wrapper
        url = "http://testing.url"
        timeout = (5, 20)
        requests_session = mock.Mock()


# Path: hotness/domain/package.py
# class Package:
#     """
#     Internal representation of package object.
# 
#     Attributes:
#         name (str): Name of the package
#         version (str): Latest version of the package
#         distro (str): Distribution assigned
#     """
# 
#     def __init__(self, name: str, version: str, distro: str) -> None:
#         """
#         Class constructor
#         """
#         self.name = name
#         self.version = version
#         self.distro = distro
# 
#     def to_dict(self) -> dict:
#         """
#         Convert object to dictionary.
# 
#         Return:
#             Dictionary created from package object.
#         """
#         return {"name": self.name, "version": self.version, "distro": self.distro}
# 
#     @classmethod
#     def from_dict(cls, package_dict: dict) -> object:
#         """
#         Convert dictionary to object.
# 
#         Params:
#             package_dict: Dictionary to create package from.
# 
#         Return:
#             Package object.
#         """
#         package = Package(
#             name=package_dict["name"],
#             version=package_dict["version"],
#             distro=package_dict["distro"],
#         )
#         return package
# 
#     def __eq__(self, other: object) -> bool:
#         """
#         Compare method for package object.
# 
#         Params:
#             other: object to compare with
# 
#         Return:
#             Compare result.
#         """
#         return self.to_dict() == other.to_dict()  # type: ignore
# 
# Path: hotness/validators/pagure.py
# class Pagure(Validator):
#     """
#     Wrapper around Pagure dist-git https://src.fedoraproject.org
# 
#     It inherits the Validator abstract class and implements the validate method.
# 
#     The Pagure wrapper is used to check if the package owner in Fedora wants to be notified
#     about new version and optionally run a scratch build.
# 
#     Attributes:
#         url: URL of the PDC server
#         requests_session: Session object which will be used for HTTP request
#         timeout: Timeouts to HTTP request in seconds (connect timeout, read timeout)
#     """
# 
#     def __init__(
#         self,
#         url: str,
#         requests_session: Session,
#         timeout: tuple,
#     ) -> None:
#         """
#         Class constructor.
#         """
#         self.url = url
#         self.requests_session = requests_session
#         self.timeout = timeout
# 
#     def validate(self, package: Package) -> dict:
#         """
#         Implementation of `Validator.validate` method. It calls the Pagure dist-git, checks if the
#         package owner wants to be monitored and returns the output.
# 
#         Params:
#             package: Package to check in Pagure
# 
#         Returns:
#             Dictionary containing output of response and validation.
#             Example:
#             {
#                 "monitoring": True,  # If the packager wants to be notified or not
#                 "scratch_build": False  # If the packager wants to run a scratch build or not
#             }
# 
#         Raises:
#             HTTPException: Is raised when HTTP status code of response isn't 200.
#         """
#         output = {"monitoring": False, "scratch_build": False}
#         dist_git_url = "{0}/_dg/anitya/rpms/{1}".format(self.url, package.name)
#         _logger.debug(
#             "Checking {} to see if {} is monitored.".format(dist_git_url, package.name)
#         )
#         response = self.requests_session.get(dist_git_url, timeout=self.timeout)
# 
#         if not response.status_code == 200:
#             raise HTTPException(
#                 response.status_code,
#                 "Error encountered on request {}".format(dist_git_url),
#             )
# 
#         data = response.json()
#         monitoring_value = data.get("monitoring", "no-monitoring")
# 
#         # Fill the output based on the monitoring value
#         # Invalid = monitoring: False; scrach_build: False
#         # monitoring-with-scratch = monitoring: True; scrach_build: True
#         # monitoring = monitoring: True; scrach_build: False
#         # no-monitoring = monitoring: False; scrach_build: False
#         if monitoring_value not in MONITORING_STATUSES:
#             _logger.info(
#                 "Unknown status '{}' recovered from {}".format(
#                     dist_git_url, monitoring_value
#                 )
#             )
# 
#         if monitoring_value == "monitoring-with-scratch":
#             output["monitoring"] = True
#             output["scratch_build"] = True
# 
#         if monitoring_value == "monitoring":
#             output["monitoring"] = True
# 
#         return output
# 
# Path: hotness/exceptions/http_exception.py
# class HTTPException(BaseHotnessException):
#     """
#     Class representing HTTP exception. This exception should be returned by any wrapper receiving
#     HTTP response when the error code is not 200.
# 
#     Attributes:
#         error_code: Error code of the response
#         message: Error message.
#     """
# 
#     def __init__(self, error_code: int, message: str):
#         """
#         Class constructor.
#         """
#         self.error_code = error_code
#         self.message = message
#         super(HTTPException, self).__init__(self.message)
# 
#     def __str__(self):
#         """
#         String representation of error.
#         """
#         return f"Error code: {self.error_code}\n" f"Error message: {self.message}"


# Path: tests/validators/test_pagure.py
import pytest
from unittest import mock
from hotness.domain import Package
from hotness.validators import Pagure
from hotness.exceptions import HTTPException


    def test_init(self):
        """
        Assert that Pagure class is initialized successfully.
        """
        url = "http://testing.url"
        timeout = (5, 20)
        requests_session = mock.Mock()

        validator = Pagure(url, requests_session, timeout)

        assert validator.url == url
        assert validator.requests_session == requests_session
        assert validator.timeout == timeout


class TestPagureValidate:
    """
    Test class for `hotness.validators.Pagure.validate` method.
    """

    def setup(self):
        """
        Setup phase before test.
        """
        # Initialize PDC wrapper
        url = "http://testing.url"
        timeout = (5, 20)
        requests_session = mock.Mock()


        self.validator = Pagure(url, requests_session, timeout)