Esempio n. 1
0
    def test_get_playing_track(self, twitter, track):
        spotify_mock = MagicMock()
        spotify_mock.get_current_track.return_value = track

        gorrion = Gorrion(spotify_mock, twitter, MagicMock())

        current_track = gorrion.get_playing_track()

        assert current_track == 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',
                ),
            ])
Esempio n. 2
0
    def test_publish_album(self, twitter, track):
        gorrion = Gorrion(MagicMock(), twitter, MagicMock())

        album_tweet = gorrion.publish_album(track)

        assert album_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',
                             ),
                         ]))
Esempio n. 3
0
def track():
    return Track(
        '1', 'Peligro', '', 'http://spotify.com/track/1', 1,
        Album(
            '11',
            'Pa morirse de amor',
            '',
            'http://spotify.com/album/11',
            '2006-01-01',
            19,
        ), [
            Artist(
                '12',
                'Ely Guerra',
                '',
                'http://spotify.com/artist/12',
            ),
        ])
Esempio n. 4
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),
        ]