def update(self, pdid, data): print("Sending command {} to pdinstall".format(data['command'])) success = pdinstall.sendCommand(data['command'], data) # NOTE: If successful, this process will probably be going down soon. if success: return "Sent command to pdinstall" else: return "Sending command to pdinstall failed"
def test_sendCommand(socket): """ Test paradrop.lib.pdinstall.sendCommand """ from paradrop.lib.pdinstall import sendCommand command = "install" data = { 'sources': ["paradrop_0.1.0_all.snap"] } sock = MagicMock() socket.return_value = sock assert sendCommand(command, data) assert sock.connect.called assert sock.send.called assert sock.close.called sock.reset_mock sock.connect.side_effect = Exception("Boom!") assert sendCommand(command, data) is False assert sock.close.called