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_sender(self, uuid): url = 'test-url' address = 'test' uuid.return_value = '1234' connection = Connection(url) connection._impl = Mock() # test sender = connection.sender(address) # validation connection._impl.create_sender.assert_called_once_with(address, name=uuid.return_value) self.assertEqual(sender, connection._impl.create_sender.return_value)
def test_sender(self, uuid): url = 'test-url' address = 'test' uuid.return_value = '1234' connection = Connection(url) connection._impl = Mock() # test sender = connection.sender(address) # validation connection._impl.create_sender.assert_called_once_with( address, name=uuid.return_value) self.assertEqual(sender, connection._impl.create_sender.return_value)
def test_dynamic_receiver(self, uuid, properties): url = 'test-url' address = 'test' uuid.return_value = '1234' connection = Connection(url) connection._impl = Mock() # test receiver = connection.receiver(address, dynamic=True) # validation properties.assert_called_once_with({'x-opt-qd.address': address}) connection._impl.create_receiver.assert_called_once_with( None, dynamic=True, name=uuid.return_value, options=properties.return_value) self.assertEqual(receiver, connection._impl.create_receiver.return_value)
def test_receiver(self, uuid, properties): url = 'test-url' address = 'test' uuid.return_value = '1234' connection = Connection(url) connection._impl = Mock() # test receiver = connection.receiver(address) # validation connection._impl.create_receiver.assert_called_once_with( address, dynamic=False, name=uuid.return_value, options=None) self.assertEqual(receiver, connection._impl.create_receiver.return_value) self.assertFalse(properties.called)
def test_is_open(self): connection = Connection('') self.assertFalse(connection.is_open()) connection._impl = Mock() self.assertTrue(connection.is_open())