# HG changeset patch # User Steve Losh # Date 1259628292 18000 # Node ID a85dc0c43f866d679aa7c0ef4e1ec9b891deae0c # Parent 6399fff665ffbfde04c4ab4c53d6e577003bd3d4 Add tests for {tip}. diff -r 6399fff665ff -r a85dc0c43f86 tests/test_node.py --- a/tests/test_node.py Fri Nov 27 15:00:33 2009 -0500 +++ b/tests/test_node.py Mon Nov 30 19:44:52 2009 -0500 @@ -1,6 +1,5 @@ '''Test output of {node}.''' -import os from nose import * from util import * diff -r 6399fff665ff -r a85dc0c43f86 tests/test_rev.py --- a/tests/test_rev.py Fri Nov 27 15:00:33 2009 -0500 +++ b/tests/test_rev.py Mon Nov 30 19:44:52 2009 -0500 @@ -1,6 +1,5 @@ '''Test output of {node}.''' -import os from nose import * from util import * diff -r 6399fff665ff -r a85dc0c43f86 tests/test_tip.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/test_tip.py Mon Nov 30 19:44:52 2009 -0500 @@ -0,0 +1,77 @@ +'''Test output of {tip}.''' + +from nose import * +from util import * + + +def _tip_rev(): + opts = { 'template': '{rev}', } + + _ui = get_sandbox_ui() + _ui.pushbuffer() + commands.tip(_ui, get_sandbox_repo(), **opts) + + return _ui.popbuffer() + +def _tip_node(): + opts = { 'template': '{node}', } + + _ui = get_sandbox_ui() + _ui.pushbuffer() + commands.tip(_ui, get_sandbox_repo(), **opts) + + return _ui.popbuffer() + + +@with_setup(setup_sandbox, teardown_sandbox) +def test_empty_repo(): + output = prompt(fs='{tip}') + assert output == '' + + output = prompt(fs='{ the tip is at {tip}}') + assert output == '' + + +@with_setup(setup_sandbox, teardown_sandbox) +def test_tip(): + hg_commit() + + output = prompt(fs='{tip}') + assert output == _tip_rev() + + output = prompt(fs='{ the tip is {tip}}') + assert output == ' the tip is %s' % _tip_rev() + + hg_commit() + output = prompt(fs='{tip}') + assert output == _tip_rev() + + +@with_setup(setup_sandbox, teardown_sandbox) +def test_node_filter(): + hg_commit() + + output = prompt(fs='{tip|node}') + assert output == _tip_node() + + output = prompt(fs='{ the tip is {tip|node}}') + assert output == ' the tip is %s' % _tip_node() + + hg_commit() + output = prompt(fs='{tip|node}') + assert output == _tip_node() + + +@with_setup(setup_sandbox, teardown_sandbox) +def test_short_filter(): + hg_commit() + + output = prompt(fs='{tip|node|short}') + assert output == _tip_node()[:12] + + output = prompt(fs='{ the tip is {tip|node|short}}') + assert output == ' the tip is %s' % _tip_node()[:12] + + hg_commit() + output = prompt(fs='{tip|node|short}') + assert output == _tip_node()[:12]