TST: complete coverage of splitAction

pull/484/head
Daniel Black 2013-12-12 20:35:30 +00:00
parent b18ce122dd
commit c6d14dcf0e
2 changed files with 13 additions and 1 deletions

View File

@ -180,7 +180,7 @@ class JailReader(ConfigReader):
"2 groups. Got: 0" % action) "2 groups. Got: 0" % action)
if len(mgroups) == 2: if len(mgroups) == 2:
action_name, action_opts = mgroups action_name, action_opts = mgroups
elif len(mgroups) == 1: elif len(mgroups) == 1: # pragma: nocover - unreachable - .* on second group always matches
action_name, action_opts = mgroups[0], None action_name, action_opts = mgroups[0], None
else: # pragma: nocover - unreachable - regex only can capture 2 groups else: # pragma: nocover - unreachable - regex only can capture 2 groups
raise ValueError("While reading action %s we should have got up to " raise ValueError("While reading action %s we should have got up to "

View File

@ -123,7 +123,19 @@ class JailReaderTest(LogCaptureTestCase):
expected = ['mail-whois', {'name': 'SSH'}] expected = ['mail-whois', {'name': 'SSH'}]
result = JailReader.splitAction(action) result = JailReader.splitAction(action)
self.assertEqual(expected, result) self.assertEqual(expected, result)
self.assertEqual(['mail.who_is', {}], JailReader.splitAction("mail.who_is"))
self.assertEqual(['mail.who_is', {'a':'cat', 'b':'dog'}], JailReader.splitAction("mail.who_is[a=cat,b=dog]"))
self.assertEqual(['mail--ho_is', {}], JailReader.splitAction("mail--ho_is"))
self.assertEqual(['mail--ho_is', {}], JailReader.splitAction("mail--ho_is['s']"))
self.assertTrue(self._is_logged("Invalid argument ['s'] in ''s''"))
self.assertEqual(['mail', {'a': ','}], JailReader.splitAction("mail[a=',']"))
self.assertRaises(ValueError, JailReader.splitAction ,'mail-how[')
def testGlob(self): def testGlob(self):
d = tempfile.mkdtemp(prefix="f2b-temp") d = tempfile.mkdtemp(prefix="f2b-temp")
# Generate few files # Generate few files