review/tests/test_init.py @ b5deba11fc17

Add working tests.  Awesome.
author Steve Losh <steve@stevelosh.com>
date Sun, 04 Oct 2009 16:12:09 -0400
parents 4d7eca6c1832
children e72a3408cc68
from nose import *
from util import *

import os


@with_setup(setup_sandbox, teardown_sandbox)
def test_init():
    sandbox = get_sandbox_repo()
    
    review(init=True)
    
    assert '.hgreview' not in sandbox['tip']
    assert os.path.exists('.hgreview')
    assert os.path.isdir('.review')
    assert get_datastore_repo('.review')
    
    with open('.hgreview', 'r') as hgrf:
        hgr = hgrf.read()
        assert 'local = .review' in hgr
        assert 'remote = ../sandbox-review' in hgr


@with_setup(setup_sandbox, teardown_sandbox)
def test_init_with_local_path():
    sandbox = get_sandbox_repo()
    
    review(init=True, local_path='codereview')
    
    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 = ../sandbox-review' in hgr


@with_setup(setup_sandbox, teardown_sandbox)
def test_init_with_remote_path():
    sandbox = get_sandbox_repo()
    
    review(init=True, remote_path='../code-review')
    
    assert '.hgreview' not in sandbox['tip']
    assert os.path.exists('.hgreview')
    assert os.path.isdir('.review')
    assert get_datastore_repo('.review')
    
    with open('.hgreview', 'r') as hgrf:
        hgr = hgrf.read()
        assert 'local = .review' in hgr
        assert 'remote = ../code-review' in hgr


@with_setup(setup_sandbox, teardown_sandbox)
def test_init_with_both_paths():
    sandbox = get_sandbox_repo()
    
    review(init=True, local_path='codereview', remote_path='../code-review')
    
    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