Exemplo n.º 1
0
    def playing_with_lyrics(self, chat_id: str, gorrion: Gorrion) -> None:
        tweets = gorrion.playing_with_lyrics()
        song, *lyrics = tweets

        self._bot.send_message(chat_id=chat_id, text=song.tweet)
        if lyrics:
            for lyric in lyrics:
                self._bot.send_message(chat_id=chat_id, text=lyric.tweet)
Exemplo n.º 2
0
    def test_playing_with_lyric(self, twitter, track, song, lyric):
        spotify_mock = MagicMock()
        spotify_mock.get_current_track.return_value = track

        musixmatch_mock = MagicMock()
        song.lyric = lyric
        musixmatch_mock.fetch_lyric.return_value = song

        gorrion = Gorrion(spotify_mock, twitter, musixmatch_mock)
        tweets = gorrion.playing_with_lyrics()

        assert tweets == [
            PublishedTweet(
                id_='fake-status-id',
                tweet=('Now listening 🔊🎶:\n\n'
                       'Track: 1. Peligro\n'
                       'Album: Pa morirse de amor\n'
                       'Artist: Ely Guerra\n\n'
                       '#gorrion #NowPlaying #ElyGuerra\n\n'
                       'http://spotify.com/track/1'),
                entity=Track(id_='1',
                             name='Peligro',
                             href='',
                             public_url='http://spotify.com/track/1',
                             track_number=1,
                             album=Album(
                                 id_='11',
                                 name='Pa morirse de amor',
                                 href='',
                                 public_url='http://spotify.com/album/11',
                                 release_date='2006-01-01',
                                 total_tracks=19,
                             ),
                             artists=[
                                 Artist(
                                     id_='12',
                                     name='Ely Guerra',
                                     href='',
                                     public_url='http://spotify.com/artist/12',
                                 ),
                             ])),
            PublishedTweet(id_='fake-status-id', tweet='lyric1', entity=None),
            PublishedTweet(id_='fake-status-id', tweet='lyric2', entity=None),
        ]