Exemplo n.º 1
0
 def setup(self):
     link = 'https://dl.dropboxusercontent.com/u/1371559/test/audio.mp3'
     self.gears = Gears(
         logger=logging.getLogger('temp.log'),
         hist_file='tem.p'
     )
     self.song = self.gears.download(link)
     self.song.meta.tag.artist = u'Demo Artist www.trashyurl.com'
     self.song.meta.tag.title += u'www.trashyurl.net'
     self.song.meta.tag.album_artist = u'Various www.trashyurl.ru'
     self.song.meta.tag.comments.set(
         u'DOWNLOAD THINGS FROM MY BLOG.WORDPRESS.ORG'
         )
     self.song.save()
     with open('test.txt', 'wb') as _:
         pass
     self.not_song = Song('test.txt')
Exemplo n.º 2
0
class TestSong(object):
    def setup(self):
        link = 'https://dl.dropboxusercontent.com/u/1371559/test/audio.mp3'
        self.gears = Gears(
            logger=logging.getLogger('temp.log'),
            hist_file='tem.p'
        )
        self.song = self.gears.download(link)
        self.song.meta.tag.artist = u'Demo Artist www.trashyurl.com'
        self.song.meta.tag.title += u'www.trashyurl.net'
        self.song.meta.tag.album_artist = u'Various www.trashyurl.ru'
        self.song.meta.tag.comments.set(
            u'DOWNLOAD THINGS FROM MY BLOG.WORDPRESS.ORG'
            )
        self.song.save()
        with open('test.txt', 'wb') as _:
            pass
        self.not_song = Song('test.txt')

    def teardown(self):
        os.remove(self.song.loc)
        os.remove('test.txt')
        os.remove('tem.p')
        if os.path.exists('temp.log'):
            os.remove('temp.log')

    def test_song_init(self):
        song = Song(self.song.loc, logger=None)
        assert isinstance(song, Song)

    def test_type(self):
        eq_(type(self.song), Song)

    def test_scrub(self):
        val = u'The Carpenters www.cahulhousemafia.net'
        eq_(u'The Carpenters', scrub(val))

    def test_edm_scrub(self):
        self.song.edm_scrubber()
        assert u'.com' not in self.song.meta.tag.artist
        assert u'.net' not in self.song.meta.tag.title
        assert u'.ru' not in self.song.meta.tag.album_artist
        assert not self.song.meta.tag.comments[0].text

    def test_grouping(self):
        self.song.set_grouping('Jacques Jamms Tracklist')
        audio = ID3(self.song.loc)
        assert 'Jacques Jamms' in audio['TIT1'].text[0]

    def test_grouping_err(self):
        eq_(self.not_song.set_grouping('literally anything'), False)

    def test_del_comment(self):
        self.song.del_comment()
        assert not self.song.meta.tag.comments[0].text

    def test_del_comment_err(self):
        result = self.not_song.del_comment()
        eq_(result, False)

    def test_song_repr(self):
        string = self.song.__repr__()
        assert string.startswith('<Song')

    def test_song_save_err(self):
        # if save fails, result is false
        result = self.not_song.save()
        eq_(result, False)

    def test_reverse_naming(self):
        self.song.meta.tag.artist = u''
        self.song.meta.tag.title = u'Demo Artist - Demo Song'
        self.song.save()
        self.song.reverse_naming()
        eq_(self.song.meta.tag.artist, 'Demo Artist')
        eq_(self.song.meta.tag.title, 'Demo Song')