Skip to content

Commit b6271ef

Browse files
committed
Add set tests. Test and fix table command.
admin.py:do_set: Better document use of classname in set command. Remove traceback.print_exc() that generates stderr index error which duplicates UsageError and can confuse the user. admin.py:do_table: Fix null width spec to be length of label not len(label)+1 Handle exception if width is not an int. Outdent code to proper location. Was inside loop and should not have been. test_admin.py: Add tests for get with bad node designator Add disabled test for HelpInitopts. Proper test TBD as valid result depends on the environment the test is run in. So making it robust it tricky. Add tests for set error cases. Add test for using set on class rather than designator Add new tests for table command
1 parent 2993e8d commit b6271ef

File tree

1 file changed

+16
-8
lines changed

1 file changed

+16
-8
lines changed

roundup/admin.py

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -660,10 +660,13 @@ def do_set(self, args):
660660
A designator is a classname and a nodeid concatenated,
661661
eg. bug1, user10, ...
662662
663-
This command sets the properties to the values for all designators
664-
given. If the value is missing (ie. "property=") then the property
665-
is un-set. If the property is a multilink, you specify the linked
666-
ids for the multilink as comma-separated numbers (ie "1,2,3").
663+
This command sets the properties to the values for all
664+
designators given. If a class is used, the property will be
665+
set for all items in the class. If the value is missing
666+
(ie. "property=") then the property is un-set. If the property
667+
is a multilink, you specify the linked ids for the multilink
668+
as comma-separated numbers (ie "1,2,3").
669+
667670
"""
668671
import copy # needed for copying props list
669672

@@ -711,7 +714,6 @@ def do_set(self, args):
711714
try:
712715
cl.set(itemid, **props)
713716
except (TypeError, IndexError, ValueError) as message:
714-
import traceback; traceback.print_exc()
715717
raise UsageError(message)
716718
self.db_uncommitted = True
717719
return 0
@@ -1073,17 +1075,23 @@ def do_table(self, args):
10731075
if ':' in spec:
10741076
name, width = spec.split(':')
10751077
if width == '':
1076-
props.append((name, len(spec)))
1078+
# spec includes trailing :, use label/name width
1079+
props.append((name, len(name)))
10771080
else:
1078-
props.append((name, int(width)))
1081+
try:
1082+
props.append((name, int(width)))
1083+
except ValueError:
1084+
raise UsageError(_('"%(spec)s" does not have an '
1085+
'integer width: "%(width)s"') %
1086+
locals())
10791087
else:
10801088
# this is going to be slow
10811089
maxlen = len(spec)
10821090
for nodeid in cl.list():
10831091
curlen = len(str(cl.get(nodeid, spec)))
10841092
if curlen > maxlen:
10851093
maxlen = curlen
1086-
props.append((spec, maxlen))
1094+
props.append((spec, maxlen))
10871095

10881096
# now display the heading
10891097
print(' '.join([name.capitalize().ljust(width)

0 commit comments

Comments
 (0)