# HG changeset patch # User Steve Losh # Date 1254699112 14400 # Node ID 35fbbd1bbd26bdeeb79b55c0c28568fe7f004cee # Parent 94b4bdc4a60c69b4a23fc8f7261fa132bdd98372 Add a commenting test, and more test utils. diff -r 94b4bdc4a60c -r 35fbbd1bbd26 review/tests/test_comment.py --- /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.' + diff -r 94b4bdc4a60c -r 35fbbd1bbd26 review/tests/util.py --- 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)