NF: adding unittests for previous commit

debian-releases/squeeze
Yaroslav Halchenko 2009-02-04 15:38:37 -05:00
parent b54290affb
commit 441318eba9
2 changed files with 14 additions and 1 deletions

View File

@ -57,6 +57,7 @@ tests = unittest.TestSuite()
tests.addTest(unittest.makeSuite(filtertestcase.IgnoreIP))
tests.addTest(unittest.makeSuite(filtertestcase.LogFile))
tests.addTest(unittest.makeSuite(filtertestcase.GetFailures))
tests.addTest(unittest.makeSuite(filtertestcase.DNSUtilsTests))
# Server
#tests.addTest(unittest.makeSuite(servertestcase.StartStop))
#tests.addTest(unittest.makeSuite(servertestcase.Transmitter))

View File

@ -26,7 +26,7 @@ __license__ = "GPL"
import unittest
from server.filterpoll import FilterPoll
from server.filter import FileFilter
from server.filter import FileFilter, DNSUtils
from server.failmanager import FailManager
from server.failmanager import FailManagerEmpty
@ -195,3 +195,15 @@ class GetFailures(unittest.TestCase):
self.__filter.getFailures(GetFailures.FILENAME_02)
self.assertRaises(FailManagerEmpty, self.__filter.failManager.toBan)
class DNSUtilsTests(unittest.TestCase):
def testTextToIp(self):
bogus = [
'doh1.2.3.4.buga.xxxxx.yyy',
'1.2.3.4.buga.xxxxx.yyy',
]
"""Really bogus addresses which should have no matches"""
for s in bogus:
res = DNSUtils.textToIp(s)
self.assertEqual(res, [])