1# -*- coding: utf-8 -*- 2# 3# Picard, the next-generation MusicBrainz tagger 4# 5# Copyright (C) 2006-2007 Lukáš Lalinský 6# Copyright (C) 2013, 2018 Laurent Monin 7# Copyright (C) 2016 Christoph Reiter 8# Copyright (C) 2018 Wieland Hoffmann 9# Copyright (C) 2019 Philipp Wolfer 10# 11# This program is free software; you can redistribute it and/or 12# modify it under the terms of the GNU General Public License 13# as published by the Free Software Foundation; either version 2 14# of the License, or (at your option) any later version. 15# 16# This program is distributed in the hope that it will be useful, 17# but WITHOUT ANY WARRANTY; without even the implied warranty of 18# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19# GNU General Public License for more details. 20# 21# You should have received a copy of the GNU General Public License 22# along with this program; if not, write to the Free Software 23# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 24 25 26from mutagen import id3 27 28from test.picardtestcase import PicardTestCase 29 30from picard.formats.id3 import id3text 31from picard.formats.mutagenext import compatid3 32 33 34class UpdateToV23Test(PicardTestCase): 35 36 def test_id3text(self): 37 self.assertEqual(id3text(u"\u1234", 0), u"?") 38 self.assertEqual(id3text(u"\u1234", 1), u"\u1234") 39 self.assertEqual(id3text(u"\u1234", 2), u"\u1234") 40 self.assertEqual(id3text(u"\u1234", 3), u"\u1234") 41 42 def test_keep_some_v24_tag(self): 43 tags = compatid3.CompatID3() 44 tags.add(id3.TSOP(encoding=0, text=["foo"])) 45 tags.add(id3.TSOA(encoding=0, text=["foo"])) 46 tags.add(id3.TSOT(encoding=0, text=["foo"])) 47 tags.update_to_v23() 48 self.assertEqual(tags["TSOP"].text, ["foo"]) 49 self.assertEqual(tags["TSOA"].text, ["foo"]) 50 self.assertEqual(tags["TSOT"].text, ["foo"]) 51 52 def test_tdrc(self): 53 tags = compatid3.CompatID3() 54 tags.add(id3.TDRC(encoding=1, text="2003-04-05 12:03")) 55 tags.update_to_v23() 56 self.assertEqual(tags["TYER"].text, ["2003"]) 57 self.assertEqual(tags["TDAT"].text, ["0504"]) 58 self.assertEqual(tags["TIME"].text, ["1203"]) 59 60 def test_tdor(self): 61 tags = compatid3.CompatID3() 62 tags.add(id3.TDOR(encoding=1, text="2003-04-05 12:03")) 63 tags.update_to_v23() 64 self.assertEqual(tags["TORY"].text, ["2003"]) 65 66 def test_genre_from_v24_1(self): 67 tags = compatid3.CompatID3() 68 tags.add(id3.TCON(encoding=1, text=["4", "Rock"])) 69 tags.update_to_v23() 70 self.assertEqual(tags["TCON"].text, ["Disco", "Rock"]) 71 72 def test_genre_from_v24_2(self): 73 tags = compatid3.CompatID3() 74 tags.add(id3.TCON(encoding=1, text=["RX", "3", "CR"])) 75 tags.update_to_v23() 76 self.assertEqual(tags["TCON"].text, ["Remix", "Dance", "Cover"]) 77 78 def test_genre_from_v23_1(self): 79 tags = compatid3.CompatID3() 80 tags.add(id3.TCON(encoding=1, text=["(4)Rock"])) 81 tags.update_to_v23() 82 self.assertEqual(tags["TCON"].text, ["Disco", "Rock"]) 83 84 def test_genre_from_v23_2(self): 85 tags = compatid3.CompatID3() 86 tags.add(id3.TCON(encoding=1, text=["(RX)(3)(CR)"])) 87 tags.update_to_v23() 88 self.assertEqual(tags["TCON"].text, ["Remix", "Dance", "Cover"]) 89