httpclient: Move to top level module

This commit is contained in:
Thomas Adamcik 2015-05-09 00:44:16 +02:00
parent 924269616b
commit 382aa0a775
4 changed files with 8 additions and 9 deletions

View File

@ -42,8 +42,8 @@ Models
Utils
-----
- Add :func:`mopidy.utils.http.format_proxy` and
:func:`mopidy.utils.http.format_user_agent`. (Part of: :issue:`1156`)
- Add :func:`mopidy.httpclient.format_proxy` and
:func:`mopidy.httpclient.format_user_agent`. (Part of: :issue:`1156`)
Internal changes
----------------

View File

@ -8,9 +8,8 @@ import pygst
pygst.require('0.10')
import gst # noqa
from mopidy import compat
from mopidy import compat, httpclient
from mopidy.models import Album, Artist, Track
from mopidy.utils import http
logger = logging.getLogger(__name__)
@ -143,7 +142,7 @@ def setup_proxy(element, config):
if not hasattr(element.props, 'proxy') or not config.get('hostname'):
return
element.set_property('proxy', http.format_proxy(config, auth=False))
element.set_property('proxy', httpclient.format_proxy(config, auth=False))
element.set_property('proxy-id', config.get('username'))
element.set_property('proxy-pw', config.get('password'))

View File

@ -4,7 +4,7 @@ import re
import pytest
from mopidy.utils import http
from mopidy.utils import httpclient
@pytest.mark.parametrize("config,expected", [
@ -20,12 +20,12 @@ from mopidy.utils import http
'http://user:pass@proxy.lan:80'),
])
def test_format_proxy(config, expected):
assert http.format_proxy(config) == expected
assert httpclient.format_proxy(config) == expected
def test_format_proxy_without_auth():
config = {'username': 'user', 'password': 'pass', 'hostname': 'proxy.lan'}
formated_proxy = http.format_proxy(config, auth=False)
formated_proxy = httpclient.format_proxy(config, auth=False)
assert formated_proxy == 'http://proxy.lan:80'
@ -35,4 +35,4 @@ def test_format_proxy_without_auth():
('Foo/1.2.3', r'^Foo/1.2.3 Mopidy/[^ ]+ CPython|/[^ ]+$'),
])
def test_format_user_agent(name, expected):
assert re.match(expected, http.format_user_agent(name))
assert re.match(expected, httpclient.format_user_agent(name))