Page MenuHomeSoftware Heritage

Jenkins > .tox.py3.lib.python3.7.site-packages.swh.loader.git.tests.test_loader.TestGitLoader2::test_load_incremental
Failed

TEST RESULT

Run At
May 4 2022, 12:50 PM
Details
self = <swh.loader.git.tests.test_loader.TestGitLoader2 object at 0x7f5262fe6208> mocker = <pytest_mock.plugin.MockerFixture object at 0x7f52601478d0> def test_load_incremental(self, mocker): statsd_report = mocker.patch("swh.core.statsd.statsd._report") snapshot_id = b"\x01" * 20 now = datetime.datetime.now(tz=datetime.timezone.utc) def ovgl(origin_url, allowed_statuses, require_snapshot, type): if origin_url == f"base://{self.repo_url}": return OriginVisit(origin=origin_url, visit=42, date=now, type="git") else: return None self.loader.storage.origin_visit_get_latest.side_effect = ovgl self.loader.storage.origin_visit_status_get_latest.return_value = ( OriginVisitStatus( origin=f"base://{self.repo_url}", visit=42, snapshot=snapshot_id, date=now, status="full", ) ) self.loader.storage.snapshot_get_branches.return_value = { "id": snapshot_id, "branches": { b"refs/heads/master": SNAPSHOT1.branches[b"refs/heads/master"] }, "next_branch": None, } res = self.loader.load() assert res == {"status": "eventful"} self.fetcher_cls.assert_called_once_with( credentials={}, lister_name="fake-lister", lister_instance_name="", origin=Origin(url=self.repo_url), ) self.fetcher.get_parent_origins.assert_called_once_with() # First tries the same origin assert self.loader.storage.origin_visit_get_latest.mock_calls == [ call( self.repo_url, allowed_statuses=None, require_snapshot=True, type=None, ), # As it does not already have a snapshot, fall back to the parent origin call( f"base://{self.repo_url}", allowed_statuses=None, require_snapshot=True, type=None, ), ] p = "swh.loader.git" assert [c for c in statsd_report.mock_calls if c[1][0].startswith(p)] == [ call(f"{p}.loader.incremental.from_parent_origin", "c", 1, None, 1), call( f"{p}.loader.ratio_ignored_refs", "h", 0.0, {"incremental": "from_parent_origin"}, 1, ), call( f"{p}.loader.ratio_known_refs", "h", 0.25, {"incremental": "from_parent_origin"}, 1, ), ] self.fetcher.reset_mock() self.fetcher_cls.reset_mock() self.loader.storage.reset_mock(return_value=True, side_effect=True) if sys.version_info < (3, 9, 0): # Reimplement https://github.com/python/cpython/commit/aef7dc89879d099dc704bd8037b8a7686fb72838 # noqa # for old Python versions: for child in self.loader.storage._mock_children.values(): child.reset_mock(return_value=True, side_effect=True) statsd_report.reset_mock() # Load again res = self.loader.load() assert res == {"status": "uneventful"} self.fetcher_cls.assert_called_once_with( credentials={}, lister_name="fake-lister", lister_instance_name="", origin=Origin(url=self.repo_url), ) self.fetcher.get_parent_origins.assert_not_called() assert self.loader.storage.origin_visit_get_latest.mock_calls == [ # Tries the same origin, and finds a snapshot call( self.repo_url, type=None, allowed_statuses=None, require_snapshot=True, ), # -> does not need to fall back to the parent ] p = "swh.loader.git" > assert [c for c in statsd_report.mock_calls if c.args[0].startswith(p)] == [ call(f"{p}.loader.incremental.from_same_origin", "c", 1, None, 1), call( f"{p}.loader.ratio_ignored_refs", "h", 0.0, {"incremental": "from_same_origin"}, 1, ), call( f"{p}.loader.ratio_known_refs", "h", 1.0, {"incremental": "from_same_origin"}, 1, ), ] E AssertionError: assert [] == [call('swh.lo..._origin'}, 1)] E Right contains 3 more items, first extra item: call('swh.loader.git.loader.incremental.from_same_origin', 'c', 1, None, 1) E Full diff: E [ E + , E - call('swh.loader.git.loader.incremental.from_same_origin', 'c', 1, None, 1), E - call('swh.loader.git.loader.ratio_ignored_refs', 'h', 0.0, {'incremental': 'from_same_origin'}, 1), E - call('swh.loader.git.loader.ratio_known_refs', 'h', 1.0, {'incremental': 'from_same_origin'}, 1),... E E ...Full output truncated (2 lines hidden), use '-vv' to show .tox/py3/lib/python3.7/site-packages/swh/loader/git/tests/test_loader.py:316: AssertionError