review/tests/test_check.py @ 6cd2b2e4286a

tests: whitespace
author Steve Losh <steve@stevelosh.com>
date Thu, 22 Jul 2010 18:26:29 -0400
parents 01a47fb22911
children bef3dce04be6
from nose import with_setup
from util import setup_reviewed_sandbox, teardown_sandbox, review, should_fail_with
from util import get_identifiers

from .. import messages

@with_setup(setup_reviewed_sandbox, teardown_sandbox)
def test_check_empty():
    def t(rev):
        output = review(check=True, rev=rev)
        assert not output

        output = review(check=True, verbose=True, rev=rev)
        assert messages.CHECK_SUCCESS in output

        review(signoff=True, no=True, message='.', rev=rev)
        output = review(check=True, verbose=True, rev=rev)
        assert messages.CHECK_SUCCESS in output

        i = get_identifiers(rev)[0]
        review(edit=i, yes=True, rev=rev)
        output = review(check=True, verbose=True, rev=rev)
        assert messages.CHECK_SUCCESS in output

        review(comment=True, message='.', rev=rev)
        output = review(check=True, verbose=True, rev=rev)
        assert messages.CHECK_SUCCESS in output
    t('.')
    t('0')

@with_setup(setup_reviewed_sandbox, teardown_sandbox)
def test_check_no_nos():
    output = review(check=True, verbose=True, no_nos=True)
    assert messages.CHECK_SUCCESS in output

    review(signoff=True, no=True, message='.')
    should_fail_with(messages.CHECK_HAS_NOS, check=True, verbose=True, no_nos=True)

    i = get_identifiers()[0]
    review(edit=i, yes=True)
    output = review(check=True, verbose=True, no_nos=True)
    assert messages.CHECK_SUCCESS in output

@with_setup(setup_reviewed_sandbox, teardown_sandbox)
def test_check_yeses():
    should_fail_with(messages.CHECK_TOO_FEW_YESES, check=True, verbose=True, yeses='1')

    output = review(check=True, verbose=True, yeses='0')
    assert messages.CHECK_SUCCESS in output

    review(signoff=True, yes=True, message='.')
    output = review(check=True, verbose=True, yeses='1')
    assert messages.CHECK_SUCCESS in output

    should_fail_with(messages.CHECK_TOO_FEW_YESES, check=True, verbose=True, yeses='2')

@with_setup(setup_reviewed_sandbox, teardown_sandbox)
def test_check_seen():
    should_fail_with(messages.CHECK_UNSEEN, check=True, verbose=True, seen=True)

    review(signoff=True, yes=True, message='.')
    output = review(check=True, verbose=True, seen=True)
    assert messages.CHECK_SUCCESS in output

    i = get_identifiers()[0]
    review(edit=i, no=True)
    output = review(check=True, verbose=True, seen=True)
    assert messages.CHECK_SUCCESS in output

    should_fail_with(messages.CHECK_UNSEEN, rev='0', check=True, verbose=True, seen=True)

    review(rev='0', comment=True, message='.')
    output = review(check=True, verbose=True, seen=True)
    assert messages.CHECK_SUCCESS in output

@with_setup(setup_reviewed_sandbox, teardown_sandbox)
def test_check_priority_no_nos():
    review(signoff=True, no=True, message='.')
    should_fail_with(messages.CHECK_HAS_NOS, check=True, verbose=True, no_nos=True, yeses='0')
    should_fail_with(messages.CHECK_HAS_NOS, check=True, verbose=True, no_nos=True, seen=True)
    should_fail_with(messages.CHECK_HAS_NOS, check=True, verbose=True, no_nos=True, seen=True, yeses='0')

    i = get_identifiers()[0]
    review(edit=i, yes=True)
    output = review(check=True, verbose=True, no_nos=True, seen=True, yeses='0')
    assert messages.CHECK_SUCCESS in output

    review(rev='0', signoff=True, no=True, message='.')
    review(rev='0', comment=True, message='.')
    should_fail_with(messages.CHECK_HAS_NOS, rev='0', check=True, verbose=True, no_nos=True)
    should_fail_with(messages.CHECK_HAS_NOS, rev='0', check=True, verbose=True, no_nos=True, seen=True)
    should_fail_with(messages.CHECK_HAS_NOS, rev='0', check=True, verbose=True, no_nos=True, seen=True, yeses='0')

@with_setup(setup_reviewed_sandbox, teardown_sandbox)
def test_check_priority_yeses():
    review(comment=True, message='.')
    should_fail_with(messages.CHECK_TOO_FEW_YESES, check=True, verbose=True, yeses='1', seen=True)

    review(signoff=True, yes=True, message='.')
    output = review(check=True, verbose=True, yeses='1', seen=True)
    assert messages.CHECK_SUCCESS in output

    # TODO: For multiple signoffs, no_nos should take priority over "yes" signoffs.