コード例 #1
0
    def test_playing_album(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)
        tweet = gorrion.playing_album()

        assert tweet == PublishedTweet(
            id_='fake-status-id',
            tweet=('Now listening 🔊🎶:\n\n'
                   'Album: Pa morirse de amor\n'
                   'Artist: Ely Guerra\n'
                   'Tracks: 19\n'
                   'Release: 2006\n\n'
                   '#gorrion #NowPlaying #PaMorirseDeAmor #ElyGuerra\n\n'
                   'http://spotify.com/album/11?si=g'),
            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',
                             ),
                         ]))
コード例 #2
0
    def playing_album(self, chat_id: str, gorrion: Gorrion) -> None:
        song = gorrion.playing_album()

        self._bot.send_message(chat_id=chat_id, text=song.tweet)