Beispiel #1
0
    def setUp(self):
        self.f = get_temp_copy(get_data_path('test.wma'))
        self.song = WMAFile(self.f)

        self.f2 = get_temp_copy(get_data_path('test-2.wma'))
        self.song2 = WMAFile(self.f2)

        self.f3 = get_temp_copy(get_data_path('test.asf'))
        self.song3 = WMAFile(self.f3)
    def setUp(self):
        self.f = get_temp_copy(get_data_path('test.wma'))
        self.song = WMAFile(self.f)

        self.f2 = get_temp_copy(get_data_path('test-2.wma'))
        self.song2 = WMAFile(self.f2)

        self.f3 = get_temp_copy(get_data_path('test.asf'))
        self.song3 = WMAFile(self.f3)
Beispiel #3
0
    def setUp(self):
        config.init()

        self.f = get_temp_copy(get_data_path('silence-44-s.ogg'))
        self.f2 = get_temp_copy(get_data_path('silence-44-s.mp3'))
        self.s = MusicFile(self.f)
        self.s2 = MusicFile(self.f2)

        fd, self.f3 = mkstemp(".mp3")
        os.write(fd, b"garbage")
        os.close(fd)
Beispiel #4
0
    def setUp(self):
        config.init()

        self.f = get_temp_copy(get_data_path('silence-44-s.ogg'))
        self.f2 = get_temp_copy(get_data_path('silence-44-s.mp3'))
        self.s = MusicFile(self.f)
        self.s2 = MusicFile(self.f2)

        fd, self.f3 = mkstemp(".mp3")
        os.write(fd, b"garbage")
        os.close(fd)
Beispiel #5
0
    def setUp(self):
        super(TOperonImageSet, self).setUp()
        from gi.repository import GdkPixbuf

        h, self.filename = mkstemp(".png")
        os.close(h)
        wide = GdkPixbuf.Pixbuf.new(GdkPixbuf.Colorspace.RGB, True, 8, 150, 10)
        wide.savev(self.filename, "png", [], [])

        self.fcover = get_temp_copy(get_data_path('test-2.wma'))
        self.cover = MusicFile(self.fcover)

        self.fcover2 = get_temp_copy(get_data_path('test-2.wma'))
        self.cover2 = MusicFile(self.fcover2)
Beispiel #6
0
    def setUp(self):
        super(TOperonImageSet, self).setUp()
        from gi.repository import GdkPixbuf

        h, self.filename = mkstemp(".png")
        os.close(h)
        wide = GdkPixbuf.Pixbuf.new(GdkPixbuf.Colorspace.RGB, True, 8, 150, 10)
        wide.savev(self.filename, "png", [], [])

        self.fcover = get_temp_copy(get_data_path('test-2.wma'))
        self.cover = MusicFile(self.fcover)

        self.fcover2 = get_temp_copy(get_data_path('test-2.wma'))
        self.cover2 = MusicFile(self.fcover2)
    def test_music_file(self):
        path = get_data_path('silence-44-s.mp3')
        self.assertTrue(formats.MusicFile(path))

        # non existing
        with capture_output() as (stdout, stderr):
            song = formats.MusicFile(get_data_path("nope.mp3"))
            self.assertFalse(song)
            self.assertTrue(stderr.getvalue())

        # unknown extension
        with capture_output() as (stdout, stderr):
            song = formats.MusicFile(get_data_path("nope.xxx"))
            self.assertFalse(song)
            self.assertFalse(stderr.getvalue())
    def test_music_file(self):
        path = get_data_path('silence-44-s.mp3')
        self.assertTrue(formats.MusicFile(path))

        # non existing
        with capture_output() as (stdout, stderr):
            song = formats.MusicFile(get_data_path("nope.mp3"))
            self.assertFalse(song)
            self.assertTrue(stderr.getvalue())

        # unknown extension
        with capture_output() as (stdout, stderr):
            song = formats.MusicFile(get_data_path("nope.xxx"))
            self.assertFalse(song)
            self.assertFalse(stderr.getvalue())
    def test_decode_all(self):
        """Decode all kinds of formats using Gstreamer, to check if
        they all work and to notify us if a plugin is missing on
        platforms where we control the packaging.
        """

        files = [
            "coverart.wv",
            "empty.aac",
            "empty.flac",
            "empty.ogg",
            "empty.opus",
            "silence-44-s.mpc",
            "silence-44-s.sv8.mpc",
            "silence-44-s.tta",
            "test.mid",
            "test.spc",
            "test.vgm",
            "test.wma",
            "silence-44-s.spx",
            "empty.xm",
        ]

        for file_ in files:
            path = get_data_path(file_)
            song = MusicFile(path)
            if song is not None:
                self._check(song)
Beispiel #10
0
    def test_watched_moving_dir(self):
        temp_dir = self.temp_path / "old"
        temp_dir.mkdir(exist_ok=False)
        sleep(0.2)
        run_gtk_loop()
        assert temp_dir in self.library._monitors
        with temp_filename(dir=temp_dir, suffix=".flac", as_path=True) as path:
            shutil.copy(Path(get_data_path("silence-44-s.flac")), path)
            sleep(0.2)
            assert path.exists()
            run_gtk_loop()
            assert str(path) in self.library, f"New path {path!s} didn't get added"
            assert len(self.added) == 1
            self.added.clear()
            assert self.library

            # Now move the directory...
            new_dir = path.parent.parent / "new"
            temp_dir.rename(new_dir)
            assert new_dir.is_dir(), "test should have moved to new dir"
            sleep(0.2)
            run_gtk_loop()

            new_path = new_dir / path.name
            assert new_path.is_file()
            msg = f"New path {new_path} not in library [{self.fns}]. Did move_root run?"
            assert str(new_path) in self.library, msg
            assert not self.removed, "A file was removed"
 def test_rename_to_existing(self):
     quux.rename(quux("~basename"))
     if os.name != "nt":
         self.failUnlessRaises(ValueError, quux.rename,
                               fsnative(u"/dev/null"))
     self.failUnlessRaises(ValueError, quux.rename,
                           get_data_path("silence-44-s.ogg"))
Beispiel #12
0
 def test_create_pixbuf(self):
     for name in self.IMAGES:
         file_path = get_data_path(name)
         pb = GdkPixbuf.Pixbuf.new_from_file(file_path)
         assert pb
         assert pb.get_width() == 16
         assert pb.get_height() == 16
Beispiel #13
0
    def test_decode_all(self):
        """Decode all kinds of formats using Gstreamer, to check if
        they all work and to notify us if a plugin is missing on
        platforms where we control the packaging.
        """

        files = [
            "coverart.wv",
            "empty.aac",
            "empty.flac",
            "empty.ogg",
            "empty.opus",
            "silence-44-s.mpc",
            "silence-44-s.sv8.mpc",
            "silence-44-s.tta",
            "test.mid",
            "test.spc",
            "test.vgm",
            "test.wma",
            "silence-44-s.spx",
            "empty.xm",
        ]

        for file_ in files:
            path = get_data_path(file_)
            song = MusicFile(path)
            if song is not None:
                self._check(song)
 def test_rename_to_existing(self):
     quux.rename(quux("~basename"))
     if os.name != "nt":
         self.failUnlessRaises(
             ValueError, quux.rename, fsnative(u"/dev/null"))
     self.failUnlessRaises(ValueError, quux.rename,
                           get_data_path("silence-44-s.ogg"))
 def test_feed(self):
     fn = get_data_path('valid_feed.xml')
     feed = Feed(pathlib.Path(fn).as_uri())
     result = feed.parse()
     self.failUnless(result)
     self.failUnlessEqual(len(feed), 2)
     self.failUnlessEqual(feed[0]('title'),
                          'Full Episode: Tuesday, November 28, 2017')
 def setUp(s):
     s.wide = GdkPixbuf.Pixbuf.new(GdkPixbuf.Colorspace.RGB, True, 8, 150,
                                   10)
     s.high = GdkPixbuf.Pixbuf.new(GdkPixbuf.Colorspace.RGB, True, 8, 10,
                                   100)
     s.small = GdkPixbuf.Pixbuf.new(GdkPixbuf.Colorspace.RGB, True, 8, 10,
                                    20)
     s.filename = get_data_path("test.png")
 def test_feed(self):
     fn = get_data_path('valid_feed.xml')
     feed = Feed(pathlib.Path(fn).as_uri())
     result = feed.parse()
     self.failUnless(result)
     self.failUnlessEqual(len(feed), 2)
     self.failUnlessEqual(feed[0]('title'),
                          'Full Episode: Tuesday, November 28, 2017')
 def setUp(s):
     s.wide = GdkPixbuf.Pixbuf.new(
         GdkPixbuf.Colorspace.RGB, True, 8, 150, 10)
     s.high = GdkPixbuf.Pixbuf.new(
         GdkPixbuf.Colorspace.RGB, True, 8, 10, 100)
     s.small = GdkPixbuf.Pixbuf.new(
         GdkPixbuf.Colorspace.RGB, True, 8, 10, 20)
     s.filename = get_data_path("test.png")
Beispiel #19
0
 def test_m4b_support(self):
     path = get_data_path('test.m4a')
     fd, filename = mkstemp(suffix='m4b')
     os.close(fd)
     shutil.copy(path, filename)
     self.song = MP4File(filename)
     assert self.song("~format") == "MPEG-4"
     self._assert_tag_supported("title")
Beispiel #20
0
 def test_get_link_target_unicode(self):
     path = get_data_path("test2.lnk")
     d = windows.get_link_target(path)
     self.assertTrue(isinstance(d, text_type))
     if is_wine():
         # wine doesn't support unicode paths here..
         self.assertEqual(os.path.basename(d), u"\xe1??.txt")
     else:
         self.assertEqual(os.path.basename(d), u"\xe1\U00016826.txt")
Beispiel #21
0
 def test_get_link_target_unicode(self):
     path = get_data_path("test2.lnk")
     d = windows.get_link_target(path)
     self.assertTrue(isinstance(d, unicode))
     if is_wine():
         # wine doesn't support unicode paths here..
         self.assertEqual(os.path.basename(d), u"\xe1??.txt")
     else:
         self.assertEqual(os.path.basename(d), u"\xe1\U00016826.txt")
def test_ma_file_old():
    s = MonkeysAudioFile(get_data_path('mac-396.ape'))

    assert s("~format") == "Monkey's Audio"
    assert s("~codec") == "Monkey's Audio"
    assert s("~encoding") == ""
    assert s("~#channels") == 2
    assert s("~#samplerate") == 44100
    # depends on the mutagen version
    assert s("~#bitdepth", 0) in (0, 16)
Beispiel #23
0
def test_ma_file_old():
    s = MonkeysAudioFile(get_data_path('mac-396.ape'))

    assert s("~format") == "Monkey's Audio"
    assert s("~codec") == "Monkey's Audio"
    assert s("~encoding") == ""
    assert s("~#channels") == 2
    assert s("~#samplerate") == 44100
    # depends on the mutagen version
    assert s("~#bitdepth", 0) in (0, 16)
Beispiel #24
0
 def test_parse_onesong(self):
     with temp_filename() as name:
         with open(name, "wb") as af:
             target = self.prefix
             target += fsn2bytes(get_data_path("silence-44-s.ogg"), "utf-8")
             af.write(target)
         with open(name, "rb") as f:
             pl = self.Parse(f, name, pl_lib=self.pl_lib)
     self.failUnlessEqual(len(pl), 1)
     self.failUnlessEqual(pl[0]("title"), "Silence")
     pl.delete()
Beispiel #25
0
 def test_feed(self):
     fn = get_data_path('valid_feed.xml')
     feed = Feed(fsn2uri(fn))
     result = feed.parse()
     # Assume en_US / en_GB locale here in tests
     self.failIfEqual(feed.name, "Unknown", msg="Didn't find feed name")
     # Do this after the above, as many exceptions can be swallowed
     self.failUnless(result)
     self.failUnlessEqual(len(feed), 2)
     self.failUnlessEqual(feed[0]('title'),
                          'Full Episode: Tuesday, November 28, 2017')
 def test_parse_onesong(self):
     with temp_filename() as name:
         with open(name, "wb") as af:
             target = self.prefix
             target += fsn2bytes(get_data_path("silence-44-s.ogg"), "utf-8")
             af.write(target)
         with open(name, "rb") as f:
             pl = self.Parse(f, name)
     self.failUnlessEqual(len(pl), 1)
     self.failUnlessEqual(pl[0]("title"), "Silence")
     pl.delete()
Beispiel #27
0
 def test_watched_adding(self):
     with temp_filename(dir=self.temp_path, suffix=".mp3", as_path=True) as path:
         shutil.copy(Path(get_data_path("silence-44-s.mp3")), path)
         assert self.temp_path in path.parents, "Copied test file incorrectly"
         watch_dirs = self.library._monitors.keys()
         assert path.parent in watch_dirs, "Not monitoring directory of new file"
         run_gtk_loop()
         assert self.library, f"Nothing in library despite watches on {watch_dirs}"
         assert str(path) in self.library, (f"{path!s} should have been added to "
                                            f"library [{self.fns}]")
         assert str(path) in {af("~filename") for af in self.added}
 def test_parse_onesong_uri(self):
     target = get_data_path("silence-44-s.ogg")
     target = fsn2uri(target).encode("ascii")
     target = self.prefix + target
     with temp_filename() as name:
         with open(name, "wb") as f:
             f.write(target)
         with open(name, "rb") as f:
             pl = self.Parse(f, name)
     self.failUnlessEqual(len(pl), 1)
     self.failUnlessEqual(pl[0]("title"), "Silence")
     pl.delete()
 def test_parse_onesong(self):
     h, name = mkstemp()
     os.close(h)
     with open(name, "wb") as f:
         target = self.prefix
         target += fsn2glib(get_data_path("silence-44-s.ogg"))
         f.write(target)
     list = self.Parse(name)
     os.unlink(name)
     self.failUnlessEqual(len(list), 1)
     self.failUnlessEqual(list[0]("title"), "Silence")
     list.delete()
Beispiel #30
0
 def test_parse_onesong_uri(self):
     target = get_data_path("silence-44-s.ogg")
     target = fsn2uri(target).encode("ascii")
     target = self.prefix + target
     with temp_filename() as name:
         with open(name, "wb") as f:
             f.write(target)
         with open(name, "rb") as f:
             pl = self.Parse(f, name, pl_lib=self.pl_lib)
     self.failUnlessEqual(len(pl), 1)
     self.failUnlessEqual(pl[0]("title"), "Silence")
     pl.delete()
Beispiel #31
0
 def test_parse_onesong(self):
     h, name = mkstemp()
     os.close(h)
     with open(name, "wb") as f:
         target = self.prefix
         target += fsn2bytes(get_data_path("silence-44-s.ogg"), "utf-8")
         f.write(target)
     list = self.Parse(name)
     os.unlink(name)
     self.failUnlessEqual(len(list), 1)
     self.failUnlessEqual(list[0]("title"), "Silence")
     list.delete()
Beispiel #32
0
 def test_parse_onesong_uri(self):
     h, name = mkstemp()
     os.close(h)
     target = get_data_path("silence-44-s.ogg")
     target = fsn2uri(target).encode("ascii")
     target = self.prefix + target
     with open(name, "wb") as f:
         f.write(target)
     list = self.Parse(name)
     os.unlink(name)
     self.failUnlessEqual(len(list), 1)
     self.failUnlessEqual(list[0]("title"), "Silence")
     list.delete()
 def test_parse_onesong_uri(self):
     h, name = mkstemp()
     os.close(h)
     target = get_data_path("silence-44-s.ogg")
     target = fsn2uri(target)
     target = self.prefix + target
     with open(name, "w") as f:
         f.write(target)
     list = self.Parse(name)
     os.unlink(name)
     self.failUnlessEqual(len(list), 1)
     self.failUnlessEqual(list[0]("title"), "Silence")
     list.delete()
    def setUp(self):
        config.init()

        self.main = mkdtemp()

        self.dir1 = mkdtemp(dir=self.main)
        self.dir2 = mkdtemp(dir=self.main)

        h, self.cover1 = mkstemp(".png", dir=self.main)
        os.close(h)
        pb = GdkPixbuf.Pixbuf.new(GdkPixbuf.Colorspace.RGB, True, 8, 10, 10)
        pb.savev(self.cover1, "png", [], [])

        h, self.cover2 = mkstemp(".png", dir=self.main)
        os.close(h)
        pb = GdkPixbuf.Pixbuf.new(GdkPixbuf.Colorspace.RGB, True, 8, 20, 20)
        pb.savev(self.cover2, "png", [], [])

        self.file1 = get_temp_copy(get_data_path('silence-44-s.mp3'))
        self.file2 = get_temp_copy(get_data_path('silence-44-s.mp3'))

        self.manager = CoverManager()
Beispiel #35
0
    def test_analyze_silence(self):
        song = MusicFile(get_data_path("silence-44-s.ogg"))
        self.failIf(song("~replaygain_track_gain"))

        self._analyse_song(song)

        self.failUnlessAlmostEqual(song("~#replaygain_track_peak"), 0.0, msg="Track peak should be 0.0")

        track_gain = song("~#replaygain_track_gain")
        self.failUnless(track_gain, msg="No Track Gain added")

        # For one-song album, track == album
        self.failUnlessEqual(track_gain, song("~#replaygain_album_gain"))
Beispiel #36
0
    def setUp(self):
        config.init()

        self.main = mkdtemp()

        self.dir1 = mkdtemp(dir=self.main)
        self.dir2 = mkdtemp(dir=self.main)

        h, self.cover1 = mkstemp(".png", dir=self.main)
        os.close(h)
        pb = GdkPixbuf.Pixbuf.new(GdkPixbuf.Colorspace.RGB, True, 8, 10, 10)
        pb.savev(self.cover1, "png", [], [])

        h, self.cover2 = mkstemp(".png", dir=self.main)
        os.close(h)
        pb = GdkPixbuf.Pixbuf.new(GdkPixbuf.Colorspace.RGB, True, 8, 20, 20)
        pb.savev(self.cover2, "png", [], [])

        self.file1 = get_temp_copy(get_data_path('silence-44-s.mp3'))
        self.file2 = get_temp_copy(get_data_path('silence-44-s.mp3'))

        self.manager = CoverManager()
 def test_reload_externally_modified(self):
     config.set("editing", "save_to_songs", True)
     fn = self.quux("~filename") + ".mp3"
     shutil.copy(get_data_path('silence-44-s.mp3'), fn)
     orig = MusicFile(fn)
     copy = MusicFile(fn)
     orig["~#rating"] = SOME_RATING
     copy["~#rating"] = ANOTHER_RATING
     orig.write()
     orig.reload()
     copy.reload()  # should pick up the change to the file
     assert orig("~#rating") == SOME_RATING, "reloading failed"
     assert copy(
         "~#rating") == SOME_RATING, "should have picked up external change"
Beispiel #38
0
    def test_analyze_silence(self):
        song = MusicFile(get_data_path("silence-44-s.ogg"))
        self.failIf(song("~replaygain_track_gain"))

        self._analyse_song(song)

        self.failUnlessAlmostEqual(song("~#replaygain_track_peak"), 0.0,
                                   msg="Track peak should be 0.0")

        track_gain = song("~#replaygain_track_gain")
        self.failUnless(track_gain, msg="No Track Gain added")

        # For one-song album, track == album
        self.failUnlessEqual(track_gain, song('~#replaygain_album_gain'))
Beispiel #39
0
    def test_analyze_sinewave(self):
        song = MusicFile(get_data_path("sine-110hz.flac"))
        self.failUnlessEqual(song("~#length"), 2)
        self.failIf(song("~replaygain_track_gain"))

        self._analyse_song(song)

        self.failUnlessAlmostEqual(song("~#replaygain_track_peak"), 1.0, msg="Track peak should be 1.0")

        track_gain = song("~#replaygain_track_gain")
        self.failUnless(track_gain, msg="No Track Gain added")
        self.failUnless(re.match(r"\-[0-9]\.[0-9]{1,2}", str(track_gain)))

        # For one-song album, track == album
        self.failUnlessEqual(track_gain, song("~#replaygain_album_gain"))
 def test_lyrics_mp3_is_not_a_valid_lyrics_file(self):
     # https://github.com/quodlibet/quodlibet/issues/3395
     fn = get_data_path('silence-44-s.mp3')
     with temp_filename() as filename:
         af = AudioFile(artist='bar', title='foo')
         af.sanitize(filename)
         lyrics_dir = os.path.dirname(af.lyric_filename)
         mkdir(lyrics_dir)
         try:
             with open(af.lyric_filename, "wb") as target:
                 with open(fn, "rb") as source:
                     target.write(source.read())
             assert "\0" not in af("~lyrics")
         finally:
             shutil.rmtree(lyrics_dir)
Beispiel #41
0
 def test_watched_adding_removing(self):
     with temp_filename(dir=self.temp_path, suffix=".mp3", as_path=True) as path:
         shutil.copy(Path(get_data_path("silence-44-s.mp3")), path)
         sleep(0.5)
         run_gtk_loop()
         assert path.exists()
         assert str(path) in self.library, f"{path} should be in [{self.fns}] now"
     assert not path.exists(), "Failed to delete test file"
     sleep(0.5)
     # Deletion now
     run_gtk_loop()
     assert self.removed, "Nothing was automatically removed"
     assert self.added, "Nothing was automatically added"
     assert {Path(af("~filename")) for af in self.added} == {path}
     assert {Path(af("~filename")) for af in self.removed} == {path}
     assert str(path) not in self.library, f"{path} shouldn't be in the library now"
Beispiel #42
0
    def test_analyze_sinewave(self):
        song = MusicFile(get_data_path("sine-110hz.flac"))
        self.failUnlessEqual(song("~#length"), 2)
        self.failIf(song("~replaygain_track_gain"))

        self._analyse_song(song)

        self.failUnlessAlmostEqual(song("~#replaygain_track_peak"), 1.0,
                                   msg="Track peak should be 1.0")

        track_gain = song("~#replaygain_track_gain")
        self.failUnless(track_gain, msg="No Track Gain added")
        self.failUnless(re.match(r'\-[0-9]\.[0-9]{1,2}', str(track_gain)))

        # For one-song album, track == album
        self.failUnlessEqual(track_gain, song('~#replaygain_album_gain'))
Beispiel #43
0
    def test_analyze_silence(self):
        pipeline = self.mod.analyze.FingerPrintPipeline()
        song = MusicFile(get_data_path("silence-44-s.ogg"))
        done = []

        def callback(self, *args):
            done.extend(args)
        pipeline.start(song, callback)
        t = time.time()
        while not done and time.time() - t < self.TIMEOUT:
            Gtk.main_iteration_do(False)
        self.assertTrue(done)
        s, result, error = done
        # silence doesn't produce a fingerprint
        self.assertTrue(error)
        self.assertFalse(result)
        self.assertTrue(song is s)
Beispiel #44
0
    def test_analyze_silence(self):
        pipeline = self.mod.analyze.FingerPrintPipeline()
        song = MusicFile(get_data_path("silence-44-s.ogg"))
        done = []

        def callback(self, *args):
            done.extend(args)
        pipeline.start(song, callback)
        t = time.time()
        while not done and time.time() - t < self.TIMEOUT:
            Gtk.main_iteration_do(False)
        self.assertTrue(done)
        s, result, error = done
        # silence doesn't produce a fingerprint
        self.assertTrue(error)
        self.assertFalse(result)
        self.assertTrue(song is s)
    def test_rename(self):
        old_fn = quux("~basename")
        new_fn = fsnative(u"anothersong.mp3")
        dir = os.path.dirname(get_data_path(""))
        self.failUnless(quux.exists())
        quux.rename(new_fn)
        self.failIf(os.path.exists(dir + old_fn),
                    "%s already exists" % (dir + old_fn))
        self.failUnless(quux.exists())
        quux.rename(old_fn)
        self.failIf(os.path.exists(dir + new_fn))
        self.failUnless(quux.exists())

        # move out of parent dir and back
        quux.rename(fsnative(u"/tmp/more_test_data"))
        self.failIf(os.path.exists(dir + old_fn))
        self.failUnless(quux.exists())
        quux.rename(dir + old_fn)
        self.failUnless(quux.exists())
    def test_rename(self):
        old_fn = quux("~basename")
        new_fn = fsnative(u"anothersong.mp3")
        dir = os.path.dirname(get_data_path(""))
        self.failUnless(quux.exists())
        quux.rename(new_fn)
        self.failIf(os.path.exists(dir + old_fn),
                    "%s already exists" % (dir + old_fn))
        self.failUnless(quux.exists())
        quux.rename(old_fn)
        self.failIf(os.path.exists(dir + new_fn))
        self.failUnless(quux.exists())

        # move out of parent dir and back
        quux.rename(fsnative(u"/tmp/more_test_data"))
        self.failIf(os.path.exists(dir + old_fn))
        self.failUnless(quux.exists())
        quux.rename(dir + old_fn)
        self.failUnless(quux.exists())
Beispiel #47
0
    def test_analyze_pool(self):
        pool = self.mod.analyze.FingerPrintPool()
        song = MusicFile(get_data_path("silence-44-s.ogg"))

        events = []

        def handler(*args):
            events.append(args)

        pool.connect("fingerprint-started", handler, "start")
        pool.connect("fingerprint-done", handler, "done")
        pool.connect("fingerprint-error", handler, "error")
        pool.push(song)

        t = time.time()
        while len(events) < 2 and time.time() - t < self.TIMEOUT:
            Gtk.main_iteration_do(False)

        self.assertEqual(len(events), 2)
        self.assertEqual(events[0][-1], "start")
        self.assertEqual(events[1][-1], "error")
Beispiel #48
0
    def test_analyze_pool(self):
        pool = self.mod.analyze.FingerPrintPool()
        song = MusicFile(get_data_path("silence-44-s.ogg"))

        events = []

        def handler(*args):
            events.append(args)

        pool.connect("fingerprint-started", handler, "start")
        pool.connect("fingerprint-done", handler, "done")
        pool.connect("fingerprint-error", handler, "error")
        pool.push(song)

        t = time.time()
        while len(events) < 2 and time.time() - t < self.TIMEOUT:
            Gtk.main_iteration_do(False)

        self.assertEqual(len(events), 2)
        self.assertEqual(events[0][-1], "start")
        self.assertEqual(events[1][-1], "error")
Beispiel #49
0
class TestMetaDataBase(TestCase):

    base = get_data_path("silence-44-s")

    def setUp(self):
        """Copy the base silent file to a temp name/location and load it"""

        config.init()
        fd, self.filename = mkstemp(suffix=self.ext, text=False)
        dst = os.fdopen(fd, 'wb')
        src = open(self.base + self.ext, 'rb')
        copyfileobj(src, dst)
        dst.close()
        self.song = formats.MusicFile(self.filename)

    def tearDown(self):
        """Delete the temp file"""

        os.remove(self.filename)
        del self.filename
        del self.song
        config.quit()
Beispiel #50
0
    def test_decode_all(self):
        """Decode all kinds of formats using Gstreamer, to check if
        they all work and to notify us if a plugin is missing on
        platforms where we control the packaging.
        """

        files = [
            "coverart.wv",
            "empty.aac",
            "empty.flac",
            "empty.ogg",
            "empty.opus",
            "silence-44-s.mpc",
            "silence-44-s.sv8.mpc",
            "silence-44-s.tta",
            # "test.mid",
            "test.spc",
            "test.vgm",
            "test.wma",
            "empty.xm",
            "h264_aac.mp4",
            "h265_aac.mp4"
        ]

        if not matches_flatpak_runtime("*org.gnome.*/3.32"):
            # https://gitlab.com/freedesktop-sdk/freedesktop-sdk/issues/809
            files.append("silence-44-s.spx")

        errors = []
        for file_ in files:
            path = get_data_path(file_)
            song = MusicFile(path)
            if song is not None:
                error = self._check(song)
                if error:
                    errors.append((song("~format"), error))

        if errors:
            raise Exception("Decoding failed %r" % errors)
Beispiel #51
0
    def test_decode_all(self):
        """Decode all kinds of formats using Gstreamer, to check if
        they all work and to notify us if a plugin is missing on
        platforms where we control the packaging.
        """

        files = [
            "coverart.wv",
            "empty.aac",
            "empty.flac",
            "empty.ogg",
            "empty.opus",
            "silence-44-s.mpc",
            "silence-44-s.sv8.mpc",
            "silence-44-s.tta",
            # "test.mid",
            "test.spc",
            "test.vgm",
            "test.wma",
            "silence-44-s.spx",
            "empty.xm",
            "h264_aac.mp4",
            "h265_aac.mp4"
        ]

        errors = []
        for file_ in files:
            path = get_data_path(file_)
            song = MusicFile(path)
            if song is not None:
                error = self._check(song)
                if error:
                    errors.append((song("~format"), error))

        if errors:
            raise Exception("Decoding failed %r" % errors)
Beispiel #52
0
from quodlibet.formats import AudioFile
from quodlibet.qltk.songmodel import PlaylistModel
from quodlibet.qltk.controls import Volume


FILES = [
    AudioFile({"~filename": fsnative(u"/foo/bar1"), "title": "1"}),
    AudioFile({"~filename": fsnative(u"/foo/bar2"), "title": "2"}),
    AudioFile({"~filename": fsnative(u"/foo/bar3"), "title": "3"}),
]
for file_ in FILES:
    file_.sanitize()

UNKNOWN_FILE = FILES.pop(-1)

REAL_FILE = AudioFile({"~filename": get_data_path("empty.ogg")})
REAL_FILE.sanitize()


class TPlayer(TestCase):
    NAME = None

    def setUp(self):
        config.init()
        config.set("player", "gst_pipeline", "fakesink")
        config.set("settings", "xine_driver", "none")
        module = player.init_backend(self.NAME)
        lib = library.init()
        self.player = module.init(lib.librarian)
        source = PlaylistModel()
        source.set(FILES)
Beispiel #53
0
 def setUp(self):
     self.song = ModFile(get_data_path("empty.xm"))
Beispiel #54
0
 def setUp(self):
     self.song = MPCFile(get_data_path('silence-44-s.mpc'))
     self.song2 = MPCFile(get_data_path('silence-44-s.sv8.mpc'))
 def __get_file(self):
     return get_temp_copy(get_data_path('empty.flac'))
 def setUp(self):
     self.song = MP3File(get_data_path('silence-44-s.mp3'))
     self.song2 = MP3File(get_data_path('test.mp2'))
     self.song3 = MP3File(get_data_path('lame.mp3'))
Beispiel #57
0
 def setUp(self):
     self.song = WAVEFile(get_data_path('test.wav'))
Beispiel #58
0
 def test_invalid(self):
     path = get_data_path('empty.xm')
     self.failUnless(os.path.exists(path))
     self.failUnlessRaises(Exception, WAVEFile, path)
 def test_invalid(self):
     path = get_data_path('empty.xm')
     self.assertTrue(os.path.exists(path))
     self.assertRaises(Exception, WMAFile, path)
Beispiel #60
0
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.

import os

from tests import TestCase, get_data_path

from quodlibet.formats import MusicFile, AudioFileError, EmbeddedImage

from .helper import get_temp_copy


FILES = [
    get_data_path("empty.ogg"),
    get_data_path("empty.flac"),
    get_data_path("silence-44-s.mp3"),
    get_data_path("silence-44-s.mpc"),
    get_data_path("test.wma"),
    get_data_path("coverart.wv"),
    get_data_path("test.m4a"),
    get_data_path("empty.opus"),
    get_data_path("silence-44-s.tta"),
    get_data_path("empty.aac"),
    get_data_path("test.mid"),
    get_data_path("test.wav"),
    get_data_path("silence-44-s.ape"),
    get_data_path("test.vgm"),
    get_data_path("silence-44-s.spx"),
    get_data_path("test.spc"),