tests: add tests for qommon.misc.simplify (#6846)
This commit is contained in:
parent
b22b3b126f
commit
4230ff7d9d
|
@ -1,10 +1,17 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
import pytest
|
||||
|
||||
from quixote import cleanup
|
||||
|
||||
import wcs.api # workaround against circular dependencies :/
|
||||
from wcs.qommon.form import FileSizeWidget
|
||||
from wcs.qommon.humantime import humanduration2seconds, seconds2humanduration
|
||||
from wcs.qommon.misc import simplify
|
||||
from wcs.admin.settings import FileTypesDirectory
|
||||
|
||||
def setup_module(module):
|
||||
cleanup()
|
||||
|
||||
def test_parse_file_size():
|
||||
assert FileSizeWidget.parse_file_size('17') == 17
|
||||
assert FileSizeWidget.parse_file_size('17o') == 17
|
||||
|
@ -46,3 +53,26 @@ def test_format_mimetypes():
|
|||
'application/pdf (.pdf), '\
|
||||
'application/vnd.openxmlformats-officedocument.wordprocessingml.document (.docx)'\
|
||||
'...'
|
||||
|
||||
def test_simplify_unchanged():
|
||||
assert simplify('test') == 'test'
|
||||
assert simplify('another-test') == 'another-test'
|
||||
assert simplify('another_test', '_') == 'another_test'
|
||||
|
||||
def test_simplify_space():
|
||||
assert simplify('test again') == 'test-again'
|
||||
assert simplify(' test again ') == 'test-again'
|
||||
assert simplify('test again', '_') == 'test_again'
|
||||
assert simplify(' test again ', '_') == 'test_again'
|
||||
|
||||
def test_simplify_accented():
|
||||
assert simplify(u'cliché') == 'cliche'
|
||||
assert simplify(u'cliché'.encode('iso-8859-1')) == 'cliche'
|
||||
|
||||
def test_simplify_remove():
|
||||
assert simplify('this is: (a) "test"') == 'this-is-a-test'
|
||||
assert simplify('a test; again?') == 'a-test-again'
|
||||
|
||||
def test_simplify_mix():
|
||||
assert simplify(u' this is: (a) "cliché" ') == 'this-is-a-cliche'
|
||||
assert simplify(u' À "cliché"; again? ') == 'a-cliche-again'
|
||||
|
|
Loading…
Reference in New Issue