def test_disconnect_exception(self): conn = Mock() close = Mock() close.side_effect=Exception("In your face") connection_valid = Mock() connection_valid.return_value = True config={"host":"host", "port":5656, "user":"******","password":"******"} co = RabbitmqClient(config) co._connection=conn conn.close=close co.is_connection_valid = connection_valid with self.assertRaises(RabbitmqClientException): co.disconnect()
def test_disconnect(self): conn = Mock() close = Mock() connection_valid = Mock() connection_valid.return_value = True conn.close=close config={"host":"host", "port":5656, "user":"******","password":"******"} co = RabbitmqClient(config) co.is_connection_valid = connection_valid co._connection=conn co.disconnect() close.assert_called_once_with() self.assertTrue(co._connection is None) self.assertTrue(co._channel is None)