Exemple #1
0
    def test_permission_errors(self):
        """Tests with missing write access"""
        personal_tagging.setup()
        image_url = personal_tagging.get_taggable_information(
            (physical_graffiti, physical_graffiti_cover))["image_url"]
        imagefile = personal_tagging.get_cover_image(image_url)
        filename = "01.ogg"
        shutil.copyfile(os.path.join("testlibrary", "testartist", "testalbum",
                                     "testfile.ogg"), filename)
        original_perms = os.stat(".").st_mode
        # Revoke write permissions on directory
        os.chmod(".", original_perms & ~stat.S_IWUSR)
        with self.assertRaises(PermissionError):
            personal_tagging.tag(filename, "Led Zeppelin", "Physical Graffiti",
                                 "1975", tracklist, imagefile)
        os.chmod(".", original_perms)

        original_perms = os.stat(filename).st_mode
        # Revoke write permissions on song
        os.chmod(filename, os.stat(filename).st_mode & ~stat.S_IWUSR)
        with self.assertRaises(PermissionError):
            personal_tagging.tag(filename, "Led Zeppelin", "Physical Graffiti",
                                 "1975", tracklist, imagefile)
        os.chmod(filename, original_perms)

        os.remove(filename)
        os.remove(imagefile)
Exemple #2
0
 def test_normal_input(self):
     """Test with normal input"""
     personal_tagging.setup()
     test_ids = personal_tagging.get_album_ids("Physical Graffiti",
                                               led_zeppelin, "Led Zeppelin")
     # release used for cover may change in the future
     self.assertIn(test_ids[0], physical_graffiti_possible)
Exemple #3
0
 def test_normal_input(self):
     """Tests with normal input"""
     self.maxDiff = None
     personal_tagging.setup()
     taggable_information = personal_tagging.get_taggable_information(
         (physical_graffiti, physical_graffiti_cover))
     self.assertEqual(expected_information, taggable_information)
Exemple #4
0
 def test_sanity(self):
     """Sanity check: Does it yield different IDs for different queries?"""
     personal_tagging.setup()
     test_ids = personal_tagging.get_album_ids("Let It Bleed",
                                               rolling_stones,
                                               "The Rolling Stones")
     for test_id in test_ids:
         self.assertNotIn(test_id, physical_graffiti_possible)
Exemple #5
0
 def test_value_error(self):
     """Test value error: Find an artist that does not exist"""
     personal_tagging.setup()
     with self.assertRaises(ValueError):
         personal_tagging.get_artist_id("I cannot think of a query where "
                                        "I can be certain such an artist "
                                        "will never exist but I think this "
                                        "does the job")
Exemple #6
0
 def test_sanity(self):
     """Sanity check: Does it yield different information for different
     queries?
     """
     personal_tagging.setup()
     taggable_information = personal_tagging.get_taggable_information(
         (let_it_bleed, let_it_bleed_cover))
     self.assertNotEqual(expected_information, taggable_information)
Exemple #7
0
 def test_normal_input(self):
     """Tests with normal input"""
     personal_tagging.setup()
     image_url = personal_tagging.get_taggable_information(
         (physical_graffiti, physical_graffiti_cover))["image_url"]
     imagefile = personal_tagging.get_cover_image(image_url)
     with PIL.Image.open(imagefile) as img:
         self.assertEqual(max(img.size), 600)
     self.assertRegex(imagefile, r".*\.png")
     os.remove(imagefile)
Exemple #8
0
 def test_permission_error(self):
     """Tests with missing write access"""
     personal_tagging.setup()
     original_perms = os.stat(".").st_mode
     # Revoke write permissions
     os.chmod(".", original_perms & ~stat.S_IWUSR)
     image_url = personal_tagging.get_taggable_information(
         (physical_graffiti, physical_graffiti_cover))["image_url"]
     with self.assertRaises(PermissionError):
         personal_tagging.get_cover_image(image_url)
     os.chmod(".", original_perms)
Exemple #9
0
 def test_not_given_format(self):
     """Tests with files that aren't the given format"""
     personal_tagging.setup()
     image_url = personal_tagging.get_taggable_information(
         (physical_graffiti, physical_graffiti_cover))["image_url"]
     imagefile = personal_tagging.get_cover_image(image_url)
     for extension in (".ogg", ".flac"):
         filename = "01" + extension
         open(filename, "w").close()
         with self.assertRaises(ValueError):
             personal_tagging.tag(filename, "Led Zeppelin",
                                  "Physical Graffiti", "1975", tracklist,
                                  imagefile)
         os.remove(filename)
     os.remove(imagefile)
Exemple #10
0
 def test_normal_input(self):
     """Tests with normal input"""
     personal_tagging.setup()
     image_url = personal_tagging.get_taggable_information(
         (physical_graffiti, physical_graffiti_cover))["image_url"]
     imagefile = personal_tagging.get_cover_image(image_url)
     for extension in ("ogg", "flac"):
         filename = "01 Custard Pie." + extension
         shutil.copyfile(os.path.join("testlibrary", "testartist",
                                      "testalbum", f"testfile.{extension}"),
                         filename)
         personal_tagging.tag(filename, "Led Zeppelin", "Physical Graffiti",
                              "1975", tracklist, imagefile)
         tags_dict = mutagen.File(filename)
         self.assertEqual(tags_dict["artist"][0], "Led Zeppelin")
         self.assertEqual(tags_dict["album"][0], "Physical Graffiti")
         self.assertEqual(tags_dict["tracknumber"][0], "01")
         self.assertEqual(tags_dict["title"][0], "Custard Pie")
         self.assertEqual(tags_dict["date"][0], "1975")
         os.remove(filename)
     os.remove(imagefile)
Exemple #11
0
 def test_sanity(self):
     """Sanity check: Does it yield different IDs for different queries?"""
     personal_tagging.setup()
     test_id = personal_tagging.get_artist_id("The Rolling Stones")
     self.assertNotEqual(test_id, led_zeppelin)
Exemple #12
0
 def test_normal_input(self):
     """Test with normal input"""
     personal_tagging.setup()
     test_id = personal_tagging.get_artist_id("Led Zeppelin")
     self.assertEqual(test_id, led_zeppelin)