def test_basic(similarity): evt1 = create_event({"message": "hello world"}, group_id=123) evt2 = create_event({"message": "jello world"}, group_id=345) similarity.record([evt1]) similarity.record([evt2]) if similarity is sentry.similarity.features: msg_label = "message:message:character-shingles" else: msg_label = ("similarity:2020-07-23", "message", "character-5-shingle") comparison = dict(similarity.compare(evt1.group)) evt1_diff = comparison[evt1.group_id] assert set(evt1_diff.values()) == {None, 1.0} assert evt1_diff[msg_label] == 1.0 evt2_diff = comparison[evt2.group_id] assert set(evt2_diff.values()) == {None, 0.5} assert evt2_diff[msg_label] == 0.5
def compare(similarity, group): return set(dict(similarity.compare(group)))