def testShouldChangeExpiredGreylistedTestEntryToWhitelisted(self):
     entry = GLEntry(client='1.2.3.4', helo='some.domain.tld', sender='bar.tld')
     entry.status = 'G'
     last_activated = datetime.now() - timedelta(minutes=5)
     entry.last_activated = last_activated
     expiry_date = datetime.now() - timedelta(minutes=5)
     entry.expiry_date = expiry_date
     entry.score = 2
     entry.count = 3
     self.session.add(entry)
     self.glc.read_headers(self.header_file)
     self.assertEqual('action=DUNNO\n\n',
                      self.glc.perform_action())
     query = self.session.query(GLEntry)
     entry = query.first()
     self.assertEqual('W', entry.status)
     self.assertEqual(1, entry.count)
     self.failUnless(entry.last_activated > last_activated)
     self.failUnless(entry.expiry_date > expiry_date)
 def testShouldUpdateGreylistedTestEntryCount(self):
     entry = GLEntry(client='1.2.3.4', helo='some.domain.tld', sender='bar.tld')
     entry.status = 'G'
     last_activated = datetime.now() - timedelta(minutes=5)
     entry.last_activated = last_activated
     expiry_date = datetime.now() + timedelta(minutes=5)
     entry.expiry_date = expiry_date
     entry.score = 1
     entry.count = 1
     self.session.add(entry)
     self.glc.read_headers(self.header_file)
     self.assertEqual("action=%s\n\n" % self.glc.settings.greylist_message,
                      self.glc.perform_action())
     query = self.session.query(GLEntry)
     entry = query.first()
     self.assertEqual('G', entry.status)
     self.assertEqual(2, entry.count)
     self.failUnless(entry.last_activated > last_activated)
     self.assertEqual(entry.expiry_date, expiry_date)