コード例 #1
0
 def test_apply_match_uses_album_path(self):
     coro = importer.apply_choices(_common.iconfig(self.lib))
     coro.next()  # Prime coroutine.
     _call_apply(coro, [self.i], self.info)
     self.assertExists(
         os.path.join(self.libdir,
                      self.lib.path_formats['default'] + '.mp3'))
コード例 #2
0
 def test_apply_as_tracks_uses_singleton_path(self):
     coro = importer.apply_choices(_common.iconfig(self.lib))
     coro.next()  # Prime coroutine.
     self._call_apply_choice(coro, [self.i], importer.action.TRACKS)
     self.assertExists(
         os.path.join(self.libdir,
                      self.lib.path_formats['singleton'] + '.mp3'))
コード例 #3
0
    def _apply_result(self):
        """Run the "apply" coroutine and get the resulting Album."""
        coro = importer.apply_choices(self.config)
        coro.next()
        _call_apply_choice(coro, self.items, importer.action.ASIS)

        return self.lib.albums()[0]
コード例 #4
0
ファイル: test_importer.py プロジェクト: Thynix/beets
    def test_reimport_inside_file_moves_and_does_not_add_to_old_paths(self):
        """Reimporting a file *inside* the library directory should
        *move* the file.
        """
        # Add the item to the library while inside the library directory.
        internal_srcpath = os.path.join(self.libdir, 'source.mp3')
        shutil.move(self.srcpath, internal_srcpath)
        temp_item = library.Item.from_path(internal_srcpath)
        self.lib.add(temp_item)
        self.lib.conn.commit()

        self.i = library.Item.from_path(internal_srcpath)
        self.i.comp = False

        # Then, re-import the same file.
        coro = importer.apply_choices(_common.iconfig(self.lib))
        coro.next()
        task = _call_apply(coro, [self.i], self.info)

        # Old file should be gone.
        self.assertNotExists(internal_srcpath)
        # New file should be present.
        self.assertExists(os.path.join(self.libdir, 'one.mp3'))
        # Also, the old file should not be in old_paths because it does
        # not exist.
        self.assertEqual(task.old_paths, [])
コード例 #5
0
ファイル: test_importer.py プロジェクト: refreshoxford/beets
    def _apply_result(self):
        """Run the "apply" coroutine and get the resulting Album."""
        coro = importer.apply_choices(self.config)
        coro.next()
        _call_apply_choice(coro, self.items, importer.action.ASIS)

        return self.lib.albums()[0]
コード例 #6
0
ファイル: test_importer.py プロジェクト: navinpai/beets
 def test_apply_match_uses_album_path(self):
     coro = importer.apply_choices(_common.iconfig(self.lib))
     coro.next() # Prime coroutine.
     _call_apply(coro, [self.i], self.info)
     self.assertExists(
         os.path.join(self.libdir, self.lib.path_formats['default']+'.mp3')
     )
コード例 #7
0
 def test_finalize_with_delete(self):
     config = _common.iconfig(self.lib, delete=True)
     applyc = importer.apply_choices(config)
     applyc.next()
     finalize = importer.finalize(config)
     finalize.next()
     _call_apply([applyc, finalize], [self.i], self.info)
     self.assertNotExists(self.srcpath)
コード例 #8
0
ファイル: test_importer.py プロジェクト: coolkehon/beets
 def test_finalize_with_delete_prunes_directory_empty(self):
     config = _common.iconfig(self.lib, delete=True)
     applyc = importer.apply_choices(config)
     applyc.next()
     finalize = importer.finalize(config)
     finalize.next()
     _call_apply([applyc, finalize], [self.i], self.info, self.srcdir)
     self.assertNotExists(os.path.dirname(self.srcpath))
コード例 #9
0
ファイル: test_importer.py プロジェクト: nidico/beets
 def test_apply_with_move_prunes_empty_directory(self):
     config = _common.iconfig(self.lib, move=True)
     applyc = importer.apply_choices(config)
     applyc.next()
     finalize = importer.finalize(config)
     finalize.next()
     _call_apply([applyc], [self.i], self.info, self.srcdir)
     self.assertNotExists(os.path.dirname(self.srcpath))
コード例 #10
0
ファイル: test_importer.py プロジェクト: refreshoxford/beets
 def test_finalize_with_delete(self):
     config = _common.iconfig(self.lib, delete=True)
     applyc = importer.apply_choices(config)
     applyc.next()
     finalize = importer.finalize(config)
     finalize.next()
     _call_apply([applyc, finalize], [self.i], self.info)
     self.assertNotExists(self.srcpath)
コード例 #11
0
ファイル: test_importer.py プロジェクト: coolkehon/beets
    def test_apply_tracks_uses_singleton_path(self):
        coro = importer.apply_choices(_common.iconfig(self.lib))
        coro.next()  # Prime coroutine.

        task = importer.ImportTask.item_task(self.i)
        task.set_choice(self.info.tracks[0])
        coro.send(task)

        self.assertExists(os.path.join(self.libdir, 'three.mp3'))
コード例 #12
0
ファイル: test_importer.py プロジェクト: domenkozar/beets
    def test_apply_tracks_uses_singleton_path(self):
        coro = importer.apply_choices(_common.iconfig(self.lib))
        coro.next()  # Prime coroutine.

        task = importer.ImportTask.item_task(self.i)
        task.set_choice(self.info.tracks[0])
        coro.send(task)

        self.assertExists(os.path.join(self.libdir, "three.mp3"))
コード例 #13
0
ファイル: test_importer.py プロジェクト: nidico/beets
 def test_apply_with_move(self):
     config = _common.iconfig(self.lib, move=True)
     applyc = importer.apply_choices(config)
     applyc.next()
     finalize = importer.finalize(config)
     finalize.next()
     _call_apply([applyc], [self.i], self.info)
     self.assertExists(list(self.lib.items())[0].path)
     self.assertNotExists(self.srcpath)
コード例 #14
0
ファイル: test_importer.py プロジェクト: navinpai/beets
    def test_apply_tracks_uses_singleton_path(self):
        coro = importer.apply_choices(_common.iconfig(self.lib))
        coro.next() # Prime coroutine.

        task = importer.ImportTask.item_task(self.i)
        task.set_choice(self.info['tracks'][0])
        coro.send(task)

        self.assertExists(
            os.path.join(self.libdir, self.lib.path_formats['singleton']+'.mp3')
        )
コード例 #15
0
ファイル: test_importer.py プロジェクト: triplem/beets
    def test_apply_tracks_uses_singleton_path(self):
        apply_coro = importer.apply_choices(self.session)
        apply_coro.next()
        manip_coro = importer.manipulate_files(self.session)
        manip_coro.next()

        task = importer.ImportTask.item_task(self.i)
        task.set_choice(TrackMatch(0, self.info.tracks[0]))
        apply_coro.send(task)
        manip_coro.send(task)

        self.assertExists(os.path.join(self.libdir, 'three.mp3'))
コード例 #16
0
ファイル: test_importer.py プロジェクト: ryanakca/beets
    def test_apply_tracks_uses_singleton_path(self):
        config = _common.iconfig(self.lib)
        apply_coro = importer.apply_choices(config)
        apply_coro.next()
        manip_coro = importer.manipulate_files(config)
        manip_coro.next()

        task = importer.ImportTask.item_task(self.i)
        task.set_choice(TrackMatch(0, self.info.tracks[0]))
        apply_coro.send(task)
        manip_coro.send(task)

        self.assertExists(os.path.join(self.libdir, "three.mp3"))
コード例 #17
0
ファイル: test_importer.py プロジェクト: ngokevin/beets
    def test_reimport_moves_file_and_does_not_add_to_old_paths(self):
        # First, add the item to the library.
        temp_item = library.Item.from_path(self.srcpath)
        self.lib.add(temp_item)
        self.lib.save()

        # Then, re-import the same file.
        coro = importer.apply_choices(_common.iconfig(self.lib))
        coro.next()
        task = _call_apply(coro, [self.i], self.info)

        # Old file should be gone.
        self.assertNotExists(self.srcpath)
        # New file should be present.
        self.assertExists(os.path.join(self.libdir, 'one.mp3'))
        # Also, the old file should not be in old_paths because it does
        # not exist.
        self.assertEqual(task.old_paths, [])
コード例 #18
0
ファイル: test_importer.py プロジェクト: refreshoxford/beets
    def test_reimport_moves_file_and_does_not_add_to_old_paths(self):
        # First, add the item to the library.
        temp_item = library.Item.from_path(self.srcpath)
        self.lib.add(temp_item)
        self.lib.save()

        # Then, re-import the same file.
        coro = importer.apply_choices(_common.iconfig(self.lib))
        coro.next()
        task = _call_apply(coro, [self.i], self.info)

        # Old file should be gone.
        self.assertNotExists(self.srcpath)
        # New file should be present.
        self.assertExists(os.path.join(self.libdir, 'one.mp3'))
        # Also, the old file should not be in old_paths because it does
        # not exist.
        self.assertEqual(task.old_paths, [])
コード例 #19
0
ファイル: test_importer.py プロジェクト: Thynix/beets
    def test_reimport_outside_file_copies(self):
        """Reimporting a file *outside* the library directory should
        *copy* the file (when copying is enabled).
        """
        # First, add the item to the library.
        temp_item = library.Item.from_path(self.srcpath)
        self.lib.add(temp_item)
        self.lib.conn.commit()

        # Then, re-import the same file.
        coro = importer.apply_choices(_common.iconfig(self.lib))
        coro.next()
        task = _call_apply(coro, [self.i], self.info)

        # Old file should still exist.
        self.assertExists(self.srcpath)
        # New file should also be present.
        self.assertExists(os.path.join(self.libdir, 'one.mp3'))
        # The old (copy-source) file should be marked for possible
        # deletion.
        self.assertEqual(task.old_paths, [self.srcpath])
コード例 #20
0
ファイル: test_importer.py プロジェクト: refreshoxford/beets
 def _apply_asis(self, items, album=True):
     """Run the "apply" coroutine."""
     coro = importer.apply_choices(self.config)
     coro.next()
     _call_apply_choice(coro, items, importer.action.ASIS, album)
コード例 #21
0
ファイル: test_importer.py プロジェクト: Bitdemon/beets
 def test_apply_sentinel(self):
     coro = importer.apply_choices(self.session)
     coro.next()
     coro.send(importer.ImportTask.done_sentinel('toppath'))
コード例 #22
0
ファイル: test_importer.py プロジェクト: mdecker/beets
 def test_apply_as_tracks_uses_singleton_path(self):
     coro = importer.apply_choices(_common.iconfig(self.lib))
     coro.next()  # Prime coroutine.
     self._call_apply_choice(coro, [self.i], importer.action.TRACKS)
     self.assertExists(os.path.join(self.libdir, self.lib.path_formats["singleton"] + ".mp3"))
コード例 #23
0
ファイル: test_importer.py プロジェクト: mdecker/beets
 def test_apply_with_delete(self):
     coro = importer.apply_choices(_common.iconfig(self.lib, delete=True))
     coro.next()  # Prime coroutine.
     self._call_apply(coro, [self.i], self.info)
     self.assertNotExists(self.srcpath)
コード例 #24
0
ファイル: test_importer.py プロジェクト: refreshoxford/beets
 def test_apply_asis_uses_album_path(self):
     coro = importer.apply_choices(_common.iconfig(self.lib))
     coro.next() # Prime coroutine.
     _call_apply_choice(coro, [self.i], importer.action.ASIS)
     self.assertExists(os.path.join(self.libdir, 'one.mp3'))
コード例 #25
0
ファイル: test_importer.py プロジェクト: refreshoxford/beets
 def test_apply_populates_old_paths(self):
     coro = importer.apply_choices(_common.iconfig(self.lib))
     coro.next()
     task = _call_apply(coro, [self.i], self.info)
     self.assertEqual(task.old_paths, [self.srcpath])
コード例 #26
0
 def test_apply_with_delete(self):
     coro = importer.apply_choices(_common.iconfig(self.lib, delete=True))
     coro.next()  # Prime coroutine.
     self._call_apply(coro, [self.i], self.info)
     self.assertNotExists(self.srcpath)
コード例 #27
0
ファイル: test_importer.py プロジェクト: triplem/beets
 def test_apply_sentinel(self):
     coro = importer.apply_choices(self.session)
     coro.next()
     coro.send(importer.ImportTask.done_sentinel('toppath'))
コード例 #28
0
ファイル: test_importer.py プロジェクト: ngokevin/beets
 def test_apply_populates_old_paths(self):
     coro = importer.apply_choices(_common.iconfig(self.lib))
     coro.next()
     task = _call_apply(coro, [self.i], self.info)
     self.assertEqual(task.old_paths, [self.srcpath])
コード例 #29
0
ファイル: test_importer.py プロジェクト: ngokevin/beets
 def test_apply_asis_uses_album_path(self):
     coro = importer.apply_choices(_common.iconfig(self.lib))
     coro.next() # Prime coroutine.
     _call_apply_choice(coro, [self.i], importer.action.ASIS)
     self.assertExists(os.path.join(self.libdir, 'one.mp3'))
コード例 #30
0
 def test_apply_sentinel(self):
     coro = importer.apply_choices(_common.iconfig(self.lib))
     coro.next()
     coro.send(importer.ImportTask.done_sentinel('toppath'))
コード例 #31
0
ファイル: test_importer.py プロジェクト: ryanakca/beets
 def test_apply_sentinel(self):
     coro = importer.apply_choices(_common.iconfig(self.lib))
     coro.next()
     coro.send(importer.ImportTask.done_sentinel("toppath"))
コード例 #32
0
 def _apply_asis(self, items, album=True):
     """Run the "apply" coroutine."""
     coro = importer.apply_choices(self.config)
     coro.next()
     _call_apply_choice(coro, items, importer.action.ASIS, album)