def test_calls_queue(mocked_request, connected_device): music_playback_service = NodeMusicPlaybackService(connected_device) tracks = [Track.from_dict({'uri':'uri{}'.format(str(i))})for i in range(10)] music_playback_service.queue(connected_device, tracks) assert mocked_request.get.call_count == len(tracks)
def test_calls_queue(mocked_request, connected_device): music_playback_service = NodeMusicPlaybackService(connected_device) tracks = [ Track.from_dict({'uri': 'uri{}'.format(str(i))}) for i in range(10) ] music_playback_service.queue(connected_device, tracks) assert mocked_request.get.call_count == len(tracks)
def test_generate_correct_url_query_for_get_method(connected_device): music_playback_service = NodeMusicPlaybackService(connected_device) track = Track.from_dict({'uri': 'uri'}) expected_query = "http://localhost:5005/Antho Room/spotify/now/uri" actual_query = music_playback_service._generate_play_now_query(track) assert expected_query == actual_query
logging.info(play_music_request) response = use_case.execute(play_music_request) if not response: hermes.publish_end_session(intentMessage.session_id, FR_TTS_SHORT_ERROR) else: hermes.publish_end_session(intentMessage.session_id, response.feedback) if __name__ == "__main__": configuration = read_configuration_file("config.ini") client_id = configuration['secret']['client_id'] client_secret = configuration['secret']['client_secret'] with Hermes(HERMES_HOST) as h: h.device_discovery_service = NodeDeviceDiscoveryService() h.device_transport_control_service = NodeDeviceTransportControlService() h.music_search_service = SpotifyMusicSearchService(client_id, client_secret) h.music_playback_service = NodeMusicPlaybackService() h \ .subscribe_session_started(hotword_detected_callack) \ .subscribe_intent("playMusic4", playMusic_callback) \ .subscribe_intent("volumeUp4", volumeUp_callback) \ .subscribe_intent("volumeDown4", volumeDown_callback) \ .subscribe_intent("volumeSet4", volumeSet_callback) \ .subscribe_intent("muteSound4", mute_callback) \ .subscribe_intent("resumeMusic4", resumeMusic_callback) \ .subscribe_intent("speakerInterrupt4", speakerInterrupt_callback) \ .subscribe_intent("nextSong4", nextSong_callback) \ .loop_forever()
def test_music_playback_service_initialization(connected_device): music_playback_service = NodeMusicPlaybackService(connected_device) assert music_playback_service.PORT == NodeMusicPlaybackService.PORT assert music_playback_service.HOST == NodeMusicPlaybackService.HOST assert music_playback_service.PROTOCOL == NodeMusicPlaybackService.PROTOCOL