コード例 #1
0
    def test_ignore_sender(self):
        from fuglu.shared import Suspect
        v = Vacation()
        v.ignoresender = u"unittests.fuglu.org [email protected]"
        v.awayuser = u'*****@*****.**'
        v.created = datetime.now()
        v.start = datetime.now()
        v.end = v.start + timedelta(days=2)
        v.subject = u'gone for good'
        v.body = u'outta here'
        self.session.add(v)
        self.session.flush()
        self.session.expunge_all()
        self.refreshcache()
        suspect = Suspect('*****@*****.**',
                          '*****@*****.**', '/dev/null')
        suspect.set_tag('nobounce', True)

        candidatevacation = self.candidate.on_vacation(suspect)
        self.assertTrue(candidatevacation != None,
                        "Vacation object not found in database")
        # TODO had to disable due to sqlalchemy error
        # Instance <Vacation at 0x2938890> is not bound to a Session; attribute refresh operation cannot proceed
        #self.assertEqual(v.ignoresender,candidatevacation.ignoresender,"Vacation object did not get ignore list")
        self.assertTrue(
            self.candidate.ignore_sender(candidatevacation, suspect),
            "Test Message should generate vacation reply(ignored sender)")
        self.assertFalse(
            self.candidate.should_send_vacation_message(suspect),
            "Sender on ignorelist, still wants to send message?!")
コード例 #2
0
    def test_generated_message(self):
        from fuglu.shared import Suspect
        suspect = Suspect(u'*****@*****.**',
                          '*****@*****.**', '/dev/null')
        suspect.tags['nobounce'] = True

        v = Vacation()
        v.ignoresender = u""
        v.awayuser = u'*****@*****.**'
        v.created = datetime.now()
        v.start = datetime.now()
        v.end = v.start + timedelta(days=2)
        v.subject = u'Döner mit schärf!'
        v.body = u"""Je m'envole pour l'Allemagne, où je suis né."""
        # v.body="Away!"
        self.session.add(v)
        self.session.flush()
        self.session.expunge_all()
        self.refreshcache()

        candidatevacation = self.candidate.on_vacation(suspect)
        self.assertTrue(candidatevacation != None,
                        "Vacation object not found in database")

        message = self.candidate.send_vacation_reply(suspect,
                                                     candidatevacation)
コード例 #3
0
    def test_localpartblacklist(self):
        """test messages from mailer-daemon"""
        from fuglu.shared import Suspect
        import email
        v = Vacation()
        v.ignoresender = u""
        v.awayuser = u'*****@*****.**'
        v.created = datetime.now()
        v.start = datetime.now()
        v.end = v.start + timedelta(days=2)
        v.subject = u'awaaay'
        v.body = u'cya'
        self.session.add(v)
        self.session.flush()
        self.session.expunge_all()
        self.refreshcache()
        botmsg = """From: [email protected]
Subject: mailinglist membership reminder...
"""

        suspect = Suspect('*****@*****.**',
                          '*****@*****.**', '/dev/null')
        suspect.set_tag('nobounce', True)
        suspect.set_source(botmsg)

        candidatevacation = self.candidate.on_vacation(suspect)
        self.assertTrue(candidatevacation != None,
                        "Vacation object not found in database")
        self.assertFalse(
            self.candidate.should_send_vacation_message(suspect),
            "Test Message should NOT generate vacation reply(automated)")
コード例 #4
0
    def test_ignore_sender(self):
        from fuglu.shared import Suspect
        v = Vacation()
        v.ignoresender = u"unittests.fuglu.org [email protected]"
        v.awayuser = u'*****@*****.**'
        v.created = datetime.now()
        v.start = datetime.now()
        v.end = v.start + timedelta(days=2)
        v.subject = u'gone for good'
        v.body = u'outta here'
        self.session.add(v)
        self.session.flush()
        self.session.expunge_all()
        self.refreshcache()
        suspect = Suspect(
            '*****@*****.**', '*****@*****.**', '/dev/null')
        suspect.set_tag('nobounce', True)

        candidatevacation = self.candidate.on_vacation(suspect)
        self.assertTrue(
            candidatevacation != None, "Vacation object not found in database")
        # TODO had to disable due to sqlalchemy error
        # Instance <Vacation at 0x2938890> is not bound to a Session; attribute refresh operation cannot proceed
        #self.assertEqual(v.ignoresender,candidatevacation.ignoresender,"Vacation object did not get ignore list")
        self.assertTrue(self.candidate.ignore_sender(
            candidatevacation, suspect), "Test Message should generate vacation reply(ignored sender)")
        self.assertFalse(self.candidate.should_send_vacation_message(
            suspect), "Sender on ignorelist, still wants to send message?!")
コード例 #5
0
    def test_generated_message(self):
        from fuglu.shared import Suspect
        suspect = Suspect(
            u'*****@*****.**', '*****@*****.**', '/dev/null')
        suspect.tags['nobounce'] = True

        v = Vacation()
        v.ignoresender = u""
        v.awayuser = u'*****@*****.**'
        v.created = datetime.now()
        v.start = datetime.now()
        v.end = v.start + timedelta(days=2)
        v.subject = u'Döner mit schärf!'
        v.body = u"""Je m'envole pour l'Allemagne, où je suis né."""
        # v.body="Away!"
        self.session.add(v)
        self.session.flush()
        self.session.expunge_all()
        self.refreshcache()

        candidatevacation = self.candidate.on_vacation(suspect)
        self.assertTrue(
            candidatevacation != None, "Vacation object not found in database")

        message = self.candidate.send_vacation_reply(
            suspect, candidatevacation)
コード例 #6
0
    def test_localpartblacklist(self):
        """test messages from mailer-daemon"""
        from fuglu.shared import Suspect
        import email
        v = Vacation()
        v.ignoresender = u""
        v.awayuser = u'*****@*****.**'
        v.created = datetime.now()
        v.start = datetime.now()
        v.end = v.start + timedelta(days=2)
        v.subject = u'awaaay'
        v.body = u'cya'
        self.session.add(v)
        self.session.flush()
        self.session.expunge_all()
        self.refreshcache()
        botmsg = """From: [email protected]
Subject: mailinglist membership reminder...
"""

        suspect = Suspect('*****@*****.**',
                          '*****@*****.**', '/dev/null')
        suspect.set_tag('nobounce', True)
        suspect.set_source(botmsg)

        candidatevacation = self.candidate.on_vacation(suspect)
        self.assertTrue(
            candidatevacation != None, "Vacation object not found in database")
        self.assertFalse(self.candidate.should_send_vacation_message(
            suspect), "Test Message should NOT generate vacation reply(automated)")
コード例 #7
0
    def test_vacation(self):
        """Test simple vacation use case"""
        from fuglu.shared import Suspect
        v = Vacation()
        v.ignoresender = ""
        v.awayuser = u'*****@*****.**'
        v.created = datetime.now()
        v.start = datetime.now()
        v.end = v.start + timedelta(days=2)
        v.subject = u'awaaay'
        v.body = u'cya'
        self.session.add(v)
        self.session.flush()
        self.session.expunge_all()
        self.refreshcache()
        suspect = Suspect(u'*****@*****.**',
                          '*****@*****.**', '/dev/null')
        suspect.set_tag('nobounce', True)

        candidatevacation = self.candidate.on_vacation(suspect)
        self.assertTrue(candidatevacation != None,
                        "Vacation object not found in database")
        self.assertTrue(self.candidate.should_send_vacation_message(suspect),
                        "Test Message should generate vacation reply")
        self.candidate.log_bounce(suspect, candidatevacation)

        # TODO: had to disable due to sqlalchemy error
        # Instance <Vacation at 0x2938890> is not bound to a Session; attribute refresh operation cannot proceed
        #self.assertFalse(self.candidate.should_send_vacation_message(suspect),"2nd test Message should NOT generate vacation reply")

        suspect2 = Suspect(u'*****@*****.**',
                           '*****@*****.**', '/dev/null')
        suspect2.set_tag('nobounce', True)
        candidatevacation = self.candidate.on_vacation(suspect2)
        self.assertFalse(
            candidatevacation != None,
            "There should be no vacation object for this recipient")
        self.assertFalse(self.candidate.should_send_vacation_message(suspect2),
                         "test Message should NOT generate vacation reply")
コード例 #8
0
    def test_vacation(self):
        """Test simple vacation use case"""
        from fuglu.shared import Suspect
        v = Vacation()
        v.ignoresender = ""
        v.awayuser = u'*****@*****.**'
        v.created = datetime.now()
        v.start = datetime.now()
        v.end = v.start + timedelta(days=2)
        v.subject = u'awaaay'
        v.body = u'cya'
        self.session.add(v)
        self.session.flush()
        self.session.expunge_all()
        self.refreshcache()
        suspect = Suspect(
            u'*****@*****.**', '*****@*****.**', '/dev/null')
        suspect.set_tag('nobounce', True)

        candidatevacation = self.candidate.on_vacation(suspect)
        self.assertTrue(
            candidatevacation != None, "Vacation object not found in database")
        self.assertTrue(self.candidate.should_send_vacation_message(
            suspect), "Test Message should generate vacation reply")
        self.candidate.log_bounce(suspect, candidatevacation)

        # TODO: had to disable due to sqlalchemy error
        # Instance <Vacation at 0x2938890> is not bound to a Session; attribute refresh operation cannot proceed
        #self.assertFalse(self.candidate.should_send_vacation_message(suspect),"2nd test Message should NOT generate vacation reply")

        suspect2 = Suspect(
            u'*****@*****.**', '*****@*****.**', '/dev/null')
        suspect2.set_tag('nobounce', True)
        candidatevacation = self.candidate.on_vacation(suspect2)
        self.assertFalse(candidatevacation != None,
                         "There should be no vacation object for this recipient")
        self.assertFalse(self.candidate.should_send_vacation_message(
            suspect2), "test Message should NOT generate vacation reply")