utils: Fix corner case in format_proxy scheme handling

This commit is contained in:
Thomas Adamcik 2015-04-29 00:27:56 +02:00
parent 8434896f2d
commit 8cf9da3d55
2 changed files with 2 additions and 1 deletions

View File

@ -25,7 +25,7 @@ def format_proxy(proxy_config):
if port < 0:
port = 80
return template.format(scheme=proxy_config.get('scheme', 'http'),
return template.format(scheme=proxy_config.get('scheme') or 'http',
username=proxy_config.get('username'),
password=proxy_config.get('password'),
hostname=proxy_config['hostname'], port=port)

View File

@ -10,6 +10,7 @@ from mopidy.utils import http
@pytest.mark.parametrize("config,expected", [
({}, None),
({'hostname': 'proxy.lan'}, 'http://proxy.lan:80'),
({'scheme': None, 'hostname': 'proxy.lan'}, 'http://proxy.lan:80'),
({'scheme': 'https', 'hostname': 'proxy.lan'}, 'https://proxy.lan:80'),
({'username': 'user', 'hostname': 'proxy.lan'}, 'http://proxy.lan:80'),
({'password': 'pass', 'hostname': 'proxy.lan'}, 'http://proxy.lan:80'),