review/tests/test_diffs.py @ 85ab60753c33

Refactor the author line generation in tests.  It's much cleaner now.
author Steve Losh <steve@stevelosh.com>
date Sat, 10 Oct 2009 10:51:02 -0400
parents 69bbcf7f0830
children 68e589a7c8c4
from nose import *
from util import *
from .. import messages

import os


a1, a2 = (messages.REVIEW_LOG_COMMENT_AUTHOR % '|').split('|')
s1, s2 = (messages.REVIEW_LOG_SKIPPED % 1111).split('1111')


@with_setup(setup_reviewed_sandbox, teardown_sandbox)
def test_review_diff_default_context():
    sandbox = get_sandbox_repo()
    
    output = review(rev='1', files=['long_file'], unified='5')
    
    assert ' 0:' not in output
    assert messages.REVIEW_LOG_SKIPPED % 1 in output
    
    for n in range(1, 20):
        assert '%2d:' % n in output
    
    assert '-g' in output
    assert '+X' in output
    assert '-m' in output
    assert '+Y' in output
    
    assert '20:' not in output
    assert messages.REVIEW_LOG_SKIPPED % 2 in output


@with_setup(setup_reviewed_sandbox, teardown_sandbox)
def test_review_diff_full_context():
    sandbox = get_sandbox_repo()
    
    output = review(rev='1', files=['long_file'], unified='10000')
    
    assert s1 not in output
    assert s2 not in output
    
    for n in range(0, 21):
        assert '%2d:' % n in output


@with_setup(setup_reviewed_sandbox, teardown_sandbox)
def test_review_diff_small_context():
    sandbox = get_sandbox_repo()
    
    output = review(rev='1', files=['long_file'], unified='2')
    
    assert ' 3:' not in output
    assert messages.REVIEW_LOG_SKIPPED % 4 in output
    
    assert '-g' in output
    assert '+X' in output
    
    assert '10:' not in output
    assert messages.REVIEW_LOG_SKIPPED % 2 in output
    
    assert '-m' in output
    assert '+Y' in output
    
    assert '17:' not in output
    assert messages.REVIEW_LOG_SKIPPED % 5 in output