def test_handle_intent_by_song(self): song = "And I Told Them I Invented Times New Roman" emby_croft = EmbyCroft(HOST, USERNAME, PASSWORD) songs = emby_croft.handle_intent(song, IntentType.SONG) assert songs is not None assert len(songs) is 1
def test_handle_intent_by_song_mock(self): with mock.patch('requests.post') as MockRequestsPost: auth_server_response = TestEmbyCroft.mocked_responses["emby"]["3.5.2.0"]["auth_server_response"] response = MockResponse(200, auth_server_response) MockRequestsPost.return_value = response emby_croft = EmbyCroft(HOST, USERNAME, PASSWORD) search_response = TestEmbyCroft.mocked_responses["emby"]["4.4.3.0"]["song_search"][ "search_response"] with mock.patch('requests.get') as MockRequestsGet: responses = [MockResponse(200, search_response)] MockRequestsGet.side_effect = responses songs = emby_croft.handle_intent("test", IntentType.SONG) assert songs assert len(songs) == 1
def test_instant_mix_mock(self): with mock.patch('requests.post') as MockRequestsPost: auth_server_response = TestEmbyCroft.mocked_responses["emby"]["3.5.2.0"]["auth_server_response"] search_response = TestEmbyCroft.mocked_responses["emby"]["3.5.2.0"]["search_response"] get_songs_response = TestEmbyCroft.mocked_responses["emby"]["3.5.2.0"]["get_songs_response"] album = "This is how the wind shifts" response = MockResponse(200, auth_server_response) MockRequestsPost.return_value = response emby_croft = EmbyCroft(HOST, USERNAME, PASSWORD) with mock.patch('requests.get') as MockRequestsGet: responses = [MockResponse(200, search_response), MockResponse(200, get_songs_response)] MockRequestsGet.side_effect = responses songs = emby_croft.handle_intent(album, IntentType.MEDIA) assert songs is not None assert len(songs) is 1
def test_find_songs_by_artist_mock(self): with mock.patch('requests.post') as MockRequestsPost: auth_server_response = TestEmbyCroft.mocked_responses["emby"]["3.5.2.0"]["auth_server_response"] response = MockResponse(200, auth_server_response) MockRequestsPost.return_value = response emby_croft = EmbyCroft(HOST, USERNAME, PASSWORD) search_response = TestEmbyCroft.mocked_responses["emby"]["3.5.2.0"]["artist_search"][ "search_response"] get_songs_response = TestEmbyCroft.mocked_responses["emby"]["3.5.2.0"]["artist_search"][ "songs_response"] with mock.patch('requests.get') as MockRequestsGet: responses = [MockResponse(200, search_response), MockResponse(200, get_songs_response)] MockRequestsGet.side_effect = responses songs = emby_croft.handle_intent("dance gavin dance", IntentType.ARTIST) assert songs assert len(songs) == 4
def test_handle_intent_by_album(self): album = "deadweight" emby_croft = EmbyCroft(HOST, USERNAME, PASSWORD) songs = emby_croft.handle_intent(album, IntentType.ALBUM) assert songs is not None
def test_handle_intent_by_artist(self): artist = "dance gavin dance" emby_croft = EmbyCroft(HOST, USERNAME, PASSWORD) songs = emby_croft.handle_intent(artist, IntentType.ARTIST) assert songs is not None
def test_handle_intent_by_playlist(self): playlist = "xmas music" emby_croft = EmbyCroft(HOST, USERNAME, PASSWORD) songs = emby_croft.handle_intent(playlist, IntentType.PLAYLIST) assert songs is not None