35fbbd1bbd26

Add a commenting test, and more test utils.
[view raw] [browse files]
author Steve Losh <steve@stevelosh.com>
date Sun, 04 Oct 2009 19:31:52 -0400
parents 94b4bdc4a60c
children 467dacbab7d6
branches/tags (none)
files review/tests/test_comment.py review/tests/util.py

Changes

--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/review/tests/test_comment.py	Sun Oct 04 19:31:52 2009 -0400
@@ -0,0 +1,20 @@
+from nose import *
+from util import *
+
+import os
+from .. import messages
+from mercurial import util as hgutil
+
+
+@with_setup(setup_reviewed_sandbox, teardown_sandbox)
+def test_blank_comment():
+    sandbox = get_sandbox_repo()
+    
+    try:
+        review(comment=True)
+    except hgutil.Abort, e:
+        error = str(e)
+        assert messages.COMMENT_REQUIRES_MESSAGE in error
+    else:
+        assert False, 'The correct error message was not printed.'
+
--- a/review/tests/util.py	Sun Oct 04 19:19:01 2009 -0400
+++ b/review/tests/util.py	Sun Oct 04 19:31:52 2009 -0400
@@ -5,9 +5,11 @@
 
 
 _ui = ui.ui()
-def review(init=False, local_path='', remote_path=''):
+def review(init=False, comment=False, message='', rev='.',
+    local_path='', remote_path=''):
     return extension_ui.review(_ui, get_sandbox_repo(),
-        init=init, local_path=local_path, remote_path=remote_path)
+        init=init, comment=comment, message=message, rev=rev,
+        local_path=local_path, remote_path=remote_path)
 
 
 sandbox_path = os.path.join(os.path.realpath('.'), 'sandbox')
@@ -27,6 +29,16 @@
                 f.write(state[filename])
         commands.commit(_ui, sandbox, **opts)
 
+def setup_reviewed_sandbox():
+    setup_sandbox()
+    sandbox = get_sandbox_repo()
+    
+    review(init=True)
+    
+    opts = { 'addremove': True, 'date': None, 'user': 'Review Tester',
+             'logfile': None, 'message': "Add the code review.", }
+    commands.commit(_ui, sandbox, **opts)
+
 def teardown_sandbox():
     os.chdir(os.path.realpath(os.path.join(sandbox_path, os.pardir)))
     shutil.rmtree(sandbox_path)