httpclient: Move to top level module
This commit is contained in:
parent
924269616b
commit
382aa0a775
@ -42,8 +42,8 @@ Models
|
|||||||
Utils
|
Utils
|
||||||
-----
|
-----
|
||||||
|
|
||||||
- Add :func:`mopidy.utils.http.format_proxy` and
|
- Add :func:`mopidy.httpclient.format_proxy` and
|
||||||
:func:`mopidy.utils.http.format_user_agent`. (Part of: :issue:`1156`)
|
:func:`mopidy.httpclient.format_user_agent`. (Part of: :issue:`1156`)
|
||||||
|
|
||||||
Internal changes
|
Internal changes
|
||||||
----------------
|
----------------
|
||||||
|
|||||||
@ -8,9 +8,8 @@ import pygst
|
|||||||
pygst.require('0.10')
|
pygst.require('0.10')
|
||||||
import gst # noqa
|
import gst # noqa
|
||||||
|
|
||||||
from mopidy import compat
|
from mopidy import compat, httpclient
|
||||||
from mopidy.models import Album, Artist, Track
|
from mopidy.models import Album, Artist, Track
|
||||||
from mopidy.utils import http
|
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
@ -143,7 +142,7 @@ def setup_proxy(element, config):
|
|||||||
if not hasattr(element.props, 'proxy') or not config.get('hostname'):
|
if not hasattr(element.props, 'proxy') or not config.get('hostname'):
|
||||||
return
|
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-id', config.get('username'))
|
||||||
element.set_property('proxy-pw', config.get('password'))
|
element.set_property('proxy-pw', config.get('password'))
|
||||||
|
|
||||||
|
|||||||
@ -4,7 +4,7 @@ import re
|
|||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from mopidy.utils import http
|
from mopidy.utils import httpclient
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize("config,expected", [
|
@pytest.mark.parametrize("config,expected", [
|
||||||
@ -20,12 +20,12 @@ from mopidy.utils import http
|
|||||||
'http://user:pass@proxy.lan:80'),
|
'http://user:pass@proxy.lan:80'),
|
||||||
])
|
])
|
||||||
def test_format_proxy(config, expected):
|
def test_format_proxy(config, expected):
|
||||||
assert http.format_proxy(config) == expected
|
assert httpclient.format_proxy(config) == expected
|
||||||
|
|
||||||
|
|
||||||
def test_format_proxy_without_auth():
|
def test_format_proxy_without_auth():
|
||||||
config = {'username': 'user', 'password': 'pass', 'hostname': 'proxy.lan'}
|
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'
|
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|/[^ ]+$'),
|
('Foo/1.2.3', r'^Foo/1.2.3 Mopidy/[^ ]+ CPython|/[^ ]+$'),
|
||||||
])
|
])
|
||||||
def test_format_user_agent(name, expected):
|
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))
|
||||||
Loading…
Reference in New Issue
Block a user