def test_validate_playlist_config_returns_false_if_global_mode_is_whitelist_and_global_whitelist_not_set( self): validator = ConfigValidator( playlist={ 'DELAY_BETWEEN_SCANS': 90, 'GLOBAL_BLACKLIST': [], 'PROTECT_ALL': False, 'GLOBAL_MODE': 'whitelist', 'BACKUP_PATH': 'data/test/backup/some_path', 'MAX_BACKUPS_PER_PLAYLIST': 2, 'PROTECTED_PLAYLISTS': [] }) validator.validate_protected_playlists = Mock(return_value=True) self.assertFalse(validator.validate_playlist_config())
def test_validate_playlist_config_returns_true_if_all_fields_valid_and_protected_playlists_are_valid( self): validator = ConfigValidator( playlist={ 'DELAY_BETWEEN_SCANS': 90, 'GLOBAL_WHITELIST': [], 'GLOBAL_BLACKLIST': [], 'PROTECT_ALL': False, 'GLOBAL_MODE': 'blacklist', 'BACKUP_PATH': 'data/test/backup/some_path', 'MAX_BACKUPS_PER_PLAYLIST': 2, 'PROTECTED_PLAYLISTS': [] }) validator.validate_protected_playlists = Mock(return_value=True) self.assertTrue(validator.validate_playlist_config())
def test_validate_protected_playlist_returns_true_if_all_playlists_have_a_valid_uri( self): # empty whitelist and no whitelist are considered the same thing validator = ConfigValidator( playlist={ 'GLOBAL_MODE': 'blacklist', 'GLOBAL_WHITELIST': [], 'GLOBAL_BLACKLIST': [], 'PROTECTED_PLAYLISTS': [{ 'playlist1label': { 'uri': self.generate_playlist_uri() } }, { 'playlist2label': { 'uri': self.generate_playlist_uri() } }] }) self.assertTrue(validator.validate_protected_playlists())
def test_validate_protected_playlist_returns_false_if_any_playlists_has_no_uri( self): validator = ConfigValidator( playlist={ 'GLOBAL_MODE': 'blacklist', 'GLOBAL_WHITELIST': [], 'GLOBAL_BLACKLIST': [], 'PROTECTED_PLAYLISTS': [{ 'pl1label': { 'uri': self.generate_playlist_uri(), 'blacklist': [] } }, { 'pl2label': { 'blacklist': [] } }] }) self.assertFalse(validator.validate_protected_playlists())
def test_validate_protected_playlist_returns_false_if_a_playlist_has_more_than_one_label( self): # empty whitelist and no whitelist are considered the same thing validator = ConfigValidator( playlist={ 'GLOBAL_MODE': 'blacklist', 'GLOBAL_WHITELIST': [], 'GLOBAL_BLACKLIST': [], 'PROTECTED_PLAYLISTS': [{ 'playlist1label': { 'uri': self.generate_playlist_uri() }, 'playlist1label2': { 'uri': self.generate_playlist_uri() } }, { 'playlist2label': { 'uri': self.generate_playlist_uri() } }] }) self.assertFalse(validator.validate_protected_playlists())