review/tests/test_signoff.py @ 85b4ae69ded2 webpy-sucks

Use the new annotated diff functionality to fix the changeset web UI.
author Steve Losh <steve@stevelosh.com>
date Wed, 03 Mar 2010 19:32:03 -0500
parents a5bfe965d4bc
children 22de90ef33ed
from nose import *
from util import *
from .. import messages

import os
from mercurial import util as hgutil


s1, s2 = (messages.REVIEW_LOG_SIGNOFF_AUTHOR % ('|', 'neutral')).split('|')
sy1, sy2 = (messages.REVIEW_LOG_SIGNOFF_AUTHOR % ('|', 'yes')).split('|')
sn1, sn2 = (messages.REVIEW_LOG_SIGNOFF_AUTHOR % ('|', 'no')).split('|')

@with_setup(setup_reviewed_sandbox, teardown_sandbox)
def test_no_signoffs():
    output = review()
    assert messages.REVIEW_LOG_SIGNOFFS % (0, 0, 0, 0) in output


@with_setup(setup_reviewed_sandbox, teardown_sandbox)
def test_blank_signoff():
    try:
        review(signoff=True)
    except hgutil.Abort, e:
        error = str(e)
        assert messages.SIGNOFF_REQUIRES_MESSAGE in error
    else:
        assert False, 'The correct error message was not printed.'


@with_setup(setup_reviewed_sandbox, teardown_sandbox)
def test_signoff_on_parent_rev():
    review(signoff=True, message='Test signoff one.')
    
    output = review()
    assert messages.REVIEW_LOG_SIGNOFFS % (1, 0, 0, 1) in output
    
    assert s1 in output
    assert s1 in output
    assert messages.REVIEW_LOG_SIGNOFF_LINE % 'Test signoff one.' in output


@with_setup(setup_reviewed_sandbox, teardown_sandbox)
def test_signoff_on_specific_rev():
    review(signoff=True, message='Test signoff one.', rev='0')
    
    output = review(rev='0')
    assert messages.REVIEW_LOG_SIGNOFFS % (1, 0, 0, 1) in output
    
    output = review()
    assert messages.REVIEW_LOG_SIGNOFFS % (0, 0, 0, 0) in output


@with_setup(setup_reviewed_sandbox, teardown_sandbox)
def test_multiple_signoffs():
    review(signoff=True, message='Test signoff one.')
    
    try:
        review(signoff=True, message='Test signoff two.')
    except hgutil.Abort, e:
        error = str(e)
        assert messages.SIGNOFF_EXISTS in error
    else:
        assert False, 'The correct error message was not printed.'
    
    review(signoff=True, message='Test signoff two.', force=True)
    
    output = review()
    assert messages.REVIEW_LOG_SIGNOFFS % (1, 0, 0, 1) in output


@with_setup(setup_reviewed_sandbox, teardown_sandbox)
def test_signoff_yes():
    review(signoff=True, yes=True, message='Test signoff one.')
    
    output = review()
    assert messages.REVIEW_LOG_SIGNOFFS % (1, 1, 0, 0) in output
    
    assert sy1 in output
    assert sy1 in output
    assert messages.REVIEW_LOG_SIGNOFF_LINE % 'Test signoff one.' in output


@with_setup(setup_reviewed_sandbox, teardown_sandbox)
def test_signoff_no():
    review(signoff=True, no=True, message='Test signoff one.')
    
    output = review()
    assert messages.REVIEW_LOG_SIGNOFFS % (1, 0, 1, 0) in output
    
    assert sn1 in output
    assert sn1 in output
    assert messages.REVIEW_LOG_SIGNOFF_LINE % 'Test signoff one.' in output