From 8cf9da3d555b375ae72a782b094d6377cedd1a59 Mon Sep 17 00:00:00 2001 From: Thomas Adamcik Date: Wed, 29 Apr 2015 00:27:56 +0200 Subject: [PATCH] utils: Fix corner case in format_proxy scheme handling --- mopidy/utils/http.py | 2 +- tests/utils/test_http.py | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/mopidy/utils/http.py b/mopidy/utils/http.py index f0c658e7..096a37a0 100644 --- a/mopidy/utils/http.py +++ b/mopidy/utils/http.py @@ -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) diff --git a/tests/utils/test_http.py b/tests/utils/test_http.py index cf97e57c..dee09c3c 100644 --- a/tests/utils/test_http.py +++ b/tests/utils/test_http.py @@ -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'),