# Path: dcos_launch/util.py
# def get_temp_config_path(tmpdir, name, update: dict = None):
#     config = yaml.load(
#         pkg_resources.resource_string(dcos_launch.__name__, 'sample_configs/{}'.format(name)).decode('utf-8'))
#     if update is not None:
#         config.update(update)
#     new_config_path = tmpdir.join('my_config.yaml')
#     new_config_path.write(yaml.dump(config))
#     return str(new_config_path)
# 
# def stub(output):
#     def accept_any_args(*args, **kwargs):
#         return output
#     return accept_any_args


import functools
import json
import dcos_launch
import dcos_launch.cli
import dcos_launch.config
import dcos_launch.onprem
import dcos_launch.platforms
import dcos_test_utils
import dcos_test_utils.ssh_client
import pytest
from collections import namedtuple
from contextlib import contextmanager
from dcos_launch.util import get_temp_config_path, stub
from dcos_test_utils.helpers import Host



class MockTunnelled:
    def __init__(self, base_cmd: list, target: str):
        pass

    def command(self, cmd, **kwargs):
        return b''

    def copy_file(self, src, dst):
        pass


@contextmanager
def mocked_context(*args, **kwargs):
    """ To be directly patched into an ssh.tunnel invocation to prevent
    any real SSH attempt
    """
    yield MockTunnelled(list(), 'foo')


@pytest.fixture
def mocked_test_runner(monkeypatch):

# Path: dcos_launch/util.py
# def get_temp_config_path(tmpdir, name, update: dict = None):
#     config = yaml.load(
#         pkg_resources.resource_string(dcos_launch.__name__, 'sample_configs/{}'.format(name)).decode('utf-8'))
#     if update is not None:
#         config.update(update)
#     new_config_path = tmpdir.join('my_config.yaml')
#     new_config_path.write(yaml.dump(config))
#     return str(new_config_path)
# 
# def stub(output):
#     def accept_any_args(*args, **kwargs):
#         return output
#     return accept_any_args


# Path: test/conftest.py
import functools
import json
import dcos_launch
import dcos_launch.cli
import dcos_launch.config
import dcos_launch.onprem
import dcos_launch.platforms
import dcos_test_utils
import dcos_test_utils.ssh_client
import pytest
from collections import namedtuple
from contextlib import contextmanager
from dcos_launch.util import get_temp_config_path, stub
from dcos_test_utils.helpers import Host




class MockTunnelled:
    def __init__(self, base_cmd: list, target: str):
        pass

    def command(self, cmd, **kwargs):
        return b''

    def copy_file(self, src, dst):
        pass


@contextmanager
def mocked_context(*args, **kwargs):
    """ To be directly patched into an ssh.tunnel invocation to prevent
    any real SSH attempt
    """
    yield MockTunnelled(list(), 'foo')


@pytest.fixture
def mocked_test_runner(monkeypatch):

    monkeypatch.setattr(dcos_launch.util, 'try_to_output_unbuffered', stub(0))