Ejemplo n.º 1
0
    def test_check_failed_exit_code(self):
        MockChecker.install()
        self.addIntegrityFailFixture()

        with self.assertRaises(SystemExit) as exit:
            beets.ui._raw_main(['check', '--external'])
        self.assertEqual(exit.exception.code, 15)
Ejemplo n.º 2
0
    def test_check_failed_exit_code(self):
        MockChecker.install()
        self.addIntegrityFailFixture()

        with self.assertRaises(SystemExit) as exit:
            beets.ui._raw_main(['check', '--external'])
        self.assertEqual(exit.exception.code, 15)
Ejemplo n.º 3
0
    def test_no_integrity_checkers_warning(self):
        MockChecker.installNone()
        self.addIntegrityFailFixture()

        with self.assertRaises(UserError) as error:
            beets.ui._raw_main(['check', '--external'])

        self.assertIn('No integrity checkers found.', error.exception.args[0])
Ejemplo n.º 4
0
    def test_no_integrity_checkers_warning(self):
        MockChecker.installNone()
        self.addIntegrityFailFixture()

        with self.assertRaises(UserError) as error:
            beets.ui._raw_main(['check', '--external'])

        self.assertIn('No integrity checkers found.', error.exception.args[0])
Ejemplo n.º 5
0
    def test_integrity_warning(self):
        MockChecker.install()
        self.addIntegrityFailFixture()

        with self.assertRaises(SystemExit):
            with captureLog() as logs:
                beets.ui._raw_main(['check', '--external'])

        self.assertIn('WARNING file is corrupt', '\n'.join(logs))
Ejemplo n.º 6
0
    def test_add_shows_integrity_warning(self):
        MockChecker.install()
        item = self.addIntegrityFailFixture(checksum=False)

        with captureLog() as logs:
            beets.ui._raw_main(['check', '-a'])

        self.assertIn('WARNING file is corrupt: {}'.format(item.path),
                      '\n'.join(logs))
Ejemplo n.º 7
0
    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())
Ejemplo n.º 8
0
    def test_integrity_warning(self):
        MockChecker.install()
        self.addIntegrityFailFixture()

        with self.assertRaises(SystemExit):
            with captureLog() as logs:
                beets.ui._raw_main(['check', '--external'])

        self.assertIn('WARNING file is corrupt', '\n'.join(logs))
Ejemplo n.º 9
0
    def test_add_shows_integrity_warning(self):
        MockChecker.install()
        item = self.addIntegrityFailFixture(checksum=False)

        with captureLog() as logs:
            beets.ui._raw_main(['check', '-a'])

        self.assertIn('WARNING file is corrupt: {}'.format(item.path),
                      '\n'.join(logs))
Ejemplo n.º 10
0
    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())
Ejemplo n.º 11
0
    def test_quiet_skip_corrupt_files(self):
        MockChecker.install()
        self.setupImportDir(['ok.mp3', 'truncated.mp3'])

        with self.mockAutotag(), captureLog() as logs:
            beets.ui._raw_main(['import', '-q', self.import_dir])

        self.assertIn('Warning: failed to verify integrity', logs)
        self.assertIn('truncated.mp3: file is corrupt\nSkipping.', '\n'.join(logs))
        self.assertEqual(len(self.lib.items()), 0)
Ejemplo n.º 12
0
    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')
Ejemplo n.º 13
0
    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')
Ejemplo n.º 14
0
    def test_quiet_skip_corrupt_files(self):
        MockChecker.install()
        self.setupImportDir(['ok.mp3', 'truncated.mp3'])

        with self.mockAutotag(), captureLog() as logs:
            beets.ui._raw_main(['import', '-q', self.import_dir])

        self.assertIn('check: Warning: failed to verify integrity', logs)
        self.assertIn('truncated.mp3: file is corrupt\ncheck: Skipping.',
                      '\n'.join(logs))
        self.assertEqual(len(self.lib.items()), 0)
Ejemplo n.º 15
0
    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)
Ejemplo n.º 16
0
    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)
Ejemplo n.º 17
0
    def test_add_shows_integrity_warning(self):
        MockChecker.install()

        item = self.lib.items('truncated').get()
        del item['checksum']
        item.store()

        with captureLog() as logs:
            beets.ui._raw_main(['check', '-a'])

        self.assertIn('WARNING file is corrupt: {}'.format(item.path),
                      '\n'.join(logs))
Ejemplo n.º 18
0
    def test_write_on_integrity_error(self):
        MockChecker.install()

        item = self.lib.items(u'truncated').get()

        item['title'] = 'newtitle'
        item.store()
        beets.ui._raw_main(['write', item.title])

        item.load()
        verify_checksum(item)
        mediafile = MediaFile(item.path)
        self.assertEqual(mediafile.title, 'newtitle')
Ejemplo n.º 19
0
    def test_write_on_integrity_error(self):
        MockChecker.install()

        item = self.lib.items(u'truncated').get()

        item['title'] = 'newtitle'
        item.store()
        beets.ui._raw_main(['write', item.title])

        item.load()
        verify_checksum(item)
        mediafile = MediaFile(item.path)
        self.assertEqual(mediafile.title, 'newtitle')
Ejemplo n.º 20
0
 def tearDown(self):
     super(ImportTest, self).tearDown()
     MockChecker.restore()
Ejemplo n.º 21
0
 def tearDown(self):
     super(ImportTest, self).tearDown()
     MockChecker.restore()