def test_replace_whitespace(self): whitelist = DEFAULT_WHITELIST_FILE replace = { ' ': '_', } self.assertEqual( FilenameTransformer.clean('f o o.xml', whitelist, replace), 'f_o_o.xml')
def test_custom_replace(self): replace = { '0': 'o', ' ': '_', ':': '_', } whitelist = DEFAULT_WHITELIST_FILE self.assertEqual( FilenameTransformer.clean('f:0o. xml', whitelist, replace=replace), 'f_oo.__xml')
def test_without_unicode_normalization(self): whitelist = DEFAULT_WHITELIST_FILE self.assertEqual( FilenameTransformer.clean('fåoäoö.xml', whitelist, normalize_unicode=False), 'foo.xml')
def test_custom_whitelist(self): whitelist = '.4{}'.format(string.ascii_letters) self.assertEqual( FilenameTransformer.clean('f1o2o3.x4m5l6', whitelist=whitelist), 'foo.x4ml')
def test_default_remove_special_characters(self): whitelist = DEFAULT_WHITELIST_FILE self.assertEqual( FilenameTransformer.clean('$f?o!o).x%m#l+', whitelist), 'foo.xml')
def test_default_replace_swedish_characters(self): whitelist = DEFAULT_WHITELIST_FILE self.assertEqual(FilenameTransformer.clean('åäö.xml', whitelist), 'aao.xml')
def test_default_correct(self): whitelist = DEFAULT_WHITELIST_FILE self.assertEqual(FilenameTransformer.clean('foo.xml', whitelist), 'foo.xml')