Centralize assigned processing in parse_assigned & add assigned test to New.
authorW. Trevor King <wking@drexel.edu>
Sat, 16 Apr 2011 17:37:17 +0000 (13:37 -0400)
committerW. Trevor King <wking@drexel.edu>
Sat, 16 Apr 2011 17:37:17 +0000 (13:37 -0400)
libbe/command/assign.py
libbe/command/new.py

index 0b3f407231244f67c2c5b6525f3d455636aa8da5..964a957db54bfa6d048810589019deefb24aae43 100644 (file)
@@ -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
index 849eafb9502231a8749f53dfc1f9dd63ed56cf80..763d09a31a852412998ed485e2e4538d045971ff 100644 (file)
@@ -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: