import unittest from unittest.mock import patch import os import time from dependabro.utils import is_cache_expired class TestIsCacheExpired(unittest.TestCase): @patch("os.path.exists", return_value=True) @patch("os.path.getmtime", return_value=time.time() - 100) def test_returns_false_when_cache_is_not_expired(self, mock_getmtime, mock_exists): self.assertFalse(is_cache_expired("/path/to/cache_file.json", 200)) @patch("os.path.exists", return_value=True) @patch("os.path.getmtime", return_value=time.time() - 300) def test_returns_true_when_cache_is_expired(self, mock_getmtime, mock_exists): self.assertTrue(is_cache_expired("/path/to/cache_file.json", 200)) @patch("os.path.exists", return_value=False) def test_returns_true_when_cache_file_not_found(self, mock_exists): self.assertTrue(is_cache_expired("/path/to/cache_file.json", 200)) if __name__ == "__main__": unittest.main()