def test_setup(self):
        registry = mock.Mock()

        ext = Extension()
        ext.setup(registry)

        registry.add.assert_called_with('backend', backend_lib.SpotifyBackend)
    def test_get_default_config(self):
        ext = Extension()

        config = ext.get_default_config()

        self.assertIn('[spotify]', config)
        self.assertIn('enabled = true', config)
示例#3
0
def test_setup():
    registry = mock.Mock()

    ext = Extension()
    ext.setup(registry)

    registry.add.assert_called_with("backend", backend_lib.SpotifyBackend)
示例#4
0
def test_get_default_config():
    ext = Extension()

    config = ext.get_default_config()

    assert "[spotify]" in config
    assert "enabled = true" in config
示例#5
0
    def test_get_default_config(self):
        ext = Extension()

        config = ext.get_default_config()

        self.assertIn('[spotify]', config)
        self.assertIn('enabled = true', config)
def test_get_default_config():
    ext = Extension()

    config = ext.get_default_config()

    assert '[spotify]' in config
    assert 'enabled = true' in config
    def test_get_config_schema(self):
        ext = Extension()

        schema = ext.get_config_schema()

        self.assertIn('username', schema)
        self.assertIn('password', schema)
        self.assertIn('bitrate', schema)
        self.assertIn('timeout', schema)
        self.assertIn('cache_dir', schema)
示例#8
0
    def test_get_config_schema(self):
        ext = Extension()

        schema = ext.get_config_schema()

        self.assertIn('username', schema)
        self.assertIn('password', schema)
        self.assertIn('bitrate', schema)
        self.assertIn('timeout', schema)
        self.assertIn('cache_dir', schema)
示例#9
0
def test_get_config_schema():
    ext = Extension()

    schema = ext.get_config_schema()

    assert "username" in schema
    assert "password" in schema
    assert "bitrate" in schema
    assert "volume_normalization" in schema
    assert "private_session" in schema
    assert "timeout" in schema
    assert "cache_dir" in schema
    assert "settings_dir" in schema
    assert "allow_cache" in schema
    assert "allow_network" in schema
    assert "allow_playlists" in schema
    assert "search_album_count" in schema
    assert "search_artist_count" in schema
    assert "search_track_count" in schema
    assert "toplist_countries" in schema
def test_get_config_schema():
    ext = Extension()

    schema = ext.get_config_schema()

    assert 'username' in schema
    assert 'password' in schema
    assert 'bitrate' in schema
    assert 'volume_normalization' in schema
    assert 'private_session' in schema
    assert 'timeout' in schema
    assert 'cache_dir' in schema
    assert 'settings_dir' in schema
    assert 'allow_cache' in schema
    assert 'allow_network' in schema
    assert 'allow_playlists' in schema
    assert 'search_album_count' in schema
    assert 'search_artist_count' in schema
    assert 'search_track_count' in schema
    assert 'toplist_countries' in schema
示例#11
0
    def create_backup(self, playlist, extra):
        safe_name = playlist.name.translate(
            str.maketrans(" @`!\"#$%&'()*+;[{<\\|]}>^~/?", "_" * 27))
        filename = (Extension.get_data_dir(self._backend._config) /
                    f"{safe_name}-{playlist.uri}-{extra}-{time.time()}.m3u8")
        with filename.open("w") as f:
            f.write("#EXTM3U\n#EXTENC: UTF-8\n\n")
            for track in playlist.tracks:
                length = int(track.length / 1000)
                artists = ", ".join(a.name for a in track.artists)
                f.write(f"#EXTINF:{length},{artists} - {track.name}\n"
                        f"{track.uri}\n\n")

        return str(filename)
示例#12
0
    def _get_spotify_config(self, config):
        ext = Extension()
        spotify_config = spotify.Config()

        spotify_config.load_application_key_file(
            os.path.join(os.path.dirname(__file__), 'spotify_appkey.key'))

        if config['spotify']['allow_cache']:
            spotify_config.cache_location = ext.get_cache_dir(config)
        else:
            spotify_config.cache_location = None

        spotify_config.settings_location = ext.get_data_dir(config)

        proxy_uri = httpclient.format_proxy(config['proxy'], auth=False)
        if proxy_uri is not None:
            logger.debug('Connecting to Spotify through proxy: %s', proxy_uri)

        spotify_config.proxy = proxy_uri
        spotify_config.proxy_username = config['proxy'].get('username')
        spotify_config.proxy_password = config['proxy'].get('password')

        return spotify_config
示例#13
0
    def _get_spotify_config(self, config):
        ext = Extension()
        spotify_config = spotify.Config()

        spotify_config.load_application_key_file(
            os.path.join(os.path.dirname(__file__), 'spotify_appkey.key'))

        if config['spotify']['allow_cache']:
            spotify_config.cache_location = ext.get_cache_dir(config)
        else:
            spotify_config.cache_location = None

        spotify_config.settings_location = ext.get_data_dir(config)

        proxy_uri = httpclient.format_proxy(config['proxy'], auth=False)
        if proxy_uri is not None:
            logger.debug('Connecting to Spotify through proxy: %s', proxy_uri)

        spotify_config.proxy = proxy_uri
        spotify_config.proxy_username = config['proxy'].get('username')
        spotify_config.proxy_password = config['proxy'].get('password')

        return spotify_config
示例#14
0
    def _get_spotify_config(self, config):
        ext = Extension()
        spotify_config = spotify.Config()

        spotify_config.load_application_key_file(
            pathlib.Path(__file__).parent / "spotify_appkey.key")

        if config["spotify"]["allow_cache"]:
            spotify_config.cache_location = bytes(ext.get_cache_dir(config))
        else:
            spotify_config.cache_location = None

        spotify_config.settings_location = bytes(ext.get_data_dir(config))

        proxy_uri = httpclient.format_proxy(config["proxy"], auth=False)
        if proxy_uri is not None:
            logger.debug(f"Connecting to Spotify through proxy: {proxy_uri}")

        spotify_config.proxy = proxy_uri
        spotify_config.proxy_username = config["proxy"].get("username")
        spotify_config.proxy_password = config["proxy"].get("password")

        return spotify_config
    def test_get_backend_classes(self):
        ext = Extension()

        backends = ext.get_backend_classes()

        self.assertIn(backend_lib.SpotifyBackend, backends)