From 952a9472a66123ad7eccfa02ee5c76c11442ed0c Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Sat, 16 Apr 2011 13:37:17 -0400 Subject: Centralize assigned processing in parse_assigned & add assigned test to New. --- libbe/command/assign.py | 15 ++++++++++----- libbe/command/new.py | 14 +++++++------- 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/libbe/command/assign.py b/libbe/command/assign.py index 0b3f407..964a957 100644 --- a/libbe/command/assign.py +++ b/libbe/command/assign.py @@ -73,11 +73,7 @@ class Assign (libbe.command.Command): ]) def _run(self, **params): - assigned = params['assigned'] - if assigned == 'none': - assigned = None - elif assigned == '-': - assigned = self._get_user_id() + assigned = parse_assigned(self, params['assigned']) bugdir = self._get_bugdir() for bug_id in params['bug-id']: bug,dummy_comment = \ @@ -99,3 +95,12 @@ Special assigned strings: "-" assign the bug to yourself "none" un-assigns the bug """ + +def parse_assigned(command, assigned): + """Standard processing for the 'assigned' Argument. + """ + if assigned == 'none': + assigned = None + elif assigned == '-': + assigned = command._get_user_id() + return assigned diff --git a/libbe/command/new.py b/libbe/command/new.py index 849eafb..763d09a 100644 --- a/libbe/command/new.py +++ b/libbe/command/new.py @@ -21,6 +21,8 @@ import libbe import libbe.command import libbe.command.util +from .assign import parse_assigned as _parse_assigned + class New (libbe.command.Command): """Create a new bug @@ -40,7 +42,8 @@ class New (libbe.command.Command): >>> uuid_gen = libbe.util.id.uuid_gen >>> libbe.util.id.uuid_gen = lambda: 'X' >>> ui._user_id = u'Fran\\xe7ois' - >>> ret = ui.run(cmd, args=['this is a test',]) + >>> options = {'assigned': 'none'} + >>> ret = ui.run(cmd, options=options, args=['this is a test',]) Created bug with ID abc/X >>> libbe.util.id.uuid_gen = uuid_gen >>> bd.flush_reload() @@ -57,6 +60,8 @@ class New (libbe.command.Command): minor >>> print bug.status open + >>> print bug.assigned + None >>> ui.cleanup() >>> bd.cleanup() """ @@ -109,12 +114,7 @@ class New (libbe.command.Command): else: bug.reporter = bug.creator if params['assigned'] != None: - assigned = params['assigned'] - if assigned == 'none': - assigned = None - elif assigned == '-': - assigned = self._get_user_id() - bug.assigned = assigned + bug.assigned = _parse_assigned(self, params['assigned']) if params['status'] != None: bug.status = params['status'] if params['severity'] != None: -- cgit