def test_add_corrupt_files(self): MockChecker.install() self.setupImportDir(['ok.mp3', 'truncated.mp3']) with self.mockAutotag(), controlStdin('n'): beets.ui._raw_main(['import', self.import_dir]) self.assertEqual(len(self.lib.items()), 2) item = self.lib.items(u'truncated').get() mediafile = MediaFile(item.path) self.assertEqual(mediafile.title, 'truncated tag')
def test_update_after_keep_new_convert(self): item = self.lib.items(u'ok.ogg').get() verify_checksum(item) with controlStdin('y'): beets.ui._raw_main(['convert', '--keep-new', 'ok.ogg']) converted = self.lib.items(u'ok.ogg').get() self.assertNotEqual(converted.path, item.path) self.assertNotEqual(converted.checksum, item.checksum) verify_checksum(converted)
def test_update_all_confirmation_no(self): self.setupFixtureLibrary() item = self.lib.items().get() orig_checksum = item['checksum'] self.modifyFile(item.path) with controlStdin(u'n'): beets.ui._raw_main(['check', '--update']) item.load() self.assertEqual(item['checksum'], orig_checksum)
def test_skip_corrupt_files(self): MockChecker.install() self.setupImportDir(['ok.mp3', 'truncated.mp3']) with self.mockAutotag(), controlStdin(' '), \ captureStdout() as stdout, captureLog() as logs: beets.ui._raw_main(['import', self.import_dir]) self.assertIn('check: Warning: failed to verify integrity', logs) self.assertIn('truncated.mp3: file is corrupt', '\n'.join(logs)) self.assertIn('Do you want to skip this album', stdout.getvalue()) self.assertEqual(len(self.lib.items()), 0)
def test_update_all_confirmation(self): self.setupFixtureLibrary() item = self.lib.items().get() orig_checksum = item['checksum'] self.modifyFile(item.path) with captureStdout() as stdout, controlStdin(u'y'): beets.ui._raw_main(['check', '--update']) self.assertIn('Do you want to overwrite all checksums', stdout.getvalue()) item.load() self.assertNotEqual(item['checksum'], orig_checksum) verify_checksum(item)
def test_fix_integrity(self): item = self.addIntegrityFailFixture() with self.assertRaises(SystemExit), captureLog() as logs: beets.ui._raw_main(['check', '-e']) self.assertIn('WARNING It seems that file is truncated', '\n'.join(logs)) with controlStdin(u'y'), captureLog() as logs: beets.ui._raw_main(['check', '--fix']) self.assertIn(item.path.decode('utf-8'), '\n'.join(logs)) self.assertIn('FIXED: {}'.format(item.path.decode('utf-8')), '\n'.join(logs)) with captureLog() as logs: beets.ui._raw_main(['check', '-e']) self.assertNotIn('WARNING It seems that file is truncated', '\n'.join(logs))
def test_convert_command(self): with controlStdin('y'): beets.ui._raw_main(['convert', 'ok.ogg'])
def test_do_not_fix(self): item = self.addIntegrityFailFixture() with controlStdin(u'n'): beets.ui._raw_main(['check', '--fix']) verify_checksum(item)