Use https and http appropriately when connecting to MusicBrainz
Fixed some bugs: - MusicBrainz submit URL always has https as protocol: hardcoded, even when inappropriate. It's just a graphical issue. - Whipper appears to always communicate with MusicBrainz using musicbrainzngs over http. The musicbrainzngs.set_hostname(server). - `musicbrainzngs.set_hostname(server)` always defaults to http. Since musicbrainzngs version 0.7 the method `set_hostname` takes an optional argument named `use_https` (defaults to False) which whipper never passes. Changed behaviour of `server` option (`musicbrainz` section of whipper's configuration file). Now it expects an URL with a valid scheme (scheme must be `http` or `http`, empty scheme isn't allowed anymore). Only the scheme and netloc parts of the URL are taken into account. Fixes #437. Signed-off-by: JoeLametta <JoeLametta@users.noreply.github.com>
This commit is contained in:
@@ -69,25 +69,25 @@ class ConfigTestCase(tcommon.TestCase):
|
||||
|
||||
def test_get_musicbrainz_server(self):
|
||||
self.assertEqual(self._config.get_musicbrainz_server(),
|
||||
'musicbrainz.org',
|
||||
{'scheme': 'https', 'netloc': 'musicbrainz.org'},
|
||||
msg='Default value is correct')
|
||||
|
||||
self._config._parser.add_section('musicbrainz')
|
||||
|
||||
self._config._parser.set('musicbrainz', 'server',
|
||||
'192.168.2.141:5000')
|
||||
'http://192.168.2.141:5000')
|
||||
self._config.write()
|
||||
self.assertEqual(self._config.get_musicbrainz_server(),
|
||||
'192.168.2.141:5000',
|
||||
{'scheme': 'http', 'netloc': '192.168.2.141:5000'},
|
||||
msg='Correctly returns user-set value')
|
||||
|
||||
self._config._parser.set('musicbrainz', 'server',
|
||||
'192.168.2.141:5000/hello/world')
|
||||
# Test for unsupported scheme
|
||||
self._config._parser.set('musicbrainz', 'server', 'ftp://example.com')
|
||||
self._config.write()
|
||||
self.assertRaises(KeyError, self._config.get_musicbrainz_server)
|
||||
|
||||
self._config._parser.set('musicbrainz', 'server',
|
||||
'http://192.168.2.141:5000')
|
||||
# Test for absent scheme
|
||||
self._config._parser.set('musicbrainz', 'server', 'example.com')
|
||||
self._config.write()
|
||||
self.assertRaises(KeyError, self._config.get_musicbrainz_server)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user