def setUp(self): # Silence the logger that talks to HipChat logger = logging.getLogger('deployd.messaging') logger.handlers = [] plugin = ErroringSocketWhitelistPlugin() plugin.begin() os.environ['DEPLOY_TESTING'] = '1' self.client = mock.Mock() self.client.sendRequest = mock.Mock(return_value=(OpCode.NOOP, None))
class ErroringSocketWhitelistPluginTestCase(unittest.TestCase): def setUp(self): self.plugin = ErroringSocketWhitelistPlugin() self.plugin.begin() def tearDown(self): self.plugin.finalize(None) def test_allows_locally(self): for address in LOCALHOST_IPV4 + LOCALHOST_IPV6: socket.getaddrinfo(address, '80') def test_errors_on_remote(self): self.assertRaises(SocketError, lambda: urlopen('http://www.disqus.com'))
class ErroringSocketWhitelistPluginTestCase(unittest.TestCase): def setUp(self): self.plugin = ErroringSocketWhitelistPlugin() self.plugin.begin() def tearDown(self): self.plugin.finalize(None) def test_allows_locally(self): for address in LOCALHOST_IPV4 + LOCALHOST_IPV6: socket.getaddrinfo(address, '80') def test_errors_on_remote(self): self.assertRaises(SocketError, lambda: urlopen('http://www.disqus.com'))