467dacbab7d6

Move the review output into messages, and add a no-comments test.
[view raw] [browse files]
author Steve Losh <steve@stevelosh.com>
date Sun, 04 Oct 2009 19:41:58 -0400
parents 35fbbd1bbd26
children adce24d24176
branches/tags (none)
files review/extension_ui.py review/messages.py review/tests/test_comment.py review/tests/util.py

Changes

--- a/review/extension_ui.py	Sun Oct 04 19:31:52 2009 -0400
+++ b/review/extension_ui.py	Sun Oct 04 19:41:58 2009 -0400
@@ -37,16 +37,16 @@
     cset = repo[rev]
     rcset = rd[rev]
     
+    comment_count = len(rcset.comments)
     author_count = len(set(comment.author for comment in rcset.comments))
     
-    ui.write('changeset: %d:%s\n' % (cset.rev(), short(cset.node())))
-    ui.write('author:    %s\n' % cset.user())
-    ui.write('summary:   %s\n\n' % cset.description().split('\n')[0])
+    ui.write(messages.REVIEW_LOG_CSET % (cset.rev(), short(cset.node())))
+    ui.write(messages.REVIEW_LOG_AUTHOR % cset.user())
+    ui.write(messages.REVIEW_LOG_SUMMARY % cset.description().split('\n')[0])
     
     
-    ui.write('signoffs:  %d signoffs\n' % len(rcset.signoffs))
-    ui.write('comments:  %d comments from %d authors\n\n' % (
-        len(rcset.comments), author_count))
+    ui.write(messages.REVIEW_LOG_SIGNOFFS % len(rcset.signoffs))
+    ui.write(messages.REVIEW_LOG_COMMENTS % (comment_count, author_count))
 
 
 cmdtable = {
--- a/review/messages.py	Sun Oct 04 19:31:52 2009 -0400
+++ b/review/messages.py	Sun Oct 04 19:41:58 2009 -0400
@@ -20,4 +20,26 @@
 
 COMMENT_REQUIRES_MESSAGE = '''\
 a message must be provided to add a comment!
-'''
\ No newline at end of file
+'''
+
+REVIEW_LOG_CSET = '''\
+changeset: %d:%s
+'''
+
+REVIEW_LOG_AUTHOR = '''\
+author:    %s
+'''
+
+REVIEW_LOG_SUMMARY = '''\
+summary:   %s
+
+'''
+
+REVIEW_LOG_SIGNOFFS = '''\
+signoffs:  %d signoffs
+'''
+
+REVIEW_LOG_COMMENTS = '''\
+comments:  %d comments from %d authors
+
+'''
--- a/review/tests/test_comment.py	Sun Oct 04 19:31:52 2009 -0400
+++ b/review/tests/test_comment.py	Sun Oct 04 19:41:58 2009 -0400
@@ -18,3 +18,13 @@
     else:
         assert False, 'The correct error message was not printed.'
 
+
+@with_setup(setup_reviewed_sandbox, teardown_sandbox)
+def test_no_comments():
+    sandbox = get_sandbox_repo()
+    
+    gather_output()
+    review()
+    output = grab_output()
+    
+    assert messages.REVIEW_LOG_COMMENTS % (0, 0) in output
--- a/review/tests/util.py	Sun Oct 04 19:31:52 2009 -0400
+++ b/review/tests/util.py	Sun Oct 04 19:41:58 2009 -0400
@@ -54,4 +54,7 @@
     _ui.pushbuffer()
 
 def grab_output():
-    return _ui.popbuffer()
+    output = _ui.popbuffer()
+    print output
+    
+    return output