def test_masked_handling(self):
        if os.name == "nt":
            # FIXME: masking isn't properly implemented on Windows
            return
        # playlists can contain songs and paths for masked handling..
        lib = FileLibrary("foobar")
        pl = Playlist(self.temp, "playlist", lib)
        song = Fakesong({"date": "2038", "~filename": "/fake"})
        song.sanitize()
        lib.add([song])

        # mask and update
        lib.mask("/")
        pl.append(song)
        pl.remove_songs([song])
        self.failUnless("/fake" in pl)

        pl.extend(self.TWO_SONGS)

        # check if collections can handle the mix
        self.failUnlessEqual(pl("date"), "2038")

        # unmask and update
        lib.unmask("/")
        pl.add_songs(["/fake"], lib)
        self.failUnless(song in pl)

        pl.delete()
        lib.destroy()
Пример #2
0
 def test_album_key(self):
     album_key_tests = [
         ({}, ('', '', '')),
         ({
             'album': 'foo'
         }, (('foo', ), '', '')),
         ({
             'labelid': 'foo'
         }, ('', '', 'foo')),
         ({
             'musicbrainz_albumid': 'foo'
         }, ('', '', 'foo')),
         ({
             'album': 'foo',
             'labelid': 'bar'
         }, (('foo', ), '', 'bar')),
         ({
             'album': 'foo',
             'labelid': 'bar',
             'musicbrainz_albumid': 'quux'
         }, (('foo', ), '', 'bar')),
         ({
             'albumartist': 'a'
         }, ('', ('a', ), '')),
     ]
     for tags, expected in album_key_tests:
         afile = AudioFile(**tags)
         afile.sanitize(fsnative(u'/dir/fn'))
         self.failUnlessEqual(afile.album_key, expected)
Пример #3
0
    def test(self):
        lib = SongFileLibrary()

        with temp_filename() as song_fn:
            song = AudioFile({"~filename": song_fn})
            song.sanitize()
            lib.add([song])

            with temp_filename() as xml_fn:
                with open(xml_fn, "wb") as h:
                    x = get_example_xml(song("~filename"), 1, 1371802107)
                    h.write(x)

                handler = self.mod.RBDBContentHandler(lib)
                xml.sax.parse(xml_fn, handler)

                self.assertEqual(song("~#rating"), 0.2)
                self.assertEqual(song("~#lastplayed"), 1371802107)
                self.assertEqual(song("~#playcount"), 1)

                with open(xml_fn, "wb") as h:
                    x = get_example_xml(song("~filename"), 2, 1371802107 - 1)
                    h.write(x)

                handler = self.mod.RBDBContentHandler(lib)
                xml.sax.parse(xml_fn, handler)

                self.assertEqual(song("~#rating"), 0.4)
                self.assertEqual(song("~#lastplayed"), 1371802107)
Пример #4
0
 def test_msic(self):
     with realized(self.b):
         self.b.activate()
         self.b.statusbar(1000)
         self.b.statusbar(1)
         song = AudioFile({"~filename": fsnative(u"/fake")})
         song.sanitize()
         self.b.scroll(song)
 def setUp(self):
     config.init()
     player = NullPlayer()
     song = AudioFile()
     song.bookmarks = [(10, "bla")]
     song.sanitize("/")
     player.song = song
     self.player = player
Пример #6
0
 def test_menuitem(self):
     library = SongLibrary()
     library.librarian = SongLibrarian()
     a = AudioFile({"~filename": "/foo"})
     a.sanitize()
     x = RatingsMenuItem([a], library)
     x.set_rating(0, [a], library)
     x.destroy()
     library.destroy()
     library.librarian.destroy()
Пример #7
0
def _print_playing(app, fstring="<artist~album~tracknumber~title>"):
    from quodlibet.formats._audio import AudioFile
    from quodlibet.pattern import Pattern

    song = app.player.song
    if song is None:
        song = AudioFile({"~filename": fsnative(u"/")})
        song.sanitize()

    return Pattern(fstring).format(song) + "\n"
Пример #8
0
 def getline(key, value):
     song = AudioFile({"~filename": "/dev/null"})
     song.sanitize()
     song[key] = value
     lines = format_tags(song).splitlines()
     if not lines:
         return ""
     if len(lines) == 1:
         return lines[0]
     # hackery since title defaults to the filename..
     for l in lines:
         if not l.startswith("Title"):
             return l
Пример #9
0
 def test_sanitize(self):
     q = AudioFile(quux)
     b = AudioFile(bar_1_1)
     q.sanitize()
     b.pop('~filename')
     self.failUnlessRaises(ValueError, b.sanitize)
     n = AudioFile({
         "artist": u"foo\0bar",
         "title": u"baz\0",
         "~filename": fsnative(u"whatever")
     })
     n.sanitize()
     self.failUnlessEqual(n["artist"], "foo\nbar")
     self.failUnlessEqual(n["title"], "baz")
Пример #10
0
    def test_header_menu(self):
        from quodlibet import browsers
        from quodlibet.library import SongLibrary, SongLibrarian

        song = AudioFile({"~filename": fsnative(u"/dev/null")})
        song.sanitize()
        self.songlist.set_songs([song])

        library = SongLibrary()
        library.librarian = SongLibrarian()
        browser = browsers.get("EmptyBar")(library)

        self.songlist.set_column_headers(["foo"])

        self.assertFalse(self.songlist.Menu("foo", browser, library))
        sel = self.songlist.get_selection()
        sel.select_all()
        self.assertTrue(self.songlist.Menu("foo", browser, library))
Пример #11
0
# -*- coding: utf-8 -*-
from gi.repository import Gtk

from tests import TestCase

from quodlibet.formats._audio import AudioFile
from quodlibet.util.path import fsnative
from quodlibet.qltk.delete import DeleteDialog, TrashDialog, TrashMenuItem

SONG = AudioFile({"~filename": fsnative(u"/dev/null")})
SONG.sanitize()


class TDeleteDialog(TestCase):
    def test_delete_songs(self):
        dialog = DeleteDialog.for_songs(None, [])
        dialog.destroy()

    def test_delete_files(self):
        dialog = DeleteDialog.for_files(None, [])
        dialog.destroy()

    def test_trash_songs(self):
        dialog = TrashDialog.for_songs(None, [])
        dialog.destroy()

    def test_trash_files(self):
        dialog = TrashDialog.for_files(None, [])
        dialog.destroy()

    def test_delete_songs_full(self):
Пример #12
0
from quodlibet import player
from quodlibet import app

A1 = AudioFile({
    'album': u'greatness',
    'title': 'excellent',
    'artist': 'fooman\ngo',
    '~#lastplayed': 1234,
    '~#rating': 0.75,
    '~filename': '/foo a/b',
    "~#length": 123,
    "albumartist": "aa\nbb",
    "bpm": "123.5",
    "tracknumber": "6/7"
})
A1.sanitize()

A2 = AudioFile({
    'album': u'greatness2\ufffe',
    'title': 'superlative',
    'artist': u'fooman\ufffe',
    '~#lastplayed': 1234,
    '~#rating': 1.0,
    '~filename': '/foo'
})
A2.sanitize()


class TMPRIS(PluginTestCase):
    @classmethod
    def setUpClass(cls):
def AF(*args, **kwargs):
    a = AudioFile(*args, **kwargs)
    a.sanitize()
    return a