|
| 1 | +# -*- coding: utf-8 -*- |
| 2 | +# |
| 3 | +# Picard, the next-generation MusicBrainz tagger |
| 4 | +# |
| 5 | +# Copyright (C) 2024 Philipp Wolfer |
| 6 | +# |
| 7 | +# This program is free software; you can redistribute it and/or |
| 8 | +# modify it under the terms of the GNU General Public License |
| 9 | +# as published by the Free Software Foundation; either version 2 |
| 10 | +# of the License, or (at your option) any later version. |
| 11 | +# |
| 12 | +# This program is distributed in the hope that it will be useful, |
| 13 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 | +# GNU General Public License for more details. |
| 16 | +# |
| 17 | +# You should have received a copy of the GNU General Public License |
| 18 | +# along with this program; if not, write to the Free Software |
| 19 | +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
| 20 | + |
| 21 | +import os.path |
| 22 | + |
| 23 | +from test.picardtestcase import PicardTestCase |
| 24 | + |
| 25 | +from picard.formats import util |
| 26 | +from picard.formats.id3 import MP3File |
| 27 | + |
| 28 | + |
| 29 | +class FormatsOpenTest(PicardTestCase): |
| 30 | + def setUp(self): |
| 31 | + super().setUp() |
| 32 | + self.set_config_values({'enabled_plugins': []}) |
| 33 | + |
| 34 | + def test_open(self): |
| 35 | + file_path = os.path.join('test', 'data', 'test.mp3') |
| 36 | + filename = self.copy_file_tmp(file_path, '.mp3') |
| 37 | + filetype = util.open_(filename) |
| 38 | + self.assertIsInstance(filetype, MP3File) |
| 39 | + |
| 40 | + def test_open_no_extension(self): |
| 41 | + file_path = os.path.join('test', 'data', 'test.mp3') |
| 42 | + filename = self.copy_file_tmp(file_path, '') |
| 43 | + filetype = util.open_(filename) |
| 44 | + self.assertIsInstance(filetype, MP3File) |
| 45 | + |
| 46 | + def test_open_unknown_extension(self): |
| 47 | + file_path = os.path.join('test', 'data', 'test.mp3') |
| 48 | + filename = self.copy_file_tmp(file_path, '.fake') |
| 49 | + filetype = util.open_(filename) |
| 50 | + self.assertIsInstance(filetype, MP3File) |
| 51 | + |
| 52 | + def test_open_unknown_type(self): |
| 53 | + file_path = os.path.join('test', 'data', 'mb.png') |
| 54 | + filename = self.copy_file_tmp(file_path, '.ogg') |
| 55 | + filetype = util.open_(filename) |
| 56 | + self.assertIsNone(filetype) |
0 commit comments