def test_keys(self):
        """
        Test is the keyboard picks up on arrow keys, requires user input
        :return:
        """
        setup_logging()

        k = KeyboardListener()
        k.start()
        time.sleep(3)
        k.stop()
    def test_play_intertwined_fail_2(self):
        setup_logging()
        test_config = os.path.join(CURDIR, "test_conf_simple", "config.json")
        globalvars.app_state = AppState.create_from_file(test_config)
        audio = AudioPlayer(globalvars.app_state)
        track = "/home/pi/smartbot/sounds/Marconi_Union-Weightless.mp3"
        seek = 10
        audio2 = AudioPlayer(globalvars.app_state)
        track2 = "/home/pi/smartbot/sounds/Marconi_Union-Weightless.mp3"
        seek2 = 60

        audio.play(track2, seek2)
        self.assertRaises(ValueError, audio2.play, track, seek)
 def test_mplayer_process_completes(self):
     setup_logging()
     mplayer_config_path = os.path.join(CURDIR, "test_conf_simple",
                                        "mplayer.json")
     test_config = os.path.join(CURDIR, "test_conf_simple", "config.json")
     globalvars.app_state = AppState.create_from_file(test_config)
     fifo_directory = "/home/pi/.config/smartbot/fifos"
     track = "/home/pi/smartbot/sounds/piano2.m4a"
     seek = 0  # this track is 6 seconds long
     player = MPlayerProcess(mplayer_config_path, fifo_directory)
     self.assertFalse(player.has_track_completed())
     player.play(track, seek)
     print(player.timer.elapsedTime())
     self.assertFalse(player.has_track_completed())
     print(player.timer.elapsedTime())
     time.sleep(2)
     print(player.timer.elapsedTime())
     self.assertFalse(player._is_alive())
     print(player.timer.elapsedTime())
     self.assertTrue(player.has_track_completed())
     print(player.timer.elapsedTime())
     self.assertEqual(7, player.get_duration())
     player = None
Beispiel #4
0
 def test_create_from_dict(self):
     values = {
         "config": {
             "owner": "Innogen",
             "personality": "personality.json",
             "devices": {
                 "path": "devices.json"
             },
             "output": {
                 "sink": "org.bluez",
                 "device": "D0:8A:55:00:9C:27"
             },
             "alarms": []
         },
         "personality": {
             "name":
             "April",
             "conf": {
                 "festival": {
                     "voice": "voice_kal_diphone"
                 },
                 "language": "en"
             },
             "sleep": {
                 "enabled":
                 True,
                 "begin": {
                     "hard": "09:00",
                     "soft": "09:30"
                 },
                 "end":
                 "20:25",
                 "on_enter":
                 "%SMARTBOT%/sounds/Marconi_Union-Weightless-sleepversion.mp3",
                 "on_end":
                 "Silence",
                 "phrases": [
                     "Its only %T, go back to sleep Innogen.",
                     "Its not quite morning Innogen, go back to sleep",
                     "Its really early Innogen, go back to sleep"
                 ]
             },
             "states": [{
                 "type": "introduction",
                 "filename": "introduction.json"
             }, {
                 "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",
                 "filename": "saved_programmes.json",
                 "playlist": {
                     "tracks": [{
                         "directory": "%SMARTBOT%/media/radio",
                         "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",
                 "filename":
                 "latest_programmes.json",
                 "playlist": {
                     "tracks": [{
                         "directory": "%SMARTBOT%/media/recent",
                         "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."
             }, {
                 "type": "audio",
                 "title": "Lets Dance",
                 "filename": "lets_dance.json",
                 "playlist": {
                     "tracks": [{
                         "directory": "%SMARTBOT%/media/lets_dance",
                         "extensions": "m4a",
                         "include-subdir": True
                     }],
                     "orderby": ["name", "asc"]
                 },
                 "on_enter": "Let's Dance!",
                 "on_empty": "There are no songs available yet."
             }, {
                 "type": "speakingclock",
                 "title": "Speaking Clock",
                 "on_enter": False
             }, {
                 "type": "facts",
                 "title": "Funky Facts",
                 "filename": "facts_*.json",
                 "on_enter": {
                     "type": "sound",
                     "path": "%SMARTBOT%/sounds/gojetters-funkyfacts.wav"
                 },
                 "on_empty": "There are no funky facts available."
             }]
         },
         "Lets Dance": {
             "tracks": {}
         }
     }
     setup_logging()
     state = AppState.create_from_dict(values)
     self.assertEqual(dict, type(state.dev_specified_configuration))
Beispiel #5
0
 def setUp(self) -> None:
     state = AppState.create_from_file(
         os.path.join(CURDIR, "test_conf_simple", "config.json"))
     globalvars.app_state = state
     setup_logging()