# Path: partify/ipc.py
# def init_desired_player_state():
# def update_desired_player_state(state, transition_fn):
# def get_desired_player_state():
# def init_times():
# def update_time(key, time):
# def get_time(key):
# def init_mpd_lock():
# def get_mpd_lock():
# def release_mpd_lock():
# 
# Path: partify/models.py
# class PlayQueueEntry(db.Model):
#     """Represents a playlist queue entry. These only live until the track they represent is played,
#     then they are deleted.
# 
#     * **id**: The :class:`PlayQueueEntry`'s unique ID
#     * **track, track_id**: The track that is represented by this :class:`PlayQueueEntry`
#     * **user, user_id**: The user that queued this track
#     * **mpd_id**: The ID used by Mopidy internally for this queue entry
#     * **time_added**: The datetime that this track was queued
#     * **user_priority**: The priority of this track in the user's queue
#     * **playback_priority**: The playback priority in the global queue
#     """
#     __tablename__ = "play_queue_entry"
#     
#     id = db.Column(db.Integer, primary_key=True, autoincrement=True)
#     track_id = db.Column(db.Integer, db.ForeignKey('track.id'))
#     track = db.relationship("Track")
#     user_id = db.Column(db.Integer, db.ForeignKey('user.id'))
#     user = db.relationship("User")
#     mpd_id = db.Column(db.Integer)    # This SHOULD be unique... but since ensuring consistency isn't atomic yet we'll have to just best-effort it
#     time_added = db.Column(db.DateTime, default=datetime.datetime.now)
#     user_priority = db.Column(db.Integer, default=lambda: (db.session.query(db.func.max(PlayQueueEntry.user_priority)).first()[0] or 0) + 1)
#     playback_priority = db.Column(db.BigInteger, default=lambda: (db.session.query(db.func.max(PlayQueueEntry.playback_priority)).first()[0] or 0) + 1)
# 
#     def __repr__(self):
#         return "<Track %r (MPD %r) queued by %r at %r with priority %r (queue position %r)>" % (self.track, self.mpd_id, self.user, self.time_added, self.user_priority, self.playback_priority)
# 
#     def as_dict(self):
#         # I'm not sure why a list comprehension into a dict doesn't work here...
#         d = {}
#         for attr in ('title', 'artist', 'album', 'spotify_url', 'date', 'length'):
#             d[attr] = getattr(self.track, attr)
#         for attr in ('id', 'mpd_id', 'playback_priority', 'user_priority'):
#             d[attr] = getattr(self, attr)
#         d['time_added'] = self.time_added.ctime()
#         d['user'] = getattr(self.user, 'name', 'Anonymous')
#         d['username'] = getattr(self.user, 'username', 'anonymous')
#         d['user_id'] = self.user_id
#         return d
# 
# Path: testing/data/sample_tracks.py



import time
from multiprocessing import Event, Manager, Queue
from partify import ipc
from partify.models import PlayQueueEntry
from testing.data.sample_tracks import sample_tracks
        idle_event.set()
        idle_event.clear()
    
    def stop_idle(self):
        global idle_event
        idle_event.set()

    def connect(self, *args, **kwargs):
        connected = True
        return connected

    def disconnect(self):
        connected = False
        return connected

    def play(self):
        state = "play"

    def pause(self):
        state = "pause"

    def search(self, *args):
        search_keys = args[::2]
        search_args = args[1::2]

        key_translations = {'filename': 'file'}

        search_keys = [k if k not in key_translations else key_translations[k] for k in search_keys]
        
        results = []

# Path: partify/ipc.py
# def init_desired_player_state():
# def update_desired_player_state(state, transition_fn):
# def get_desired_player_state():
# def init_times():
# def update_time(key, time):
# def get_time(key):
# def init_mpd_lock():
# def get_mpd_lock():
# def release_mpd_lock():
# 
# Path: partify/models.py
# class PlayQueueEntry(db.Model):
#     """Represents a playlist queue entry. These only live until the track they represent is played,
#     then they are deleted.
# 
#     * **id**: The :class:`PlayQueueEntry`'s unique ID
#     * **track, track_id**: The track that is represented by this :class:`PlayQueueEntry`
#     * **user, user_id**: The user that queued this track
#     * **mpd_id**: The ID used by Mopidy internally for this queue entry
#     * **time_added**: The datetime that this track was queued
#     * **user_priority**: The priority of this track in the user's queue
#     * **playback_priority**: The playback priority in the global queue
#     """
#     __tablename__ = "play_queue_entry"
#     
#     id = db.Column(db.Integer, primary_key=True, autoincrement=True)
#     track_id = db.Column(db.Integer, db.ForeignKey('track.id'))
#     track = db.relationship("Track")
#     user_id = db.Column(db.Integer, db.ForeignKey('user.id'))
#     user = db.relationship("User")
#     mpd_id = db.Column(db.Integer)    # This SHOULD be unique... but since ensuring consistency isn't atomic yet we'll have to just best-effort it
#     time_added = db.Column(db.DateTime, default=datetime.datetime.now)
#     user_priority = db.Column(db.Integer, default=lambda: (db.session.query(db.func.max(PlayQueueEntry.user_priority)).first()[0] or 0) + 1)
#     playback_priority = db.Column(db.BigInteger, default=lambda: (db.session.query(db.func.max(PlayQueueEntry.playback_priority)).first()[0] or 0) + 1)
# 
#     def __repr__(self):
#         return "<Track %r (MPD %r) queued by %r at %r with priority %r (queue position %r)>" % (self.track, self.mpd_id, self.user, self.time_added, self.user_priority, self.playback_priority)
# 
#     def as_dict(self):
#         # I'm not sure why a list comprehension into a dict doesn't work here...
#         d = {}
#         for attr in ('title', 'artist', 'album', 'spotify_url', 'date', 'length'):
#             d[attr] = getattr(self.track, attr)
#         for attr in ('id', 'mpd_id', 'playback_priority', 'user_priority'):
#             d[attr] = getattr(self, attr)
#         d['time_added'] = self.time_added.ctime()
#         d['user'] = getattr(self.user, 'name', 'Anonymous')
#         d['username'] = getattr(self.user, 'username', 'anonymous')
#         d['user_id'] = self.user_id
#         return d
# 
# Path: testing/data/sample_tracks.py



# Path: testing/mocks/mock_mpd_client.py
import time
from multiprocessing import Event, Manager, Queue
from partify import ipc
from partify.models import PlayQueueEntry
from testing.data.sample_tracks import sample_tracks

        idle_event.set()
        idle_event.clear()
    
    def stop_idle(self):
        global idle_event
        idle_event.set()

    def connect(self, *args, **kwargs):
        connected = True
        return connected

    def disconnect(self):
        connected = False
        return connected

    def play(self):
        state = "play"

    def pause(self):
        state = "pause"

    def search(self, *args):
        search_keys = args[::2]
        search_args = args[1::2]

        key_translations = {'filename': 'file'}

        search_keys = [k if k not in key_translations else key_translations[k] for k in search_keys]
        
        results = []

        for track in sample_tracks: