def test_load_states(self): config = Configuration() personality = Personality(config) personality.do_not_save = True states = [{ "name": "introduction" },{ "type": "audio", "title": "Live Radio", "filename": "live_stream.json", "on_enter": "You are now listening to live radio.", "on_empty": "There are no radio stations available." }, { "type": "audio", "title": "Saved Programmes", "playlist": { "tracks": [ { "directory": "%HOME%/Radio_Uncompressed/keep", "extensions": "m4a", "include-subdir": True } ], "orderby": "name" }, "on_enter": "You are now listening to your favourites.", "on_empty": "There are no favourites chosen yet." }, { "type": "audio", "title": "Latest Programmes", "playlist": { "tracks": [ { "directory": "%HOME%/Radio_Uncompressed/tmp", "extensions": "m4a", "include-subdir": True } ], "orderby": ["date", "desc"] }, "on_enter": "You are now listening to the latest programmes.", "on_empty": "There are no programmes downloaded yet." } ] personality.set_states(states) item = StatesFactory.create(config, personality) context = UserContext(item) context.personality = personality config.context = context logging.debug("Starting state context") context.start() for ii in range(0,4): time.sleep(3) logging.debug("************* Next state context {}".format(ii)) context.on_play_down() context.on_play_up()
def test_load_states(self): config = Configuration() personality = Personality(config) personality.do_not_save = True item = StatesFactory.create(config, personality) context = UserContext(item) context.personality = personality config.context = context logging.debug("Starting state context") context.start() for ii in range(0,len(personality.json["states"])): time.sleep(3) logging.debug("************* Next state context {}".format(ii)) context.on_play_down() context.on_play_up() time.sleep(3)
def test_play(self): config = Configuration() p = Personality(config) state = SpeakingClockState(config, p) state.on_enter(); time.sleep(12) state.on_exit();
def test_play(self): config = Configuration() p = Personality(config) state = IntroductionState.create(config, p, {}) state.on_enter() time.sleep(3) state.on_exit()
def test_move_automatically_onto_next_track(self): config = Configuration() p = Personality(config) empty_playlist = { "type": "audio", "title": "Test progress", "filename": "checkpoint2.json", "playlist": { "tracks": [{ "directory": "/home/pi/Music/dance", "extensions": ["m4a", "wav"], "include-subdir": True }], "orderby": ["date", "desc"] }, "on_enter": "You are now listening to a test list.", "on_empty": "There are no favourites chosen yet." } state = PlaylistStreamState.create(config, p, empty_playlist) logging.debug("creating") print(state.json) state.on_enter() time.sleep(15) state.is_finished() time.sleep(15) state.is_finished() time.sleep(15) print(state.json)
def test_play(self): config = Configuration() p = Personality(config) state = EndState() state.on_enter() time.sleep(3) state.on_exit()
def test_play(self): config = Configuration() p = Personality(config) state = AnnounceState(config, p) state.message = "Testing announcement" state.on_enter() time.sleep(3) state.on_exit()
def test_play(self): config = Configuration() p = Personality(config) state_config = { "name": "audio", "title": "Latest Programmes", "path": "%HOME%/Radio_Uncompressed/tmp", "extensions": "m4a", "orderby": ["date", "desc"] } state = AudioState.create(config, p, state_config) state.on_enter() time.sleep(3) state.on_exit()
def test_empty_list(self): config = Configuration() p = Personality(config) state = LiveStreamState.create(config, p, {}) empty_playlist = {"playlist": []} state.json = empty_playlist state.on_enter() for attempt in range(0, 2): time.sleep(3) logging.debug( "attempting to move to next track in empty livestream") state.on_next_track_down() state.on_next_track_up() time.sleep(3) state.on_exit()
def test_play(self): """Test the alarm by itself""" config = Configuration() p = Personality(config) now = datetime.datetime.now() logging.debug(now) one_minute_from_now = now + datetime.timedelta(minutes=1) one_minute_from_now_str = one_minute_from_now.strftime("%H:%M") logging.debug(one_minute_from_now) logging.debug(one_minute_from_now_str) alarm_schedule = [ { "when": [ one_minute_from_now_str ], "action": "play", "args": { "track": CURDIR+"/../../sounds/piano2.m4a", "run_once": True } } ] config.alarm.update_schedule(alarm_schedule) config.alarm.start() logging.debug("please wait, while we test the alarm") time.sleep(90)
def test_midnight_3(self): config = Configuration() p = Personality(config) state = SpeakingClockState(config, p) when = datetime.datetime.today() state.tell(when.replace(hour=0,minute=54))
def test_midday_2(self): config = Configuration() p = Personality(config) state = SpeakingClockState(config, p) when = datetime.datetime.today() state.tell(when.replace(day=3,hour=12,minute=13))
def test_evening(self): config = Configuration() p = Personality(config) state = SpeakingClockState(config, p) when = datetime.datetime.today() state.tell(when.replace(hour=19,minute=23))