# HG changeset patch # User Steve Losh # Date 1255186311 14400 # Node ID 68e589a7c8c45e9d83cd1683a431f1852324638e # Parent 85ab60753c3358a7b81c88c10f491199c74c6b9d Add tests for contextual diffs with comments. fixes issue 12 diff -r 85ab60753c33 -r 68e589a7c8c4 review/tests/test_diffs.py --- a/review/tests/test_diffs.py Sat Oct 10 10:51:02 2009 -0400 +++ b/review/tests/test_diffs.py Sat Oct 10 10:51:51 2009 -0400 @@ -63,3 +63,49 @@ assert '17:' not in output assert messages.REVIEW_LOG_SKIPPED % 5 in output + + +@with_setup(setup_reviewed_sandbox, teardown_sandbox) +def test_review_diff_with_comment(): + sandbox = get_sandbox_repo() + + review(comment=True, rev='1', message='Test comment one.', + files=['long_file'], lines='6,7') + + output = review(rev='1', files=['long_file'], unified=0) + + # Make sure the comment is present at all. + assert a1 in output + assert a2 in output + assert messages.REVIEW_LOG_COMMENT_LINE % 'Test comment one.' in output + + # Make sure it's in the correct place + output = output.splitlines() + for n, line in enumerate(output): + if line.startswith('#'): + assert output[n-1].strip().startswith('7') + break + + +@with_setup(setup_reviewed_sandbox, teardown_sandbox) +def test_review_diff_with_skipped_comment(): + sandbox = get_sandbox_repo() + + review(comment=True, rev='1', message='Test comment one.', + files=['long_file'], lines='3') + + output = review(rev='1', files=['long_file'], unified=0) + + # Make sure the comment is present at all. + assert a1 in output + assert a2 in output + assert messages.REVIEW_LOG_COMMENT_LINE % 'Test comment one.' in output + + # Make sure it's in the correct place + output = output.splitlines() + for n, line in enumerate(output): + if line.startswith('#'): + assert output[n-1].startswith(s1) + assert output[n-1].endswith(s2.strip()) + break +