Esempio n. 1
0
    def test_report_to_few(self):
        digest = "2aedaac999d71421c9ee49b9d81f627a7bc570aa"
        self.patch_all()

        client = pyzor.client.BatchClient()
        for i in range(9):
            client.report(digest)

        self.assertEqual(list(self.get_requests()), [])
Esempio n. 2
0
    def test_force_report(self):
        digest = "2aedaac999d71421c9ee49b9d81f627a7bc570aa"
        self.patch_all()

        client = pyzor.client.BatchClient()
        for i in range(9):
            client.report(digest)
        client.force()
        args, kwargs = list(self.get_requests())[0]

        msg = email.message_from_string(args[0].decode())
        self.assertEqual(len(msg.get_all("Op-Digest")), 9)
Esempio n. 3
0
 def _pyzor_report(self, msg, spam=True):
     """Does the actual work for reporting digests to pyzor."""
     if not self["use_pyzor"]:
         return
     try:
         digest = self.get_local(msg, "digest")
     except KeyError:
         digest = pyzor.digest.DataDigester(msg.msg).value
         self.set_local(msg, "digest", digest)
     client = self["client"]
     self.ctxt.log.debug("Reporting digest %s with Pyzor (%s)", digest,
                         spam)
     for server in self["pyzor_servers"]:
         if spam:
             client.report(digest, server.rsplit(":", 1))
         else:
             client.whitelist(digest, server.rsplit(":", 1))
Esempio n. 4
0
 def _pyzor_report(self, msg, spam=True):
     """Does the actual work for reporting digests to pyzor."""
     if not self["use_pyzor"]:
         return
     try:
         digest = self.get_local(msg, "digest")
     except KeyError:
         digest = pyzor.digest.DataDigester(msg.msg).value
         self.set_local(msg, "digest", digest)
     client = self["client"]
     self.ctxt.log.debug("Reporting digest %s with Pyzor (%s)", digest,
                         spam)
     for server in self["pyzor_servers"]:
         if spam:
             client.report(digest, server.rsplit(":", 1))
         else:
             client.whitelist(digest, server.rsplit(":", 1))