def test_close(self): url = Mock() messenger = Endpoint(url) messenger.connection = Mock() messenger.channel = Mock() messenger.close() messenger.channel.close.assert_called_once_with()
def test_open(self): url = Mock() messenger = Endpoint(url) messenger.open() messenger.connection.open.assert_called_once_with() self.assertEqual(messenger.channel, messenger.connection.channel.return_value)
def test_repair(self): url = Mock() messenger = Endpoint(url) messenger.repair() messenger.connection.close.assert_called_once_with() messenger.connection.open.assert_called_once_with() self.assertEqual(messenger.channel, messenger.connection.channel.return_value)
def test_close_failed(self): url = Mock() messenger = Endpoint(url) messenger.connection = Mock() messenger.channel = Mock() messenger.channel.close.side_effect = ValueError messenger.close() messenger.channel.close.assert_called_once_with()
def test_is_open(self): url = Mock() messenger = Endpoint(url) self.assertTrue(messenger.is_open())
def test_init(self, connection): url = Mock() messenger = Endpoint(url) connection.assert_called_once_with(url) self.assertEqual(messenger.connection, connection.return_value) self.assertEqual(messenger.channel, None)