def test_export(self): self.setupFixtureLibrary() with captureStdout() as stdout: beets.ui._raw_main(['check', '--export']) item = self.lib.items().get() self.assertIn( '{} *{}\n'.format(item.checksum, item.path.decode('utf-8')), stdout.getvalue())
def test_print_integrity_checkers(self): MockChecker.install() self.addIntegrityFailFixture() with self.assertRaises(SystemExit): with captureStdout() as stdout: beets.ui._raw_main(['check', '--external']) self.assertIn('Using integrity checker mock', stdout.getvalue())
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_check_success(self): self.setupFixtureLibrary() with captureStdout() as stdout: beets.ui._raw_main(['check']) self.assertEqual('All checksums successfully verified', stdout.getvalue().split('\n')[-2])
def test_oggz_validate_not_found(self): with captureStdout() as stdout: beets.ui._raw_main(['check', '--list-tools']) self.assertRegexpMatches(stdout.getvalue(), r'oggz-validate *not found')
def test_found_mp3val(self): shutil.copy('/bin/echo', os.path.join(self.temp_dir, 'mp3val')) with captureStdout() as stdout: beets.ui._raw_main(['check', '--list-tools']) self.assertRegexpMatches(stdout.getvalue(), r'mp3val *found')
def test_list(self): with captureStdout() as stdout: beets.ui._raw_main(['check', '--list-tools']) self.assertIn('mp3val', stdout.getvalue()) self.assertIn('flac', stdout.getvalue()) self.assertIn('oggz-validate', stdout.getvalue())
def test_nothing_to_fix(self): self.addItemFixture('ok.ogg') with captureStdout() as stdout: beets.ui._raw_main(['check', '--fix', '--force']) self.assertIn('No MP3 files to fix', stdout.getvalue())