<s> import json <EOL> from . import AbstractSchedulerClient <EOL> from . states import JobState , TransitionError <EOL> jobs = { } <EOL> class MockSchedulerClient ( AbstractSchedulerClient ) : <EOL> def create ( self , name , image , command , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> jobs . setdefault ( name , { } ) [ '<STR_LIT:state>' ] = JobState . created <EOL> def destroy ( self , name ) : <EOL> """<STR_LIT>""" <EOL> jobs . setdefault ( name , { } ) [ '<STR_LIT:state>' ] = JobState . destroyed <EOL> def run ( self , name , image , entrypoint , command ) : <EOL> """<STR_LIT>""" <EOL> return <NUM_LIT:0> , json . dumps ( { <EOL> '<STR_LIT:name>' : name , <EOL> '<STR_LIT:image>' : image , <EOL> '<STR_LIT>' : entrypoint , <EOL> '<STR_LIT>' : command , <EOL> } ) <EOL> def start ( self , name ) : <EOL> """<STR_LIT>""" <EOL> if self . state ( name ) not in [ JobState . created , <EOL> JobState . up , <EOL> JobState . down , <EOL> JobState . crashed , <EOL> JobState . error ] : <EOL> raise TransitionError ( self . state ( name ) , <EOL> JobState . up , <EOL> '<STR_LIT>' ) <EOL> jobs . setdefault ( name , { } ) [ '<STR_LIT:state>' ] = JobState . up <EOL> def state ( self , name ) : <EOL> """<STR_LIT>""" <EOL> return jobs . get ( name , { } ) . get ( '<STR_LIT:state>' , JobState . initialized ) <EOL> def stop ( self , name ) : <EOL> """<STR_LIT>""" <EOL> job = jobs . get ( name , { } ) <EOL> if job . get ( '<STR_LIT:state>' ) not in [ JobState . up , JobState . crashed , JobState . error ] : <EOL> raise TransitionError ( job . get ( '<STR_LIT:state>' ) , <EOL> JobState . up , <EOL> '<STR_LIT>' ) <EOL> job [ '<STR_LIT:state>' ] = JobState . down <EOL> SchedulerClient = MockSchedulerClient </s>
