def test_push_is_secured(): try: push = commands.push(secure_context, [topdir / ".." / "foo"]) assert False, "Expected security error for trying to push elsewhere" except commands.SecurityError: pass try: push = commands.push(secure_context, ["file:///etc/passwd"]) assert False, "Expected security error for trying to push elsewhere" except commands.SecurityError: pass
def test_push_command_ssh_username_auth(): context = main.Context(topdir, auth=dict(type="ssh", key="/tmp/id.rsa", username="******")) generic_push = commands.push(context, ["ssh://hg.mozilla.org/bar"]) result = dialect.convert(generic_push) assert result.writes_remote assert result.reads_remote assert str(result) == "push -e ssh -i /tmp/id.rsa -o StrictHostKeyChecking=no ssh://[email protected]/bar"
def test_push_command_before_commit(): commit_file = path(test_context.working_dir) / ".svn_commit_messages" if commit_file.exists(): commit_file.unlink() generic_push = commands.push(test_context, []) result = dialect.convert(generic_push) assert result.get_command_line() == None assert str(result.get_output()) == "Nothing to push. Run commit first."
def test_push_after_commit(): commit_file = path(test_context.working_dir) / ".svn_commit_messages" if commit_file.exists(): commit_file.unlink() generic_commit = commands.commit(test_context, ["-m", "test message1", "foo", "bar"]) result = dialect.convert(generic_commit) result.get_output() generic_commit = commands.commit(test_context, ["-m", "test message2", "foo", "bar"]) result = dialect.convert(generic_commit) result.get_output() generic_push = commands.push(test_context, []) result = dialect.convert(generic_push) assert result.get_command_line() == ["svn", "commit", "-m", "test message1\n\ntest message2\n\n"]
def test_push_command(): push = commands.push(test_context, []) assert push.reads_remote assert push.writes_remote assert str(push) == "push"