def test_close_failed(self): url = 'test-url' c = Connection(url) impl = Mock() impl.close.side_effect = ValueError c._impl = impl c.close()
def test_close(self): url = 'test-url' c = Connection(url) impl = Mock() c._impl = impl c.close() impl.close.assert_called_once_with() self.assertEqual(c._impl, None)
def test_channel(self): url = TEST_URL c = Connection(url) c._impl = Mock() ch = c.channel() self.assertEqual(ch, c._impl.channel.return_value)
def test_open_already(self): url = TEST_URL c = Connection(url) c._impl = Mock() c.open() self.assertFalse(c._impl.open.called)