# Path: revolver/contextmanager.py
# def sudo(username=None, login=False):
# def unpatched_state():
# 
# Path: revolver/decorator.py
# def sudo(func):
#     def wrapper(*args, **kwargs):
# def multiargs(func):
#     def wrapper(*args, **kwargs):
# def inject_use_sudo(func):
#     def inject_wrapper(*args, **kwargs):
# 
# Path: revolver/core.py
# VERSION = '0.0.5'
# def put(*args, **kwargs):
# def run(*args, **kwargs):
# def sudo(*args, **kwargs):


import fabric
from revolver import contextmanager as ctx
from revolver import decorator, core


def test_inject_sudo_does_nothing_if_argument_given():
    assert decorator.inject_use_sudo(_sudo_dummy)(sudo=True)
    assert not decorator.inject_use_sudo(_sudo_dummy)(sudo=False)


def _use_sudo_dummy(use_sudo=None):
    return use_sudo


def test_sudo_dummy():
    assert _use_sudo_dummy() is None
    assert _use_sudo_dummy(True)
    assert not _use_sudo_dummy(False)


def test_inject_use_sudo_with_forced_sudo():
    with ctx.sudo():
        assert decorator.inject_use_sudo(_use_sudo_dummy)()


def test_inject_use_sudo_does_nothing_if_argument_given():
    assert decorator.inject_use_sudo(_use_sudo_dummy)(use_sudo=True)
    assert not decorator.inject_use_sudo(_use_sudo_dummy)(use_sudo=False)


def test_sudo():
    # TODO Properly mock/assert the used context
    def checker():

# Path: revolver/contextmanager.py
# def sudo(username=None, login=False):
# def unpatched_state():
# 
# Path: revolver/decorator.py
# def sudo(func):
#     def wrapper(*args, **kwargs):
# def multiargs(func):
#     def wrapper(*args, **kwargs):
# def inject_use_sudo(func):
#     def inject_wrapper(*args, **kwargs):
# 
# Path: revolver/core.py
# VERSION = '0.0.5'
# def put(*args, **kwargs):
# def run(*args, **kwargs):
# def sudo(*args, **kwargs):


# Path: revolver/test/decorator_test.py
import fabric
from revolver import contextmanager as ctx
from revolver import decorator, core



def test_inject_sudo_does_nothing_if_argument_given():
    assert decorator.inject_use_sudo(_sudo_dummy)(sudo=True)
    assert not decorator.inject_use_sudo(_sudo_dummy)(sudo=False)


def _use_sudo_dummy(use_sudo=None):
    return use_sudo


def test_sudo_dummy():
    assert _use_sudo_dummy() is None
    assert _use_sudo_dummy(True)
    assert not _use_sudo_dummy(False)


def test_inject_use_sudo_with_forced_sudo():
    with ctx.sudo():
        assert decorator.inject_use_sudo(_use_sudo_dummy)()


def test_inject_use_sudo_does_nothing_if_argument_given():
    assert decorator.inject_use_sudo(_use_sudo_dummy)(use_sudo=True)
    assert not decorator.inject_use_sudo(_use_sudo_dummy)(use_sudo=False)


def test_sudo():
    # TODO Properly mock/assert the used context
    def checker():

        assert core.env.sudo_forced