diff options
author | W. Trevor King <wking@drexel.edu> | 2009-12-31 14:32:39 -0500 |
---|---|---|
committer | W. Trevor King <wking@drexel.edu> | 2009-12-31 14:32:39 -0500 |
commit | cfae8a8302f06a84196700138d7ddbb25e91ea31 (patch) | |
tree | e5e158f424e01edeb83c0d6132af8b5c1d1808ea /libbe/command/import_xml.py | |
parent | 80e76f70d58672167b17ddaced6c7856ba703ece (diff) | |
download | bugseverywhere-cfae8a8302f06a84196700138d7ddbb25e91ea31.tar.gz |
Added UserInterface and other improved abstractions for command handling
Diffstat (limited to 'libbe/command/import_xml.py')
-rw-r--r-- | libbe/command/import_xml.py | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/libbe/command/import_xml.py b/libbe/command/import_xml.py index 2e96848..be22c82 100644 --- a/libbe/command/import_xml.py +++ b/libbe/command/import_xml.py @@ -44,14 +44,14 @@ class Import_XML (libbe.command.Command): >>> import StringIO >>> import libbe.bugdir >>> bd = libbe.bugdir.SimpleBugDir(memory=False) - >>> cmd = Import_XML() - >>> cmd._storage = bd.storage - >>> cmd._setup_io = lambda i_enc,o_enc : None - >>> cmd.stdout = sys.stdout + >>> io = libbe.command.StringInputOutput() + >>> io.stdout = sys.stdout + >>> ui = libbe.command.UserInterface(io=io) + >>> ui.storage_callbacks.set_storage(bd.storage) + >>> cmd = Import_XML(ui=ui) - >>> cmd.stdin = StringIO.StringIO('<be-xml><comment><uuid>c</uuid><body>This is a comment about a</body></comment></be-xml>') - >>> cmd.stdin.encoding = 'ascii' - >>> ret = cmd.run({'comment-root':'/a'}, ['-']) + >>> ui.io.set_stdin('<be-xml><comment><uuid>c</uuid><body>This is a comment about a</body></comment></be-xml>') + >>> ret = ui.run(cmd, {'comment-root':'/a'}, ['-']) >>> bd.flush_reload() >>> bug = bd.bug_from_uuid('a') >>> bug.load_comments(load_full=False) @@ -63,6 +63,7 @@ class Import_XML (libbe.command.Command): True >>> comment.in_reply_to is None True + >>> ui.cleanup() >>> bd.cleanup() """ name = 'import-xml' @@ -321,7 +322,10 @@ if libbe.TESTING == True: """ def setUp(self): self.bugdir = libbe.bugdir.SimpleBugDir(memory=False) - self.cmd = Import_XML() + io = libbe.command.StringInputOutput() + self.ui = libbe.command.UserInterface(io=io) + self.ui.storage_callbacks.set_storage(self.bugdir.storage) + self.cmd = Import_XML(ui=self.ui) self.cmd._storage = self.bugdir.storage self.cmd._setup_io = lambda i_enc,o_enc : None bugA = self.bugdir.bug_from_uuid('a') @@ -360,13 +364,12 @@ if libbe.TESTING == True: </bug> </be-xml> """ - self.cmd.stdin = StringIO.StringIO(self.xml) - self.cmd.stdin.encoding = 'ascii' - self.cmd.stdout = StringIO.StringIO() def tearDown(self): self.bugdir.cleanup() + self.ui.cleanup() def _execute(self, params={}, args=[]): - self.cmd.run(params, args) + self.ui.io.set_stdin(self.xml) + self.ui.run(self.cmd, params, args) self.bugdir.flush_reload() def testCleanBugdir(self): uuids = list(self.bugdir.uuids()) |