Skip to content

Commit

Permalink
Update importer mock test aboutcode-org#597
Browse files Browse the repository at this point in the history
Reference: aboutcode-org#935

Signed-off-by: John M. Horan <johnmhoran@gmail.com>
  • Loading branch information
johnmhoran authored and TG1999 committed Oct 19, 2022
1 parent c89c5a0 commit 9565c0e
Show file tree
Hide file tree
Showing 3 changed files with 307,750 additions and 4 deletions.
2 changes: 1 addition & 1 deletion vulnerabilities/importers/archlinux.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def fetch(self) -> Iterable[Mapping]:

def advisory_data(self) -> Iterable[AdvisoryData]:
for record in self.fetch():
yield self.parse_advisory(record)
yield from self.parse_advisory(record)

def parse_advisory(self, record) -> List[AdvisoryData]:
advisories = []
Expand Down
4 changes: 1 addition & 3 deletions vulnerabilities/tests/test_archlinux.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,11 @@ def test_parse_advisory_single():
util_tests.check_results_against_json(result, expected_file)


@patch("vulnerabilities.importers.archlinux.ArchlinuxImporter.fetch")
@patch("vulnerabilities.utils.fetch_response")
def test_archlinux_importer(mock_response):
with open(os.path.join(TEST_DATA, "archlinux-multi.json")) as f:
mock_response.return_value = json.load(f)

expected_file = os.path.join(TEST_DATA, f"archlinux-multi-expected.json")
result = [data.to_dict() for data in list(archlinux.ArchlinuxImporter().advisory_data())]
# result = [data.to_dict() for data in archlinux.ArchlinuxImporter().advisory_data()]
# result = archlinux.ArchlinuxImporter().advisory_data()
util_tests.check_results_against_json(result, expected_file)
Loading

0 comments on commit 9565c0e

Please sign in to comment.