Beispiel #1
0
    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)
Beispiel #2
0
    def test_remove_partially_old(self) -> None:
        path = Path(self.tmp.name).joinpath("vulns01.json")

        timestamp = time.time() + const.CACHE_TIME + 1000
        self._write_cache(path, timestamp, 2)

        with path.open() as f:
            entry = next(x for x in json.load(f)
                         if x["coordinates"] == "pkg:pypi/[email protected]")

        with patch("ossaudit.const.CACHE", path):
            cache.save(entry)

        with path.open() as f:
            updated = json.load(f)

        self.assertEqual(len(updated), 2)
        self.assertNotEqual(updated[0]["time"], timestamp)
Beispiel #3
0
    def test_mkdir(self) -> None:
        path = Path(self.tmp.name).joinpath("x", "y", "z", "vulns01.json")

        with patch("ossaudit.const.CACHE", path):
            cache.save({})
            self.assertTrue(path.parent.exists())