def test_clone_command_simple_ssh_auth(): context = main.Context(topdir, auth=dict(type="ssh", key="/tmp/id.rsa")) generic_clone = commands.clone(context, ["ssh://hg.mozilla.org/bar"]) result = dialect.convert(generic_clone) assert result.reads_remote assert not result.writes_remote assert str(result) == "clone -e ssh -i /tmp/id.rsa -o StrictHostKeyChecking=no ssh://hg.mozilla.org/bar bar"
def test_clone_is_secured(): try: clone = commands.clone(secure_context, ["http://hg.mozilla.org/labs/bespin", topdir / ".." / "foo"]) assert False, "Expected exception for going above topdir" except commands.SecurityError: pass
def test_create_clone_command(): clone = commands.clone(context, ["http://hg.mozilla.org/labs/bespin", "bespin"]) assert clone.reads_remote assert not clone.writes_remote assert clone.source == "http://hg.mozilla.org/labs/bespin" assert clone.dest == "bespin" assert str(clone) == "clone http://hg.mozilla.org/labs/bespin bespin"
def test_clone_command_checks_for_existence(): bespin_dir = topdir / "bespin" if bespin_dir.exists(): bespin_dir.rmdir() # should work when the dest directory is not there. clone = commands.clone(context, ["http://hg.mozilla.org/labs/bespin"]) dest = clone.dest assert dest == "bespin" bespin_dir.mkdir() try: clone = commands.clone(context, ["http://hg.mozilla.org/labs/bespin"]) assert False, "Expected FileError for existing dest directory" except commands.FileError: pass bespin_dir.rmdir()
def test_bad_clone_command(): try: clone = commands.clone(context, []) assert False, "Expected BadArgument exception for missing args." except commands.BadArgument: pass
def test_clone_command_http_password_auth(): context = main.Context(topdir, auth=dict(type="password", username="******", password="******")) generic_clone = commands.clone(context, ["http://hg.mozilla.org/bar"]) result = dialect.convert(generic_clone) assert str(result) == "clone http://supercooluser:[email protected]/bar bar"
def test_clone_command_ssh_username_auth(): context = main.Context(topdir, auth=dict(type="ssh", key="/tmp/id.rsa", username="******")) generic_clone = commands.clone(context, ["ssh://hg.mozilla.org/bar"]) result = dialect.convert(generic_clone) assert str(result) == "clone -e ssh -i /tmp/id.rsa -o StrictHostKeyChecking=no ssh://[email protected]/bar bar"
def test_convert_function(): generic_clone = commands.clone(context, ["http://hg.mozilla.org/labs/bespin", "bespin"]) result = dialect.convert(generic_clone) assert str(result) == "clone http://hg.mozilla.org/labs/bespin bespin"
def test_clone_command_conversion(): generic_clone = commands.clone(context, ["http://hg.mozilla.org/labs/bespin", "bespin"]) hg_clone = hg.clone(generic_clone) assert str(hg_clone) == "clone http://hg.mozilla.org/labs/bespin bespin"
def test_convert_function(): generic_clone = commands.clone(context, ["http://paver.googlecode.com/svn/trunk/", "paver"]) svn_clone = dialect.convert(generic_clone) svn_clone_command = " ".join(svn_clone.get_command_line()) assert svn_clone_command == "svn checkout http://paver.googlecode.com/svn/trunk/ paver"