From 33a31e096a1af6b5adbd3a4d2fd9524eb86e5496 Mon Sep 17 00:00:00 2001 From: Yaroslav Halchenko Date: Fri, 29 Mar 2013 15:32:43 -0400 Subject: [PATCH] RF+TST: bring inBanList back from private to protected and enabled its rudimentary unittests --- server/banmanager.py | 4 ++-- testcases/banmanagertestcase.py | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/server/banmanager.py b/server/banmanager.py index 596dc4e9..1143f791 100644 --- a/server/banmanager.py +++ b/server/banmanager.py @@ -148,7 +148,7 @@ class BanManager: def addBanTicket(self, ticket): try: self.__lock.acquire() - if not self.__inBanList(ticket): + if not self._inBanList(ticket): self.__banList.append(ticket) self.__banTotal += 1 return True @@ -177,7 +177,7 @@ class BanManager: # @param ticket the ticket # @return True if a ticket already exists - def __inBanList(self, ticket): + def _inBanList(self, ticket): for i in self.__banList: if ticket.getIP() == i.getIP(): return True diff --git a/testcases/banmanagertestcase.py b/testcases/banmanagertestcase.py index 7d389eed..6d0ce55a 100644 --- a/testcases/banmanagertestcase.py +++ b/testcases/banmanagertestcase.py @@ -49,11 +49,11 @@ class AddFailure(unittest.TestCase): self.assertFalse(self.__banManager.addBanTicket(self.__ticket)) self.assertEqual(self.__banManager.size(), 1) - def _testInListOK(self): + def testInListOK(self): ticket = BanTicket('193.168.0.128', 1167605999.0) - self.assertTrue(self.__banManager.inBanList(ticket)) + self.assertTrue(self.__banManager._inBanList(ticket)) - def _testInListNOK(self): + def testInListNOK(self): ticket = BanTicket('111.111.1.111', 1167605999.0) - self.assertFalse(self.__banManager.inBanList(ticket)) + self.assertFalse(self.__banManager._inBanList(ticket))