コード例 #1
0
ファイル: test_cache.py プロジェクト: pombredanne/ossaudit
    def test_missing_cached_entry(self) -> None:
        path = Path(self.tmp.name).joinpath("vulns01.json")
        self._write_cache(path, time.time())

        with patch("ossaudit.const.CACHE", path):
            entry = cache.get("pkg:pypi/[email protected]")

        self.assertIsNone(entry)
コード例 #2
0
ファイル: test_cache.py プロジェクト: pombredanne/ossaudit
    def test_have_old_cached_entry(self) -> None:
        path = Path(self.tmp.name).joinpath("vulns01.json")
        self._write_cache(path, time.time() + const.CACHE_TIME + 1)

        with patch("ossaudit.const.CACHE", path):
            entry = cache.get("pkg:pypi/[email protected]")

        self.assertIsNone(entry)
コード例 #3
0
ファイル: test_cache.py プロジェクト: pombredanne/ossaudit
    def test_have_cached_entry(self) -> None:
        path = Path(self.tmp.name).joinpath("vulns01.json")
        self._write_cache(path, time.time())

        with patch("ossaudit.const.CACHE", path):
            entry = cache.get("pkg:pypi/[email protected]") or {}

        self.assertEqual(entry["coordinates"], "pkg:pypi/[email protected]")
コード例 #4
0
ファイル: test_cache.py プロジェクト: sseide/ossaudit
    def test_ignore_invalid(self) -> None:
        path = Path(self.tmp.name).joinpath("vulns01.json")
        path.write_text("foo")

        entry = {"coordinates": "abcd"}
        with patch("ossaudit.const.CACHE", path):
            cache.save(entry)
            entry["time"] = ANY
            self.assertEqual(cache.get("abcd"), entry)
コード例 #5
0
ファイル: test_cache.py プロジェクト: pombredanne/ossaudit
 def test_no_cache(self) -> None:
     self.assertIsNone(cache.get("x"))
コード例 #6
0
ファイル: test_cache.py プロジェクト: sseide/ossaudit
 def test_invalid_cache(self) -> None:
     path = Path(self.tmp.name).joinpath("invalid.json")
     path.write_text("abcd")
     with patch("ossaudit.const.CACHE", path):
         self.assertIsNone(cache.get("foo"))