Changeset View
Changeset View
Standalone View
Standalone View
swh/loader/git/tests/test_loader.py
Show First 20 Lines • Show All 446 Lines • ▼ Show 20 Lines | def test_load_incremental(self, mocker): | ||||
), | ), | ||||
] | ] | ||||
# TODO: assert "incremental*" is added to constant tags before these | # TODO: assert "incremental*" is added to constant tags before these | ||||
# metrics are sent | # metrics are sent | ||||
assert [c for c in statsd_report.mock_calls if c[1][0].startswith("git_")] == [ | assert [c for c in statsd_report.mock_calls if c[1][0].startswith("git_")] == [ | ||||
call("git_total", "c", 1, {}, 1), | call("git_total", "c", 1, {}, 1), | ||||
call("git_ignored_refs_percent", "h", 0.0, {}, 1), | call("git_ignored_refs_percent", "h", 0.0, {}, 1), | ||||
call("git_known_refs_percent", "h", 0.25, {}, 1), | call("git_known_refs_percent", "h", 0.0, {}, 1), | ||||
] | ] | ||||
assert self.loader.statsd.constant_tags == { | assert self.loader.statsd.constant_tags == { | ||||
"visit_type": "git", | "visit_type": "git", | ||||
"incremental_enabled": True, | "incremental_enabled": True, | ||||
"has_parent_snapshot": True, | "has_parent_snapshot": True, | ||||
"has_previous_snapshot": False, | "has_previous_snapshot": False, | ||||
"has_parent_origins": True, | "has_parent_origins": True, | ||||
} | } | ||||
▲ Show 20 Lines • Show All 43 Lines • ▼ Show 20 Lines | def test_load_incremental(self, mocker): | ||||
), | ), | ||||
] | ] | ||||
# TODO: assert "incremental*" is added to constant tags before these | # TODO: assert "incremental*" is added to constant tags before these | ||||
# metrics are sent | # metrics are sent | ||||
assert [c for c in statsd_report.mock_calls if c[1][0].startswith("git_")] == [ | assert [c for c in statsd_report.mock_calls if c[1][0].startswith("git_")] == [ | ||||
call("git_total", "c", 1, {}, 1), | call("git_total", "c", 1, {}, 1), | ||||
call("git_ignored_refs_percent", "h", 0.0, {}, 1), | call("git_ignored_refs_percent", "h", 0.0, {}, 1), | ||||
call("git_known_refs_percent", "h", 1.0, {}, 1), | call("git_known_refs_percent", "h", 0.0, {}, 1), | ||||
] | ] | ||||
assert self.loader.statsd.constant_tags == { | assert self.loader.statsd.constant_tags == { | ||||
"visit_type": "git", | "visit_type": "git", | ||||
"incremental_enabled": True, | "incremental_enabled": True, | ||||
"has_parent_snapshot": False, # Because we reset the mock since last time | "has_parent_snapshot": False, # Because we reset the mock since last time | ||||
"has_previous_snapshot": True, | "has_previous_snapshot": True, | ||||
"has_parent_origins": True, | "has_parent_origins": True, | ||||
} | } | ||||
@pytest.mark.parametrize( | @pytest.mark.parametrize( | ||||
"parent_snapshot,previous_snapshot,expected_git_known_refs_percent", | "parent_snapshot,previous_snapshot,expected_git_known_refs_percent", | ||||
[ | [ | ||||
pytest.param( | pytest.param( | ||||
Snapshot( | Snapshot( | ||||
branches={ | branches={ | ||||
b"refs/heads/master": SNAPSHOT1.branches[b"refs/heads/master"] | b"refs/heads/master": SNAPSHOT1.branches[b"refs/heads/master"] | ||||
} | } | ||||
), | ), | ||||
Snapshot(branches={}), | Snapshot(branches={}), | ||||
0.25, | 0.0, | ||||
id="partial-parent-and-empty-previous", | id="partial-parent-and-empty-previous", | ||||
), | ), | ||||
pytest.param( | pytest.param( | ||||
SNAPSHOT1, | SNAPSHOT1, | ||||
Snapshot( | Snapshot( | ||||
branches={ | branches={ | ||||
b"refs/heads/master": SNAPSHOT1.branches[b"refs/heads/master"] | b"refs/heads/master": SNAPSHOT1.branches[b"refs/heads/master"] | ||||
} | } | ||||
), | ), | ||||
1.0, | 0.0, | ||||
id="full-parent-and-partial-previous", | id="full-parent-and-partial-previous", | ||||
), | ), | ||||
], | ], | ||||
) | ) | ||||
def test_load_incremental_from( | def test_load_incremental_from( | ||||
self, | self, | ||||
parent_snapshot, | parent_snapshot, | ||||
previous_snapshot, | previous_snapshot, | ||||
▲ Show 20 Lines • Show All 289 Lines • Show Last 20 Lines |