Skip to content
Snippets Groups Projects
Commit 09b671f4 authored by Stuart Gathman's avatar Stuart Gathman
Browse files

Test AddrCache.

parent 732e7317
Branches
Tags
No related merge requests found
import unittest
import os
from Milter.cache import AddrCache
class AddrCacheTestCase(unittest.TestCase):
def setUp(self):
self.fname = 'test.dat'
self.cache = AddrCache(fname=self.fname)
def tearDown(self):
os.remove(self.fname)
def testAdd(self):
cache = self.cache
cache['foo@bar.com'] = None
cache.addperm('baz@bar.com')
cache['temp@bar.com'] = 'testing'
self.failUnless(cache.has_key('foo@bar.com'))
self.failUnless(not cache.has_key('hello@bar.com'))
self.assertEquals(cache['temp@bar.com'],'testing')
s = open(self.fname).readlines()
self.failUnless(len(s) == 2)
self.failUnless(s[0].startswith('foo@bar.com '))
self.assertEquals(s[1].strip(),'baz@bar.com')
def suite(): return unittest.makeSuite(AddrCacheTestCase,'test')
if __name__ == '__main__':
unittest.main()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment