Beispiel #1
0
 def test_score_bad_match_same_day_run(self):
     """
     Tests messages with mutually exclusive uids on the same day are scored lowly
     """
     # uid, risk, day, time_received, true sender id
     current_day = 0
     message1 = Message(0, 0, current_day, "human:0")
     message2 = Message(1, 0, current_day, "human:1")
     clusters = Clusters()
     clusters.add_messages([encode_message(message1)], current_day)
     best_cluster, best_message, best_score = clusters.score_matches(message2, current_day)
     self.assertEqual(best_score, -1)
     self.assertEqual(message1, best_message)
Beispiel #2
0
 def test_score_bad_match_one_day_run(self):
     """
     Tests messages with mutually exclusive uids seperated by a day are scored lowly
     """
     # uid, risk, day, true sender id
     message1 = Message(0, 0, 0, "human:1")
     message2 = Message(6, 0, 1, "human:1")
     clusters = Clusters()
     clusters.add_messages([encode_message(message1)], 0)
     best_cluster, best_message, best_score = clusters.score_matches(message2, 1)
     self.assertEqual(best_cluster, 0)
     self.assertEqual(best_message, message1)
     self.assertEqual(best_score, -1)
Beispiel #3
0
 def test_score_good_match_same_day_run(self):
     """
     Tests messages with the same uids on the same day are scored highly
     """
     # uid, risk, day, true sender id
     current_day = 0
     message1 = Message(0, 0, current_day, "human:1")
     message2 = Message(0, 0, current_day, "human:1")
     clusters = Clusters()
     clusters.add_messages([encode_message(message1)], current_day)
     best_cluster, best_message, best_score = clusters.score_matches(message2, current_day)
     self.assertEqual(best_cluster, 0)
     self.assertEqual(best_message, message1)
     self.assertEqual(best_score, 3)
Beispiel #4
0
    def test_score_good_match_one_day_run(self):
        """
        Tests messages with similar uids on the different day are scored mediumly
        """
        # uid, risk, day, true sender id
        current_day = 0
        clusters = Clusters()
        message1 = Message(0, 0, 0, "human:1")
        clusters.add_messages([encode_message(message1)], current_day)
        message2 = Message(1, 0, 1, "human:1")

        best_cluster, best_message, best_score = clusters.score_matches(message2, 1)
        self.assertEqual(best_cluster, 0)
        self.assertEqual(best_message, message1)
        self.assertEqual(best_score, 2)