Skip to content

Commit

Permalink
Issue #50: Internal (not in pypi) packages not ignored, even when ins…
Browse files Browse the repository at this point in the history
…tructed to (tests).
  • Loading branch information
Nekmo committed Oct 30, 2023
1 parent 4c9dc7a commit b091269
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions tests/test_results.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ def test_colorize_rating(self):
self.assertEqual("F", colorize_rating(ScoreValue(-1)).letter)
with self.subTest("Test above 0"):
self.assertIn("E", colorize_rating(ScoreValue(5)).letter)
with self.subTest("Test with undefined rating"):
self.assertIn(
"?",
colorize_rating(None).letter,
)


class TestColorizeRatingPackage(unittest.TestCase):
Expand All @@ -69,6 +74,11 @@ def test_colorize_rating_package(self, mock_colorize_rating: MagicMock):
self.assertIn(
"E", colorize_rating_package(mock_package, mock_parent_package)
)
with self.subTest("Test with undefined rating"):
mock_colorize_rating.side_effect = ["?", "?"]
self.assertIn(
"?", colorize_rating_package(mock_package, mock_parent_package)
)


class TestAddTreeNode(unittest.TestCase):
Expand Down Expand Up @@ -259,8 +269,13 @@ def test_show_packages_results(self):
mock_package.rating.breakdown_scores = [("key", 5)]
mock_package.rating.get_vulnerabilities.return_value = [{"id": "CVE-2020-0001"}]
mock_package.name = "name"
mock_dependencies.packages = {"name": mock_package}
mock_dependencies.req_file = ["name"]
mock_ignore_package = MagicMock()
mock_ignore_package.rating = None
mock_dependencies.packages = {
"name": mock_package,
"ignored": mock_ignore_package,
}
mock_dependencies.req_file = ["name", "ignored"]
test_results = Results()
test_results.results_console = Mock()
test_results.show_packages_results(mock_dependencies)
Expand Down

0 comments on commit b091269

Please sign in to comment.