コード例 #1
0
    def test_invalid_glob(self):
        config.set("albumart", "force_filename", str(True))
        config.set("albumart", "filename", "[a-2].jpg")

        # Should match
        f = self.add_file("[a-2].jpg")
        assert path_equal(os.path.abspath(self._find_cover(self.song).name), f)

        # Should not crash
        f = self.add_file("test.jpg")
        assert not path_equal(
            os.path.abspath(self._find_cover(self.song).name), f)
コード例 #2
0
ファイル: test_util_cover.py プロジェクト: LudoBike/quodlibet
    def test_invalid_glob(self):
        config.set("albumart", "force_filename", str(True))
        config.set("albumart", "filename", "[a-2].jpg")

        # Should match
        f = self.add_file("[a-2].jpg")
        assert path_equal(
            os.path.abspath(self._find_cover(self.song).name), f)

        # Should not crash
        f = self.add_file("test.jpg")
        assert not path_equal(
            os.path.abspath(self._find_cover(self.song).name), f)
コード例 #3
0
 def test_intelligent(self):
     song = self.song
     song["artist"] = "Q-Man"
     song["title"] = "First Q falls hardest"
     fns = ["Quuxly - back.jpg", "Quuxly.jpg", "q-man - quxxly.jpg",
               "folder.jpeg", "Q-man - Quuxly (FRONT).jpg"]
     for fn in fns:
         f = self.add_file(fn)
         cover = self._find_cover(song)
         if cover:
             actual = os.path.abspath(cover.name)
             assert path_equal(actual, f)
         else:
             # Here, no cover is better than the back...
             assert path_equal(f, self.full_path("Quuxly - back.jpg"))
コード例 #4
0
ファイル: test_util_cover.py プロジェクト: LudoBike/quodlibet
 def test_intelligent(self):
     song = self.song
     song["artist"] = "Q-Man"
     song["title"] = "First Q falls hardest"
     fns = ["Quuxly - back.jpg", "Quuxly.jpg", "q-man - quxxly.jpg",
               "folder.jpeg", "Q-man - Quuxly (FRONT).jpg"]
     for fn in fns:
         f = self.add_file(fn)
         cover = self._find_cover(song)
         if cover:
             actual = os.path.abspath(cover.name)
             assert path_equal(actual, f)
         else:
             # Here, no cover is better than the back...
             assert path_equal(f, self.full_path("Quuxly - back.jpg"))
コード例 #5
0
    def test_embedded_special_cover_words(self):
        """Tests that words incidentally containing embedded "special" words
        album keywords (e.g. cover, disc, back) don't trigger
        See Issue 818"""

        song = AudioFile({
            "~filename": fsnative(os.path.join(self.dir, u"asong.ogg")),
            "album": "foobar",
            "title": "Ode to Baz",
            "artist": "Q-Man",
        })
        data = [('back.jpg', False),
                ('discovery.jpg', False),
                ("Pharell - frontin'.jpg", False),
                ('nickelback - Curb.jpg', False),
                ('foobar.jpg', True),
                ('folder.jpg', True),  # Though this order is debatable
                ('Q-Man - foobar.jpg', True),
                ('Q-man - foobar (cover).jpg', True)]
        for fn, should_find in data:
            f = self.add_file(fn)
            cover = self._find_cover(song)
            if cover:
                actual = os.path.abspath(cover.name)
                assert path_equal(actual, f), \
                    f"{basename(f)!r} should trump {basename(actual)!r}"
            else:
                self.failIf(should_find, msg="Couldn't find %s for %s" %
                                             (f, song("~filename")))
コード例 #6
0
ファイル: test_util_cover.py プロジェクト: munya76/quodlibet
 def test_regular(self):
     for fn in ["cover.png", "folder.jpg", "frontcover.jpg",
                "front_folder_cover.gif", "jacket_cover.front.folder.jpeg"]:
         f = self.add_file(fn)
         assert path_equal(
             os.path.abspath(self._find_cover(self.song).name), f)
     self.test_labelid() # labelid must work with other files present
コード例 #7
0
ファイル: test_util_cover.py プロジェクト: LudoBike/quodlibet
 def test_regular(self):
     for fn in ["cover.png", "folder.jpg", "frontcover.jpg",
                "front_folder_cover.gif", "jacket_cover.front.folder.jpeg"]:
         f = self.add_file(fn)
         assert path_equal(
             os.path.abspath(self._find_cover(self.song).name), f)
     self.test_labelid() # labelid must work with other files present
コード例 #8
0
ファイル: test_util_cover.py プロジェクト: LudoBike/quodlibet
 def test_glob(self):
     config.set("albumart", "force_filename", str(True))
     config.set("albumart", "filename", "foo.*")
     for fn in ["foo.jpg", "foo.png"]:
         f = self.add_file(fn)
         assert path_equal(
             os.path.abspath(self._find_cover(self.song).name), f)
コード例 #9
0
 def test_glob(self):
     config.set("albumart", "force_filename", str(True))
     config.set("albumart", "filename", "foo.*")
     for fn in ["foo.jpg", "foo.png"]:
         f = self.add_file(fn)
         assert path_equal(
             os.path.abspath(self._find_cover(self.song).name), f)
コード例 #10
0
ファイル: test_util_cover.py プロジェクト: LudoBike/quodlibet
    def test_embedded_special_cover_words(self):
        """Tests that words incidentally containing embedded "special" words
        album keywords (e.g. cover, disc, back) don't trigger
        See Issue 818"""

        song = AudioFile({
            "~filename": fsnative(os.path.join(self.dir, u"asong.ogg")),
            "album": "foobar",
            "title": "Ode to Baz",
            "artist": "Q-Man",
        })
        data = [('back.jpg', False),
                ('discovery.jpg', False),
                ("Pharell - frontin'.jpg", False),
                ('nickelback - Curb.jpg', False),
                ('foobar.jpg', True),
                ('folder.jpg', True),  # Though this order is debatable
                ('Q-Man - foobar.jpg', True),
                ('Q-man - foobar (cover).jpg', True)]
        for fn, should_find in data:
            f = self.add_file(fn)
            cover = self._find_cover(song)
            if cover:
                actual = os.path.abspath(cover.name)
                assert path_equal(
                    actual, f, "\"%s\" should trump \"%s\"" % (f, actual))
            else:
                self.failIf(should_find, msg="Couldn't find %s for %s" %
                                             (f, song("~filename")))
コード例 #11
0
 def test_regular(self):
     for fn in ["cover.png", "folder.jpg", "Quuxly - front.png",
                "Quuxly_front_folder_cover.gif"]:
         f = self.add_file(fn)
         cover = self._find_cover(self.song)
         assert cover, f"No cover found after adding {fn}"
         assert path_equal(os.path.abspath(cover.name), f)
     self.test_labelid() # labelid must work with other files present
コード例 #12
0
    def test_multiple_entries(self):
        config.set("albumart", "force_filename", str(True))
        # the order of these is important, since bar should be
        # preferred to both 'foo' files
        # the spaces after the comma and last name are intentional
        config.set("albumart", "filename", "bar*,foo.png, foo.jpg ")

        for fn in ["foo.jpg", "foo.png", "bar.jpg"]:
            f = self.add_file(fn)
            assert path_equal(
                os.path.abspath(self._find_cover(self.song).name), f)
コード例 #13
0
ファイル: test_util_cover.py プロジェクト: LudoBike/quodlibet
 def test_multiple_people(self):
     song = AudioFile({
         "~filename": os.path.join(self.dir, "asong.ogg"),
         "album": "foobar",
         "title": "Ode to Baz",
         "performer": "The Performer",
         "artist": "The Composer\nThe Conductor",
         "composer": "The Composer",
     })
     for fn in ["foobar.jpg",
                "The Performer - foobar.jpg",
                "The Composer - The Performer - foobar.jpg",
                "The Composer - The Conductor, The Performer - foobar.jpg"]:
         f = self.add_file(fn)
         cover = self._find_cover(song)
         self.failUnless(cover)
         actual = os.path.abspath(cover.name)
         cover.close()
         assert path_equal(
             actual, f, "\"%s\" should trump \"%s\"" % (f, actual))
コード例 #14
0
    def test_invalid_glob_path(self):
        config.set("albumart", "force_filename", str(True))
        config.set("albumart", "filename", "*.jpg")

        # Make a dir which contains an invalid glob
        path = os.path.join(self.full_path("[a-2]"), "cover.jpg")
        mkdir(os.path.dirname(path))
        f = self.add_file(path)

        # Change the song's path to contain the invalid glob
        old_song_path = self.song['~filename']
        new_song_path = os.path.join(os.path.dirname(path),
                                     os.path.basename(old_song_path))
        self.song['~filename'] = new_song_path

        # The glob in the dirname should be ignored, while the
        # glob in the filename/basename is honored
        assert path_equal(os.path.abspath(self._find_cover(self.song).name), f)

        self.song['~filename'] = old_song_path
コード例 #15
0
 def test_multiple_people(self):
     song = AudioFile({
         "~filename": os.path.join(self.dir, "asong.ogg"),
         "album": "foobar",
         "title": "Ode to Baz",
         "performer": "The Performer",
         "artist": "The Composer\nThe Conductor",
         "composer": "The Composer",
     })
     for fn in ["foobar.jpg",
                "The Performer - foobar.jpg",
                "The Composer - The Performer - foobar.jpg",
                "The Composer - The Conductor, The Performer - foobar.jpg"]:
         f = self.add_file(fn)
         cover = self._find_cover(song)
         self.failUnless(cover)
         actual = os.path.abspath(cover.name)
         cover.close()
         assert path_equal(
             actual, f, "\"%s\" should trump \"%s\"" % (f, actual))
コード例 #16
0
ファイル: test_util_cover.py プロジェクト: LudoBike/quodlibet
    def test_invalid_glob_path(self):
        config.set("albumart", "force_filename", str(True))
        config.set("albumart", "filename", "*.jpg")

        # Make a dir which contains an invalid glob
        path = os.path.join(self.full_path("[a-2]"), "cover.jpg")
        mkdir(os.path.dirname(path))
        f = self.add_file(path)

        # Change the song's path to contain the invalid glob
        old_song_path = self.song['~filename']
        new_song_path = os.path.join(os.path.dirname(path),
                                     os.path.basename(old_song_path))
        self.song['~filename'] = new_song_path

        # The glob in the dirname should be ignored, while the
        # glob in the filename/basename is honored
        assert path_equal(
            os.path.abspath(self._find_cover(self.song).name), f)

        self.song['~filename'] = old_song_path
コード例 #17
0
ファイル: test_plugins_cover.py プロジェクト: bp0/quodlibet
 def is_embedded(fileobj):
     return not path_equal(fileobj.name, self.cover2, True)
コード例 #18
0
 def test_labelid(self):
     self.song["labelid"] = "12345"
     assert path_equal(os.path.abspath(self._find_cover(self.song).name),
                       self.full_path("12345.jpg"))
     del (self.song["labelid"])
コード例 #19
0
 def is_embedded(fileobj):
     return not path_equal(fileobj.name, self.cover2, True)
コード例 #20
0
 def is_embedded(self, fileobj):
     return not path_equal(fileobj.name, self.external_cover, True)
コード例 #21
0
 def is_embedded(self, fileobj):
     return not path_equal(fileobj.name, self.external_cover, True)
コード例 #22
0
ファイル: test_util_cover.py プロジェクト: LudoBike/quodlibet
 def test_labelid(self):
     self.song["labelid"] = "12345"
     assert path_equal(os.path.abspath(self._find_cover(self.song).name),
                       self.full_path("12345.jpg"))
     del(self.song["labelid"])