Exemple #1
0
    def test_latin1_playlist_contents_is_written_to_disk(self):
        track = Track(uri=generate_song(1), name='Test\x9f', length=60000)
        playlist = self.core.playlists.create('test')
        playlist = self.core.playlists.save(playlist.copy(tracks=[track]))
        path = os.path.join(self.playlists_dir, b'test.m3u')

        with open(path, 'rb') as f:
            m3u = f.read().splitlines()
        self.assertEqual([b'#EXTM3U', b'#EXTINF:-1,Test\x9f', track.uri], m3u)
Exemple #2
0
    def test_utf8_playlist_contents_is_replaced_and_written_to_disk(self):
        track = Track(uri=generate_song(1), name='Test\u07b4', length=60000)
        playlist = self.core.playlists.create('test')
        playlist = self.core.playlists.save(playlist.copy(tracks=[track]))
        path = playlist_uri_to_path(playlist.uri, self.playlists_dir)

        with open(path, 'rb') as f:
            m3u = f.read().splitlines()
        self.assertEqual([b'#EXTM3U', b'#EXTINF:60,Test?', track.uri], m3u)
Exemple #3
0
    def test_utf8_playlist_contents_is_replaced_and_written_to_disk(self):
        track = Track(uri=generate_song(1), name='Test\u07b4', length=60000)
        playlist = self.core.playlists.create('test')
        playlist = self.core.playlists.save(playlist.replace(tracks=[track]))
        path = os.path.join(self.playlists_dir, b'test.m3u')

        with open(path, 'rb') as f:
            m3u = f.read().splitlines()
        self.assertEqual([b'#EXTM3U', b'#EXTINF:-1,Test?', track.uri], m3u)
Exemple #4
0
    def test_latin1_playlist_contents_is_written_to_disk(self):
        track = Track(uri=generate_song(1), name='Test\x9f', length=60000)
        playlist = self.core.playlists.create('test')
        playlist = self.core.playlists.save(playlist.copy(tracks=[track]))
        path = playlist_uri_to_path(playlist.uri, self.playlists_dir)

        with open(path, 'rb') as f:
            m3u = f.read().splitlines()
        self.assertEqual([b'#EXTM3U', b'#EXTINF:60,Test\x9f', track.uri], m3u)
Exemple #5
0
    def test_playlist_contents_is_written_to_disk(self):
        track = Track(uri=generate_song(1))
        playlist = self.core.playlists.create("test")
        playlist = self.core.playlists.save(playlist.replace(tracks=[track]))
        path = self.playlists_dir / "test.m3u"

        contents = path.read_text()

        assert track.uri == contents.strip()
Exemple #6
0
    def test_extended_playlist_contents_is_written_to_disk(self):
        track = Track(uri=generate_song(1), name="Test", length=60000)
        playlist = self.core.playlists.create("test")
        playlist = self.core.playlists.save(playlist.replace(tracks=[track]))
        path = self.playlists_dir / "test.m3u"

        m3u = path.read_text().splitlines()

        assert ["#EXTM3U", "#EXTINF:-1,Test", track.uri] == m3u
Exemple #7
0
    def test_playlist_contents_is_written_to_disk(self):
        track = Track(uri=generate_song(1))
        playlist = self.core.playlists.create('test')
        playlist = self.core.playlists.save(playlist.copy(tracks=[track]))
        path = playlist_uri_to_path(playlist.uri, self.playlists_dir)

        with open(path) as f:
            contents = f.read()

        self.assertEqual(track.uri, contents.strip())
Exemple #8
0
    def test_playlist_contents_is_written_to_disk(self):
        track = Track(uri=generate_song(1))
        playlist = self.core.playlists.create('test')
        playlist = self.core.playlists.save(playlist.replace(tracks=[track]))
        path = os.path.join(self.playlists_dir, b'test.m3u')

        with open(path) as f:
            contents = f.read()

        self.assertEqual(track.uri, contents.strip())
Exemple #9
0
    def test_playlist_contents_is_written_to_disk(self):
        track = Track(uri=generate_song(1))
        playlist = self.core.playlists.create('test')
        playlist = self.core.playlists.save(playlist.replace(tracks=[track]))
        path = os.path.join(self.playlists_dir, b'test.m3u')

        with open(path) as f:
            contents = f.read()

        self.assertEqual(track.uri, contents.strip())
Exemple #10
0
    def test_playlist_contents_is_written_to_disk(self):
        track = Track(uri=generate_song(1))
        playlist = self.core.playlists.create('test')
        playlist = self.core.playlists.save(playlist.copy(tracks=[track]))
        path = playlist_uri_to_path(playlist.uri, self.playlists_dir)

        with open(path) as f:
            contents = f.read()

        self.assertEqual(track.uri, contents.strip())
Exemple #11
0
    def test_extended_playlist_contents_is_written_to_disk(self):
        track = Track(uri=generate_song(1), name='Test', length=60000)
        playlist = self.core.playlists.create('test')
        playlist = self.core.playlists.save(playlist.copy(tracks=[track]))
        path = playlist_uri_to_path(playlist.uri, self.playlists_dir)

        with open(path) as f:
            contents = f.read().splitlines()

        self.assertEqual(contents, ['#EXTM3U', '#EXTINF:60,Test', track.uri])
Exemple #12
0
    def test_create_replaces_existing_playlist_with_updated_playlist(self):
        track = Track(uri=generate_song(1))
        playlist1 = self.core.playlists.create("test")
        playlist1 = self.core.playlists.save(playlist1.replace(tracks=[track]))
        assert playlist1 == self.core.playlists.lookup(playlist1.uri)

        playlist2 = self.core.playlists.create("test")
        assert playlist1.uri == playlist2.uri
        assert playlist1 != self.core.playlists.lookup(playlist1.uri)
        assert playlist2 == self.core.playlists.lookup(playlist1.uri)
Exemple #13
0
    def test_create_replaces_existing_playlist_with_updated_playlist(self):
        track = Track(uri=generate_song(1))
        playlist1 = self.core.playlists.create('test')
        playlist1 = self.core.playlists.save(playlist1.copy(tracks=[track]))
        self.assertEqual(playlist1, self.core.playlists.lookup(playlist1.uri))

        playlist2 = self.core.playlists.create('test')
        self.assertEqual(playlist1.uri, playlist2.uri)
        self.assertNotEqual(playlist1,
                            self.core.playlists.lookup(playlist1.uri))
        self.assertEqual(playlist2, self.core.playlists.lookup(playlist1.uri))
Exemple #14
0
    def test_create_replaces_existing_playlist_with_updated_playlist(self):
        track = Track(uri=generate_song(1))
        playlist1 = self.core.playlists.create('test')
        playlist1 = self.core.playlists.save(playlist1.replace(tracks=[track]))
        self.assertEqual(playlist1, self.core.playlists.lookup(playlist1.uri))

        playlist2 = self.core.playlists.create('test')
        self.assertEqual(playlist1.uri, playlist2.uri)
        self.assertNotEqual(
            playlist1, self.core.playlists.lookup(playlist1.uri))
        self.assertEqual(playlist2, self.core.playlists.lookup(playlist1.uri))
Exemple #15
0
    def test_utf8_playlist_contents_is_replaced_and_written_to_disk(self):
        track = Track(uri=generate_song(1), name="Test\u07b4", length=60000)
        playlist = self.core.playlists.create("test")
        playlist = self.core.playlists.save(playlist.replace(tracks=[track]))
        path = self.playlists_dir / "test.m3u"

        m3u = path.read_bytes().splitlines()

        track_uri = track.uri
        if not isinstance(track_uri, bytes):
            track_uri = track.uri.encode()
        assert [b"#EXTM3U", b"#EXTINF:-1,Test?", track_uri] == m3u