def test_use_unofficial(self): self.set_config_values( setting={ 'server_host': 'example.com', 'server_port': 8042, 'use_server_for_submission': True, }) self.assertEqual('http://example.com:8042', build_submission_url()) self.assertEqual('http://example.com:8042/', build_submission_url('/')) self.assertEqual( 'http://example.com:8042/some/path?foo=1&bar=baz', build_submission_url('/some/path', { 'foo': 1, 'bar': 'baz' }))
def test_unofficial_fallback(self): self.set_config_values( setting={ 'server_host': 'test.musicbrainz.org', 'server_port': 80, 'use_server_for_submission': False, }) self.assertEqual('https://musicbrainz.org:443', build_submission_url()) self.assertEqual('https://musicbrainz.org:443/', build_submission_url('/')) self.assertEqual( 'https://musicbrainz.org:443/some/path?foo=1&bar=baz', build_submission_url('/some/path', { 'foo': 1, 'bar': 'baz' }))
def _get_form(title, action, label, form_data): return _form_template.format( title=htmlescape(title), submit_label=htmlescape(label), action=htmlescape(build_submission_url(action)), form_data=_format_form_data(form_data), )
def test_official(self): for host in MUSICBRAINZ_SERVERS: self.set_config_values( setting={ 'server_host': host, 'server_port': 80, 'use_server_for_submission': False, }) self.assertEqual('https://%s:443' % host, build_submission_url()) self.assertEqual('https://%s:443/' % host, build_submission_url('/')) self.assertEqual( 'https://%s:443/some/path?foo=1&bar=baz' % host, build_submission_url('/some/path', { 'foo': 1, 'bar': 'baz' }))
def submission_url(self): if self.id: return build_submission_url('/cdtoc/attach', query_args={ 'id': self.id, 'tracks': self.tracks, 'toc': self.toc_string.replace(' ', '+'), }) else: return None