Пример #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_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'))
Пример #3
0
    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._connection().commit()

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

        # Then, re-import the same file.
        config =_common.iconfig(self.lib)
        task = _call_stages(config, [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, [])
Пример #4
0
    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._connection().commit()

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

        # Then, re-import the same file.
        config = _common.iconfig(self.lib)
        task = _call_stages(config, [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
 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'))
Пример #6
0
 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))
Пример #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
 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)
Пример #9
0
 def test_manipulate_files_with_null_move(self):
     """It should be possible to "move" a file even when the file is
     already at the destination.
     """
     config = _common.iconfig(self.lib, move=True)
     self.lib.move(self.i)  # Already at destination.
     _call_stages(config, [self.i], self.info, toppath=self.srcdir, stages=[importer.manipulate_files])
     self.assertExists(self.i.path)
Пример #10
0
 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))
Пример #11
0
    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
 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)
Пример #13
0
 def test_manipulate_files_with_null_move(self):
     """It should be possible to "move" a file even when the file is
     already at the destination.
     """
     config = _common.iconfig(self.lib, move=True)
     self.lib.move(self.i)  # Already at destination.
     _call_stages(config, [self.i], self.info, toppath=self.srcdir,
                  stages=[importer.manipulate_files])
     self.assertExists(self.i.path)
Пример #14
0
    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"))
Пример #15
0
 def _no_candidates_test(self, result):
     task = importer.ImportTask(
         'toppath',
         'path',
         [_common.item()],
     )
     task.set_match('artist', 'album', [], autotag.RECOMMEND_NONE)
     res = commands.choose_match(task, _common.iconfig(None, quiet=False))
     self.assertEqual(res, result)
     self.assertTrue('No match' in self.io.getoutput())
Пример #16
0
 def _no_candidates_test(self, result):
     task = importer.ImportTask(
         'toppath',
         'path',
         [_common.item()],
     )
     task.set_match('artist', 'album', [], autotag.RECOMMEND_NONE)
     res = commands.choose_match(task, _common.iconfig(None, quiet=False))
     self.assertEqual(res, result)
     self.assertTrue('No match' in self.io.getoutput())
Пример #17
0
    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')
        )
Пример #18
0
    def setUp(self):
        self.libdir = os.path.join(_common.RSRC, "testlibdir")
        os.mkdir(self.libdir)

        self.dbpath = os.path.join(_common.RSRC, "templib.blb")
        self.lib = library.Library(self.dbpath, self.libdir)
        self.lib.path_formats = [("default", "$artist/$title")]
        self.config = _common.iconfig(self.lib, write=False, copy=False)

        self.srcpath = os.path.join(self.libdir, "srcfile.mp3")
        shutil.copy(os.path.join(_common.RSRC, "full.mp3"), self.srcpath)
        self.i = library.Item.from_path(self.srcpath)
        self.i.comp = False
Пример #19
0
    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"))
Пример #20
0
 def _show_change(self, items=None, info=None,
                  cur_artist='the artist', cur_album='the album',
                  dist=0.1):
     items = items or self.items
     info = info or self.info
     mapping = dict(zip(items, info.tracks))
     commands.show_change(
         _common.iconfig(None),
         cur_artist,
         cur_album,
         autotag.AlbumMatch(0.1, info, mapping, set(), set()),
         color=False,
     )
     return self.io.getoutput().lower()
Пример #21
0
    def setUp(self):
        self.libdir = os.path.join(_common.RSRC, 'testlibdir')
        os.mkdir(self.libdir)

        self.dbpath = os.path.join(_common.RSRC, 'templib.blb')
        self.lib = library.Library(self.dbpath, self.libdir)
        self.lib.path_formats = {
            'default': '$artist/$title',
        }
        self.config = _common.iconfig(self.lib, write=False, copy=False)

        self.srcpath = os.path.join(self.libdir, 'srcfile.mp3')
        shutil.copy(os.path.join(_common.RSRC, 'full.mp3'), self.srcpath)
        self.i = library.Item.from_path(self.srcpath)
        self.i.comp = False
Пример #22
0
    def setUp(self):
        self.libdir = os.path.join(_common.RSRC, 'testlibdir')
        os.mkdir(self.libdir)

        self.dbpath = os.path.join(_common.RSRC, 'templib.blb')
        self.lib = library.Library(self.dbpath, self.libdir)
        self.lib.path_formats = [
            ('default', '$artist/$title'),
        ]
        self.config = _common.iconfig(self.lib, write=False, copy=False)

        self.srcpath = os.path.join(self.libdir, 'srcfile.mp3')
        shutil.copy(os.path.join(_common.RSRC, 'full.mp3'), self.srcpath)
        self.i = library.Item.from_path(self.srcpath)
        self.i.comp = False
Пример #23
0
    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')
        )
Пример #24
0
    def setUp(self):
        self.dbpath = os.path.join(_common.RSRC, "templib.blb")
        self.lib = library.Library(self.dbpath)
        self.config = _common.iconfig(self.lib, write=False, copy=False)

        # Make an "album" that has a homogenous artist. (Modified by
        # individual tests.)
        i1 = _common.item()
        i2 = _common.item()
        i3 = _common.item()
        i1.title = "first item"
        i2.title = "second item"
        i3.title = "third item"
        i1.comp = i2.comp = i3.comp = False
        i1.albumartist = i2.albumartist = i3.albumartist = ""
        self.items = [i1, i2, i3]
Пример #25
0
    def setUp(self):
        self.dbpath = os.path.join(_common.RSRC, 'templib.blb')
        self.lib = library.Library(self.dbpath)
        self.config = _common.iconfig(self.lib, write=False, copy=False)

        # Make an "album" that has a homogenous artist. (Modified by
        # individual tests.)
        i1 = _common.item()
        i2 = _common.item()
        i3 = _common.item()
        i1.title = 'first item'
        i2.title = 'second item'
        i3.title = 'third item'
        i1.comp = i2.comp = i3.comp = False
        i1.albumartist = i2.albumartist = i3.albumartist = ''
        self.items = [i1, i2, i3]
Пример #26
0
    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, [])
Пример #27
0
    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, [])
Пример #28
0
    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._connection().commit()

        # Then, re-import the same file.
        config = _common.iconfig(self.lib)
        task = _call_stages(config, [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])
Пример #29
0
    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._connection().commit()

        # Then, re-import the same file.
        config = _common.iconfig(self.lib)
        task = _call_stages(config, [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])
Пример #30
0
    def setUp(self):
        # Mock the album art fetcher to always return our test file.
        self.art_file = os.path.join(_common.RSRC, 'tmpcover.jpg')
        _common.touch(self.art_file)
        self.old_afa = fetchart.art_for_album
        self.afa_response = self.art_file
        def art_for_album(i, p, maxwidth=None, local_only=False):
            return self.afa_response
        fetchart.art_for_album = art_for_album

        # Test library.
        self.libpath = os.path.join(_common.RSRC, 'tmplib.blb')
        self.libdir = os.path.join(_common.RSRC, 'tmplib')
        os.mkdir(self.libdir)
        os.mkdir(os.path.join(self.libdir, 'album'))
        itempath = os.path.join(self.libdir, 'album', 'test.mp3')
        shutil.copyfile(os.path.join(_common.RSRC, 'full.mp3'), itempath)
        self.lib = library.Library(self.libpath)
        self.i = _common.item()
        self.i.path = itempath
        self.album = self.lib.add_album([self.i])
        self.lib._connection().commit()

        # The plugin and import configuration.
        self.plugin = fetchart.FetchArtPlugin()
        self.config = _common.iconfig(self.lib)

        # Import task for the coroutine.
        self.task = importer.ImportTask(None, None, [self.i])
        self.task.is_album = True
        self.task.album_id = self.album.id
        info = AlbumInfo(
            album = 'some album',
            album_id = 'albumid',
            artist = 'some artist',
            artist_id = 'artistid',
            tracks = [],
        )
        self.task.set_choice(AlbumMatch(0, info, {}, set(), set()))
Пример #31
0
    def setUp(self):
        # Mock the album art fetcher to always return our test file.
        self.art_file = os.path.join(_common.RSRC, 'tmpcover.jpg')
        _common.touch(self.art_file)
        self.old_afa = art.art_for_album
        art.art_for_album = lambda a, b: self.art_file

        # Test library.
        self.libpath = os.path.join(_common.RSRC, 'tmplib.blb')
        self.libdir = os.path.join(_common.RSRC, 'tmplib')
        os.mkdir(self.libdir)
        os.mkdir(os.path.join(self.libdir, 'album'))
        itempath = os.path.join(self.libdir, 'album', 'test.mp3')
        shutil.copyfile(os.path.join(_common.RSRC, 'full.mp3'), itempath)
        self.lib = library.Library(self.libpath)
        self.i = _common.item()
        self.i.path = itempath
        self.album = self.lib.add_album([self.i])
        self.lib._connection().commit()

        # Set up an art-fetching coroutine.
        self.config = _common.iconfig(self.lib)
        self.config.art = True
        self.coro = importer.fetch_art(self.config)
        self.coro.next()

        # Import task for the coroutine.
        self.task = importer.ImportTask(None, None, [self.i])
        self.task.is_album = True
        self.task.album_id = self.album.id
        info = AlbumInfo(
            album = 'some album',
            album_id = 'albumid',
            artist = 'some artist',
            artist_id = 'artistid',
            tracks = [TrackInfo('one',  'trackid', 'some artist',
                                'artistid', 1)],
        )
        self.task.set_choice((info, [self.i]))
Пример #32
0
    def setUp(self):
        # Mock the album art fetcher to always return our test file.
        self.art_file = os.path.join(_common.RSRC, 'tmpcover.jpg')
        _common.touch(self.art_file)
        self.old_afa = art.art_for_album
        art.art_for_album = lambda a, b: self.art_file

        # Test library.
        self.libpath = os.path.join(_common.RSRC, 'tmplib.blb')
        self.libdir = os.path.join(_common.RSRC, 'tmplib')
        os.mkdir(self.libdir)
        os.mkdir(os.path.join(self.libdir, 'album'))
        itempath = os.path.join(self.libdir, 'album', 'test.mp3')
        shutil.copyfile(os.path.join(_common.RSRC, 'full.mp3'), itempath)
        self.lib = library.Library(self.libpath)
        self.i = _common.item()
        self.i.path = itempath
        self.album = self.lib.add_album([self.i])
        self.lib.save()

        # Set up an art-fetching coroutine.
        self.config = _common.iconfig(self.lib)
        self.config.art = True
        self.coro = importer.fetch_art(self.config)
        self.coro.next()

        # Import task for the coroutine.
        self.task = importer.ImportTask(None, None, [self.i])
        self.task.is_album = True
        self.task.album_id = self.album.id
        info = AlbumInfo(
            album='some album',
            album_id='albumid',
            artist='some artist',
            artist_id='artistid',
            tracks=[TrackInfo('one', 'trackid', 'some artist', 'artistid', 1)],
        )
        self.task.set_choice((info, [self.i]))
Пример #33
0
    def setUp(self):
        # Mock the album art fetcher to always return our test file.
        self.art_file = os.path.join(_common.RSRC, "tmpcover.jpg")
        _common.touch(self.art_file)
        self.old_afa = art.art_for_album
        art.art_for_album = lambda a, b: self.art_file

        # Test library.
        self.libpath = os.path.join(_common.RSRC, "tmplib.blb")
        self.libdir = os.path.join(_common.RSRC, "tmplib")
        os.mkdir(self.libdir)
        os.mkdir(os.path.join(self.libdir, "album"))
        itempath = os.path.join(self.libdir, "album", "test.mp3")
        shutil.copyfile(os.path.join(_common.RSRC, "full.mp3"), itempath)
        self.lib = library.Library(self.libpath)
        self.i = _common.item()
        self.i.path = itempath
        self.album = self.lib.add_album([self.i])
        self.lib.save()

        # Set up an art-fetching coroutine.
        self.config = _common.iconfig(self.lib)
        self.config.art = True
        self.coro = importer.fetch_art(self.config)
        self.coro.next()

        # Import task for the coroutine.
        self.task = importer.ImportTask(None, None, [self.i])
        self.task.is_album = True
        self.task.album_id = self.album.id
        info = AlbumInfo(
            album="some album",
            album_id="albumid",
            artist="some artist",
            artist_id="artistid",
            tracks=[TrackInfo("one", "trackid", "some artist", "artistid", 1)],
        )
        self.task.set_choice((info, [self.i]))
Пример #34
0
 def test_apply_asis_uses_album_path(self):
     config = _common.iconfig(self.lib)
     _call_stages(config, [self.i], importer.action.ASIS)
     self.assertExists(os.path.join(self.libdir, 'one.mp3'))
Пример #35
0
 def test_apply_match_uses_album_path(self):
     config = _common.iconfig(self.lib)
     _call_stages(config, [self.i], self.info)
     self.assertExists(os.path.join(self.libdir, "one.mp3"))
Пример #36
0
 def test_apply_asis_uses_album_path(self):
     config = _common.iconfig(self.lib)
     _call_stages(config, [self.i], importer.action.ASIS)
     self.assertExists(os.path.join(self.libdir, "one.mp3"))
Пример #37
0
 def test_finalize_with_delete_prunes_directory_empty(self):
     config = _common.iconfig(self.lib, delete=True)
     _call_stages(config, [self.i], self.info, toppath=self.srcdir)
     self.assertNotExists(os.path.dirname(self.srcpath))
Пример #38
0
 def test_finalize_with_delete_prunes_directory_empty(self):
     config = _common.iconfig(self.lib, delete=True)
     _call_stages(config, [self.i], self.info,
                  toppath=self.srcdir)
     self.assertNotExists(os.path.dirname(self.srcpath))
Пример #39
0
 def test_apply_with_move(self):
     config = _common.iconfig(self.lib, move=True)
     _call_stages(config, [self.i], self.info)
     self.assertExists(list(self.lib.items())[0].path)
     self.assertNotExists(self.srcpath)
Пример #40
0
 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'))
Пример #41
0
 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])
Пример #42
0
 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'))
Пример #43
0
 def test_apply_populates_old_paths(self):
     config = _common.iconfig(self.lib)
     task = _call_stages(config, [self.i], self.info)
     self.assertEqual(task.old_paths, [self.srcpath])
Пример #44
0
 def test_apply_match_uses_album_path(self):
     config = _common.iconfig(self.lib)
     _call_stages(config, [self.i], self.info)
     self.assertExists(os.path.join(self.libdir, 'one.mp3'))
Пример #45
0
 def test_apply_sentinel(self):
     coro = importer.apply_choices(_common.iconfig(self.lib))
     coro.next()
     coro.send(importer.ImportTask.done_sentinel("toppath"))
Пример #46
0
 def test_apply_populates_old_paths(self):
     config = _common.iconfig(self.lib)
     task = _call_stages(config, [self.i], self.info)
     self.assertEqual(task.old_paths, [self.srcpath])
Пример #47
0
 def _no_candidates_test(self, result):
     task = importer.ImportTask("toppath", "path", [_common.item()])
     task.set_match("artist", "album", [], autotag.RECOMMEND_NONE)
     res = commands.choose_match(task, _common.iconfig(None, quiet=False))
     self.assertEqual(res, result)
     self.assertTrue("No match" in self.io.getoutput())
Пример #48
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)
Пример #49
0
 def test_apply_with_move(self):
     config = _common.iconfig(self.lib, move=True)
     _call_stages(config, [self.i], self.info)
     self.assertExists(list(self.lib.items())[0].path)
     self.assertNotExists(self.srcpath)
Пример #50
0
 def test_apply_with_move_prunes_empty_directory(self):
     config = _common.iconfig(self.lib, move=True)
     _call_stages(config, [self.i], self.info, toppath=self.srcdir)
     self.assertNotExists(os.path.dirname(self.srcpath))
Пример #51
0
 def test_finalize_with_delete(self):
     config = _common.iconfig(self.lib, delete=True)
     _call_stages(config, [self.i], self.info)
     self.assertNotExists(self.srcpath)
Пример #52
0
 def test_finalize_with_delete(self):
     config = _common.iconfig(self.lib, delete=True)
     _call_stages(config, [self.i], self.info)
     self.assertNotExists(self.srcpath)
Пример #53
0
 def test_apply_with_move_prunes_empty_directory(self):
     config = _common.iconfig(self.lib, move=True)
     _call_stages(config, [self.i], self.info, toppath=self.srcdir)
     self.assertNotExists(os.path.dirname(self.srcpath))
Пример #54
0
 def test_apply_sentinel(self):
     coro = importer.apply_choices(_common.iconfig(self.lib))
     coro.next()
     coro.send(importer.ImportTask.done_sentinel('toppath'))
Пример #55
0
 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])