def testIsExitFeedbackIpAddress(self): """Tests _IsExitFeedbackIpAddress().""" self.mox.StubOutWithMock(reports.models.KeyValueCache, 'IpInList') ip_address = '1.2.3.4' reports.models.KeyValueCache.IpInList( 'client_exit_ip_blocks', ip_address).AndReturn(True) self.mox.ReplayAll() self.assertFalse(reports.IsExitFeedbackIpAddress(None)) self.assertTrue(reports.IsExitFeedbackIpAddress(ip_address)) self.mox.VerifyAll()
def _MockIsExitFeedbackIpAddress(self, ip_address=None, match=False): """Utility method to mock IsExitFeedbackIpAddress() calls. Args: ip_address: str, optional, IP like '1.2.3.4' match: bool, optional, True if the ip_address matches the exit list """ self.mox.StubOutWithMock(reports, 'IsExitFeedbackIpAddress') reports.IsExitFeedbackIpAddress(ip_address).AndReturn(match)