review/tests/test_init.py @ deb1059d6425
Add some documentation for hg review --comment
author |
Steve Losh <steve@stevelosh.com> |
date |
Sat, 10 Oct 2009 19:45:45 -0400 |
parents |
8b8dee73f936 |
children |
4ede1c231525 |
from nose import *
from util import *
from .. import messages
from .. import api
import os
from mercurial import util as hgutil
@with_setup(setup_sandbox, teardown_sandbox)
def test_init():
sandbox = get_sandbox_repo()
output = review(init=True)
assert messages.INIT_SUCCESS in output
assert '.hgreview' not in sandbox['tip']
assert os.path.exists('.hgreview')
assert os.path.isdir(api.DEFAULT_DATASTORE_DIRNAME)
assert get_datastore_repo(api.DEFAULT_DATASTORE_DIRNAME)
with open('.hgreview', 'r') as hgrf:
hgr = hgrf.read()
assert 'local = %s' % api.DEFAULT_DATASTORE_DIRNAME in hgr
assert 'remote = ../sandbox-review' in hgr
@with_setup(setup_sandbox, teardown_sandbox)
def test_init_with_local_path():
sandbox = get_sandbox_repo()
output = review(init=True, local_path='NEW_PATH')
assert messages.INIT_SUCCESS in output
assert '.hgreview' not in sandbox['tip']
assert os.path.exists('.hgreview')
assert os.path.isdir('NEW_PATH')
assert get_datastore_repo('NEW_PATH')
with open('.hgreview', 'r') as hgrf:
hgr = hgrf.read()
assert 'local = NEW_PATH' in hgr
assert 'remote = ../sandbox-review' in hgr
@with_setup(setup_sandbox, teardown_sandbox)
def test_init_with_remote_path():
sandbox = get_sandbox_repo()
output = review(init=True, remote_path='../code-review')
assert messages.INIT_SUCCESS in output
assert '.hgreview' not in sandbox['tip']
assert os.path.exists('.hgreview')
assert os.path.isdir(api.DEFAULT_DATASTORE_DIRNAME)
assert get_datastore_repo(api.DEFAULT_DATASTORE_DIRNAME)
with open('.hgreview', 'r') as hgrf:
hgr = hgrf.read()
assert 'local = %s' % api.DEFAULT_DATASTORE_DIRNAME in hgr
assert 'remote = ../code-review' in hgr
@with_setup(setup_sandbox, teardown_sandbox)
def test_init_with_both_paths():
sandbox = get_sandbox_repo()
output = review(init=True, local_path='codereview', remote_path='../code-review')
assert messages.INIT_SUCCESS in output
assert '.hgreview' not in sandbox['tip']
assert os.path.exists('.hgreview')
assert os.path.isdir('codereview')
assert get_datastore_repo('codereview')
with open('.hgreview', 'r') as hgrf:
hgr = hgrf.read()
assert 'local = codereview' in hgr
assert 'remote = ../code-review' in hgr
@with_setup(setup_sandbox, teardown_sandbox)
def test_init_twice():
sandbox = get_sandbox_repo()
review(init=True)
try:
review(init=True)
except hgutil.Abort, e:
error = str(e)
assert messages.INIT_EXISTS_UNCOMMITTED in error
else:
assert False, 'The correct error message was not printed.'