def test_unavailable_bitrate_setting_returns_error(self): result = setting_utils.validate_settings( self.defaults, {'SPOTIFY_BITRATE': 50}) self.assertEqual( result['SPOTIFY_BITRATE'], 'Unavailable Spotify bitrate. ' 'Available bitrates are 96, 160, and 320.')
def test_deprecated_setting_value_returns_error(self): result = validate_settings(self.defaults, {'BACKENDS': ('mopidy.backends.despotify.DespotifyBackend',)}) self.assertEqual(result['BACKENDS'], u'Deprecated setting value. ' + '"mopidy.backends.despotify.DespotifyBackend" is no longer ' + 'available.')
def test_noniterable_multivalue_setting_returns_error(self): result = setting_utils.validate_settings( self.defaults, {'FRONTENDS': ('this is not a tuple')}) self.assertEqual( result['FRONTENDS'], 'Must be a tuple. ' "Remember the comma after single values: (u'value',)")
def test_deprecated_setting_value_returns_error(self): result = setting_utils.validate_settings( self.defaults, {'BACKENDS': ('mopidy.backends.despotify.DespotifyBackend', )}) self.assertEqual( result['BACKENDS'], u'Deprecated setting value. ' + '"mopidy.backends.despotify.DespotifyBackend" is no longer ' + 'available.')
def test_unknown_setting_returns_error(self): result = validate_settings(self.defaults, {'MPD_SERVER_HOSTNMAE': '127.0.0.1'}) self.assertEqual(result['MPD_SERVER_HOSTNMAE'], u'Unknown setting. Is it misspelled?')
def test_no_errors_yields_empty_dict(self): result = validate_settings(self.defaults, {}) self.assertEqual(result, {})
def test_empty_backends_list_returns_error(self): result = setting_utils.validate_settings( self.defaults, {'BACKENDS': []}) self.assertEqual( result['BACKENDS'], 'Must contain at least one value.')
def test_two_errors_are_both_reported(self): result = setting_utils.validate_settings( self.defaults, {'FOO': '', 'BAR': ''}) self.assertEqual(len(result), 2)
def test_custom_settings_does_not_return_errors(self): result = setting_utils.validate_settings( self.defaults, {'CUSTOM_MYAPP_SETTING': 'foobar'}) self.assertNotIn('CUSTOM_MYAPP_SETTING', result)
def test_unknown_setting_returns_error(self): result = setting_utils.validate_settings( self.defaults, {'MPD_SERVER_HOSTNMAE': '127.0.0.1'}) self.assertEqual( result['MPD_SERVER_HOSTNMAE'], 'Unknown setting. Did you mean MPD_SERVER_HOSTNAME?')
def test_no_errors_yields_empty_dict(self): result = setting_utils.validate_settings(self.defaults, {}) self.assertEqual(result, {})
def test_empty_frontends_list_returns_error(self): result = setting_utils.validate_settings(self.defaults, {'FRONTENDS': []}) self.assertEqual(result['FRONTENDS'], 'Must be set.')
def test_not_renamed_setting_returns_error(self): result = validate_settings(self.defaults, {'SERVER_HOSTNAME': '127.0.0.1'}) self.assertEqual(result['SERVER_HOSTNAME'], u'Deprecated setting. Use MPD_SERVER_HOSTNAME.')
def test_not_renamed_setting_returns_error(self): result = setting_utils.validate_settings( self.defaults, {'SERVER_HOSTNAME': '127.0.0.1'}) self.assertEqual( result['SERVER_HOSTNAME'], 'Deprecated setting. Use MPD_SERVER_HOSTNAME.')
def test_unneeded_settings_returns_error(self): result = validate_settings(self.defaults, {'SPOTIFY_LIB_APPKEY': '/tmp/foo'}) self.assertEqual(result['SPOTIFY_LIB_APPKEY'], u'Deprecated setting. It may be removed.')
def test_unneeded_settings_returns_error(self): result = setting_utils.validate_settings( self.defaults, {'SPOTIFY_LIB_APPKEY': '/tmp/foo'}) self.assertEqual( result['SPOTIFY_LIB_APPKEY'], 'Deprecated setting. It may be removed.')
def test_two_errors_are_both_reported(self): result = validate_settings(self.defaults, {'FOO': '', 'BAR': ''}) self.assertEqual(len(result), 2)
def test_empty_frontends_list_returns_error(self): result = setting_utils.validate_settings( self.defaults, {'FRONTENDS': []}) self.assertEqual( result['FRONTENDS'], 'Must be set.')