Add a comment to a bug
>>> import time
>>> import libbe.bugdir
>>> import libbe.util.id
>>> bd = libbe.bugdir.SimpleBugDir(memory=False)
>>> io = libbe.command.StringInputOutput()
>>> io.stdout = sys.stdout
>>> ui = libbe.command.UserInterface(io=io)
>>> ui.storage_callbacks.set_storage(bd.storage)
>>> cmd = Comment(ui=ui)
>>> 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=['/a', 'This is a comment about a'])
Created comment with ID abc/a/X
>>> libbe.util.id.uuid_gen = uuid_gen
>>> bd.flush_reload()
>>> bug = bd.bug_from_uuid('a')
>>> bug.load_comments(load_full=False)
>>> comment = bug.comment_root[0]
>>> comment.id.storage() == comment.uuid
True
>>> print comment.body
This is a comment about a
>>> comment.author
u'Fran\xe7ois'
>>> comment.time <= int(time.time())
True
>>> comment.in_reply_to is None
True
>>> if 'EDITOR' in os.environ:
... del os.environ['EDITOR']
>>> if 'VISUAL' in os.environ:
... del os.environ['VISUAL']
>>> ui._user_id = u'Frank'
>>> ret = ui.run(cmd, args=['/b'])
Traceback (most recent call last):
UserError: No comment supplied, and EDITOR not specified.
>>> os.environ['EDITOR'] = "echo 'I like cheese' > "
>>> libbe.util.id.uuid_gen = lambda: 'Y'
>>> ret = ui.run(cmd, args=['/b'])
Created comment with ID abc/b/Y
>>> libbe.util.id.uuid_gen = uuid_gen
>>> bd.flush_reload()
>>> bug = bd.bug_from_uuid('b')
>>> bug.load_comments(load_full=False)
>>> comment = bug.comment_root[0]
>>> print comment.body
I like cheese
>>> ui.cleanup()
>>> bd.cleanup()
>>> del os.environ["EDITOR"]
Methods
cleanup() | |
complete([argument, fragment]) | |
help(*args) | |
run([options, args]) | |
usage() |