diff --git a/swh/loader/package/tests/test_loader.py b/swh/loader/package/tests/test_loader.py --- a/swh/loader/package/tests/test_loader.py +++ b/swh/loader/package/tests/test_loader.py @@ -5,7 +5,7 @@ import hashlib import string -from unittest.mock import MagicMock +from unittest.mock import Mock import attr import pytest @@ -45,18 +45,18 @@ assert actual_load_status2 == {"status": "failed"} -def test_resolve_revision_from_artifacts(): - loader = PackageLoader(None, None) - loader.known_artifact_to_extid = MagicMock( - wraps=lambda known_artifact: known_artifact["key"].encode() +def test_resolve_revision_from_artifacts() -> None: + loader = PackageLoader(None, None) # type: ignore + loader.known_artifact_to_extid = Mock( # type: ignore + wraps=lambda known_artifact: ("extid-type", known_artifact["key"].encode()) ) known_artifacts = { - b"a" * 40: {"key": "extid-of-aaaa"}, - b"b" * 40: {"key": "extid-of-bbbb"}, + b"a" * 20: {"key": "extid-of-aaaa"}, + b"b" * 20: {"key": "extid-of-bbbb"}, } - p_info = MagicMock() + p_info = Mock(wraps=BasePackageInfo(None, None)) # type: ignore # No known artifact -> it would be useless to compute the extid assert loader.resolve_revision_from_artifacts({}, p_info) is None @@ -74,7 +74,7 @@ p_info.extid.reset_mock() # Some artifacts, and the PackageInfo is not one of them (ie. cache miss) - p_info.extid.return_value = b"extid-of-cccc" + p_info.extid.return_value = ("extid-type", b"extid-of-cccc") assert loader.resolve_revision_from_artifacts(known_artifacts, p_info) is None p_info.extid.assert_called_once() loader.known_artifact_to_extid.assert_any_call({"key": "extid-of-aaaa"}) @@ -84,8 +84,8 @@ loader.known_artifact_to_extid.reset_mock() # Some artifacts, and the PackageInfo is one of them (ie. cache hit) - p_info.extid.return_value = b"extid-of-aaaa" - assert loader.resolve_revision_from_artifacts(known_artifacts, p_info) == b"a" * 40 + p_info.extid.return_value = ("extid-type", b"extid-of-aaaa") + assert loader.resolve_revision_from_artifacts(known_artifacts, p_info) == b"a" * 20 p_info.extid.assert_called_once() loader.known_artifact_to_extid.assert_called_once_with({"key": "extid-of-aaaa"})