# Path: hotness/databases/cache.py
# class Cache(Database):
#     """
#     Wrapper for the cache for the-new-hotness.
#     It is represented by python dictionary.
# 
#     Attributes:
#         cache (dict): Dictionary to hold key/value pairs
#     """
# 
#     def __init__(self) -> None:
#         """
#         Class constructor.
#         """
#         super(Cache, self).__init__()
#         self.cache: Dict = {}
# 
#     def insert(self, key: str, value: str) -> dict:
#         """
#         It insert key/value pair to cache. If key is already in cache
#         it will change the value.
# 
#         Params:
#             key: Key to insert to database
#             value: Value for the key to add
# 
#         Returns:
#             Dictionary containing key/value pairs.
#             Example:
#             {
#               "key": "key", # Key we added/edited in database
#               "value": "value", # New value added to the key
#               "old_value": "old_value" # Old value for the key, empty if the key is new
#             }
#         """
#         output = {"key": key, "value": value, "old_value": self.cache.get(key, "")}
# 
#         self.cache[key] = value
# 
#         return output
# 
#     def retrieve(self, key: str) -> dict:
#         """
#         Retrieve value for a key in database. If the key is not available
#         it returns empty value represented by "".
# 
#         Params:
#             key: Key to retrieve from database
# 
#         Returns:
#             Dictionary containing key/value pairs.
#             Example:
#             {
#               "key": "key", # Key we retrieved from database
#               "value": "value" # Retrieved value for the key
#             }
#         """
#         output = {"key": key, "value": self.cache.get(key, "")}
# 
#         return output


from hotness.databases import Cache
        output = self.database.insert(key, value)

        assert output == {"key": key, "value": value, "old_value": ""}
        assert self.database.cache == {key: value}

    def test_insert_key_already_exists(self):
        """
        Assert that insert changes the value if key is already present.
        """
        key = "key"
        old_value = "old_value"
        value = "value"

        self.database.cache = {key: old_value}

        output = self.database.insert(key, value)

        assert output == {"key": key, "value": value, "old_value": old_value}
        assert self.database.cache == {key: value}


class TestCacheRetrieve:
    """
    Test class for `hotness.databases.Cache.retrieve` method.
    """

    def setup(self):
        """
        Create database instance for tests.
        """

# Path: hotness/databases/cache.py
# class Cache(Database):
#     """
#     Wrapper for the cache for the-new-hotness.
#     It is represented by python dictionary.
# 
#     Attributes:
#         cache (dict): Dictionary to hold key/value pairs
#     """
# 
#     def __init__(self) -> None:
#         """
#         Class constructor.
#         """
#         super(Cache, self).__init__()
#         self.cache: Dict = {}
# 
#     def insert(self, key: str, value: str) -> dict:
#         """
#         It insert key/value pair to cache. If key is already in cache
#         it will change the value.
# 
#         Params:
#             key: Key to insert to database
#             value: Value for the key to add
# 
#         Returns:
#             Dictionary containing key/value pairs.
#             Example:
#             {
#               "key": "key", # Key we added/edited in database
#               "value": "value", # New value added to the key
#               "old_value": "old_value" # Old value for the key, empty if the key is new
#             }
#         """
#         output = {"key": key, "value": value, "old_value": self.cache.get(key, "")}
# 
#         self.cache[key] = value
# 
#         return output
# 
#     def retrieve(self, key: str) -> dict:
#         """
#         Retrieve value for a key in database. If the key is not available
#         it returns empty value represented by "".
# 
#         Params:
#             key: Key to retrieve from database
# 
#         Returns:
#             Dictionary containing key/value pairs.
#             Example:
#             {
#               "key": "key", # Key we retrieved from database
#               "value": "value" # Retrieved value for the key
#             }
#         """
#         output = {"key": key, "value": self.cache.get(key, "")}
# 
#         return output


# Path: tests/databases/test_cache.py
from hotness.databases import Cache

        output = self.database.insert(key, value)

        assert output == {"key": key, "value": value, "old_value": ""}
        assert self.database.cache == {key: value}

    def test_insert_key_already_exists(self):
        """
        Assert that insert changes the value if key is already present.
        """
        key = "key"
        old_value = "old_value"
        value = "value"

        self.database.cache = {key: old_value}

        output = self.database.insert(key, value)

        assert output == {"key": key, "value": value, "old_value": old_value}
        assert self.database.cache == {key: value}


class TestCacheRetrieve:
    """
    Test class for `hotness.databases.Cache.retrieve` method.
    """

    def setup(self):
        """
        Create database instance for tests.
        """

        self.database = Cache()