def test_repair(self, _find): _impl = Mock() plugin = Mock() plugin.Sender.return_value = _impl _find.return_value = plugin url = TEST_URL sender = Sender(url) sender.repair() _impl.repair.assert_called_with()
def test_close(self, _find): _impl = Mock() plugin = Mock() plugin.Sender.return_value = _impl _find.return_value = plugin url = TEST_URL sender = Sender(url) # soft sender.close() _impl.close.assert_called_with()
def test_is_open(self, _find): _impl = Mock() plugin = Mock() plugin.Sender.return_value = _impl _find.return_value = plugin url = TEST_URL sender = Sender(url) is_open = sender.is_open() _impl.is_open.assert_called_with() self.assertEqual(is_open, _impl.is_open.return_value)
def test_send(self, _find): _impl = Mock() plugin = Mock() plugin.Sender.return_value = _impl _find.return_value = plugin url = TEST_URL address = Mock() content = '1234' ttl = 10 sender = Sender(url) sender.durable = 18 sender.send(address, content, ttl) _impl.send.assert_called_once_with(address, content, ttl) self.assertEqual(sender.durable, _impl.durable)
def test_init(self, _find): _impl = Mock() plugin = Mock() plugin.Sender.return_value = _impl _find.return_value = plugin url = TEST_URL sender = Sender(url) self.assertEqual(sender._impl, _impl) self.assertTrue(isinstance(sender, BaseSender))