Esempio n. 1
0
 def _similarity(self, threshold):
     return art.check_art_similarity(
         self.log,
         self.item,
         b'path',
         threshold,
         artresizer=self.artresizer,
     )
Esempio n. 2
0
    def test_imagemagick_response(self, mock_extract, mock_subprocess):
        mock_extract.return_value = True
        proc = mock_subprocess.Popen.return_value
        log = logging.getLogger('beets.embedart')

        # everything is fine
        proc.returncode = 0
        proc.communicate.return_value = "10", "tagada"
        self.assertTrue(art.check_art_similarity(log, None, None, 20))
        self.assertFalse(art.check_art_similarity(log, None, None, 5))

        # small failure
        proc.returncode = 1
        proc.communicate.return_value = "tagada", "10"
        self.assertTrue(art.check_art_similarity(log, None, None, 20))
        self.assertFalse(art.check_art_similarity(log, None, None, 5))

        # bigger failure
        proc.returncode = 2
        self.assertIsNone(art.check_art_similarity(log, None, None, 20))

        # IM result parsing problems
        proc.returncode = 0
        proc.communicate.return_value = "foo", "bar"
        self.assertIsNone(art.check_art_similarity(log, None, None, 20))

        proc.returncode = 1
        self.assertIsNone(art.check_art_similarity(log, None, None, 20))
Esempio n. 3
0
    def test_imagemagick_response(self, mock_extract, mock_subprocess):
        mock_extract.return_value = True
        proc = mock_subprocess.Popen.return_value
        log = logging.getLogger('beets.embedart')

        # everything is fine
        proc.returncode = 0
        proc.communicate.return_value = "10", "tagada"
        self.assertTrue(art.check_art_similarity(log, None, None, 20))
        self.assertFalse(art.check_art_similarity(log, None, None, 5))

        # small failure
        proc.returncode = 1
        proc.communicate.return_value = "tagada", "10"
        self.assertTrue(art.check_art_similarity(log, None, None, 20))
        self.assertFalse(art.check_art_similarity(log, None, None, 5))

        # bigger failure
        proc.returncode = 2
        self.assertIsNone(art.check_art_similarity(log, None, None, 20))

        # IM result parsing problems
        proc.returncode = 0
        proc.communicate.return_value = "foo", "bar"
        self.assertIsNone(art.check_art_similarity(log, None, None, 20))

        proc.returncode = 1
        self.assertIsNone(art.check_art_similarity(log, None, None, 20))
Esempio n. 4
0
 def _similarity(self, threshold):
     return art.check_art_similarity(self.log, self.item, b'path',
                                     threshold)