ENH+TST: Ticket -- drop unused/bogus get|setFile + enh __str__ + basic testing

pull/304/head
Yaroslav Halchenko 2013-07-22 12:09:33 -04:00
parent 149a83545f
commit 3b52eca608
2 changed files with 15 additions and 7 deletions

View File

@ -47,7 +47,7 @@ class Ticket:
def __str__(self):
return "%s: ip=%s time=%s #attempts=%d" % \
(self.__class__, self.__ip, self.__time, self.__attempt)
(self.__class__.__name__.split('.')[-1], self.__ip, self.__time, self.__attempt)
def setIP(self, value):
@ -59,12 +59,6 @@ class Ticket:
def getIP(self):
return self.__ip
def setFile(self, value):
self.__file = value
def getFile(self):
return self.__file
def setTime(self, value):
self.__time = value

View File

@ -78,6 +78,20 @@ class AddFailure(unittest.TestCase):
ticket = self.__failManager.toBan()
self.assertEqual(ticket.getIP(), "193.168.0.128")
self.assertTrue(isinstance(ticket.getIP(), str))
# finish with rudimentary tests of the ticket
# verify consistent str
ticket_str = str(ticket)
self.assertEqual(
ticket_str,
'FailTicket: ip=193.168.0.128 time=1167605999.0 #attempts=5')
# and some get/set-ers otherwise not tested
ticket.setTime(1000002000.0)
self.assertEqual(ticket.getTime(), 1000002000.0)
# and str() adjusted correspondingly
self.assertEqual(
str(ticket),
'FailTicket: ip=193.168.0.128 time=1000002000.0 #attempts=5')
def testbanNOK(self):
self.__failManager.setMaxRetry(10)