18 |
18 |
import wcs.api # workaround against circular dependencies :/
|
19 |
19 |
from wcs.qommon.form import FileSizeWidget, PicklableUpload
|
20 |
20 |
from wcs.qommon.humantime import humanduration2seconds, seconds2humanduration
|
21 |
|
from wcs.qommon.misc import (simplify, json_loads, parse_isotime, format_time,
|
22 |
|
date_format, get_as_datetime, normalize_geolocation)
|
|
21 |
from wcs.qommon.misc import (
|
|
22 |
simplify, json_loads, parse_isotime, format_time,
|
|
23 |
date_format, get_as_datetime, normalize_geolocation, ellipsize)
|
23 |
24 |
from wcs.admin.settings import FileTypesDirectory
|
24 |
25 |
from wcs.scripts import Script
|
25 |
26 |
from wcs.qommon import force_str, evalutils
|
... | ... | |
555 |
556 |
field.id = '1'
|
556 |
557 |
field.label = 'test'
|
557 |
558 |
assert repr(field) == "<StringField 1 'test'>"
|
|
559 |
|
|
560 |
|
|
561 |
@pytest.mark.parametrize('value, length, expected', [
|
|
562 |
('', 30, ''),
|
|
563 |
(None, 30, 'None'),
|
|
564 |
('foo bar', 30, 'foo bar'),
|
|
565 |
('01234567890123456789012345678', 30, '01234567890123456789012345678'),
|
|
566 |
('012345678901234567890123456789', 30, '012345678901234567890123456789'),
|
|
567 |
('0123456789012345678901234567890', 30, '012345678901234567890123456(…)'),
|
|
568 |
('foo bar', 4, 'f(…)'),
|
|
569 |
('foo bar', 3, 'foo'),
|
|
570 |
('foo bar', 2, 'fo'),
|
|
571 |
])
|
|
572 |
def test_ellipsize(value, length, expected):
|
|
573 |
create_temporary_pub()
|
|
574 |
assert ellipsize(value, length=length) == expected
|