Exemplo n.º 1
0
    def setUp(self):
        pathlib.Path(LibraryTest.FOLDER).mkdir(exist_ok=True)

        usrcfg = userconfig.UserConfig()
        usrcfg['library'] = {}
        usrcfg['library']['music_directory'] = self.FOLDER
        usrcfg['library']['playlist_directory'] = self.FOLDER

        self.library = Library(appconfig.Testing, usrcfg)

        (pathlib.Path(self.FOLDER) / 'fake.png').touch()
        (pathlib.Path(self.FOLDER) / 'fakefolder').mkdir()

        # Create 8 songs on 4 different album from 2 different artist
        for index, path in enumerate(LibraryTest.DST_FILE):
            shutil.copy(LibraryTest.SRC_FILE, path)
            song = Song(Path=path)
            song.read_tags()
            song.Title = 'Title' + str(index)
            song.AlbumArtist = 'Artist' + str(int(index / 4))
            song.Artist = 'Artist' + str(int(index / 4))
            song.Album = 'Album' + str(int(index / 2))
            song.write_tags()

        playlist = M3uParser(LibraryTest.PLAYLIST_FILE)
        for path in LibraryTest.DST_FILE:
            playlist.append(pathlib.Path(path).name)
        playlist.write()
Exemplo n.º 2
0
    def test_save(self):
        self.cfg['data'] = 1
        self.assertEqual(1, self.cfg['data'])

        self.cfg.save()
        self.assertEqual(1, self.cfg['data'])

        new_cfg = userconfig.UserConfig(self.CONFIG_FILE_PATH)
        self.assertEqual(1, new_cfg['data'])
Exemplo n.º 3
0
 def test_save_invalid_file(self):
     with self.assertLogs(level=logging.CRITICAL):
         tmp = userconfig.UserConfig()
         tmp._path = 'invalid/99999999/file'
         tmp.save()
Exemplo n.º 4
0
 def setUp(self):
     self.cfg = userconfig.UserConfig(self.CONFIG_FILE_PATH)