Skip to content

Commit

Permalink
chore: assert no exceptions logged during test run (#311)
Browse files Browse the repository at this point in the history
The provider is intentionally resilient to malformed records, and
implements this resilience by logging and continuing on when any
exception is thrown. However, this prevents the unit tests from many
errors in the implementation of the provider. Therefore, spy on the
provider and fail unit tests if it is logging exceptions.

Signed-off-by: Will Murphy <[email protected]>
  • Loading branch information
willmurphyscode authored Oct 3, 2023
1 parent e61d534 commit c4680bf
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions tests/unit/providers/debian/test_debian.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import os.path
import shutil
from unittest.mock import MagicMock

import pytest
from vunnel import result, workspace
Expand Down Expand Up @@ -68,6 +69,7 @@ def test_get_dsa_map(self, tmpdir, helpers, disable_get_requests):

def test_normalize_json(self, tmpdir, helpers, disable_get_requests):
subject = parser.Parser(workspace=workspace.Workspace(tmpdir, "test", create=True))
subject.logger = MagicMock()

dsa_mock_data_path = helpers.local_dir(self._sample_dsa_data_)
json_mock_data_path = helpers.local_dir(self._sample_json_data_)
Expand All @@ -88,6 +90,7 @@ def test_normalize_json(self, tmpdir, helpers, disable_get_requests):
assert all(x.get("Vulnerability", {}).get("Name") for x in vuln_dict.values())

assert all(x.get("Vulnerability", {}).get("Description") is not None for x in vuln_dict.values())
assert not subject.logger.exception.called, "no exceptions should be logged"

def test_get_legacy_records(self, tmpdir, helpers, disable_get_requests):
subject = parser.Parser(workspace=workspace.Workspace(tmpdir, "test", create=True))
Expand Down

0 comments on commit c4680bf

Please sign in to comment.