コード例 #1
0
from ...utils import merge_dicts
from ...utils import swallow_logs
from ...tests.utils import assert_in
from ...tests.skip import mark
from reproman.tests.fixtures import get_docker_fixture
from ...consts import TEST_SSH_DOCKER_DIGEST

# Skip entire module if no SSH is available.
pytestmark = mark.skipif_no_ssh

setup_ssh = get_docker_fixture(
    TEST_SSH_DOCKER_DIGEST,
    portmaps={
        49000: 22
    },
    custom_params={
        'host': 'localhost',
        'user': '******',
        'port': 49000
    },
    scope='module'
)


def test_setup_ssh(setup_ssh):
    # Rudimentary smoke test for setup_ssh so we have
    # multiple uses for the setup_ssh
    assert 'port' in setup_ssh['custom']
    assert setup_ssh['custom']['host'] == 'localhost'


def test_ssh_class(setup_ssh, resource_test_dir, resman):
コード例 #2
0
import logging
from unittest.mock import patch, MagicMock, call

from ...utils import merge_dicts
from ...utils import swallow_logs
from ...tests.utils import assert_in
from ...tests.skip import mark
from ...support.exceptions import ResourceError
from ...consts import TEST_SSH_DOCKER_DIGEST

from reproman.tests.fixtures import get_docker_fixture

from pytest import raises

setup_ubuntu = get_docker_fixture(TEST_SSH_DOCKER_DIGEST,
                                  scope='module',
                                  name='reproman-test-ssh-container')


@mark.skipif_no_docker_dependencies
def test_dockercontainer_class(resman):

    with patch('docker.APIClient') as client, \
        patch('dockerpty.start') as dockerpty, \
            swallow_logs(new_level=logging.DEBUG) as log:

        client.return_value = MagicMock(
            containers=lambda all: [{
                'Id': '326b0fdfbf83',
                'Names': ['/existing-test-resource'],
                'State': 'running'
コード例 #3
0
from reproman.tests.skip import mark
from reproman.tests.skip import skipif
from reproman.tests.utils import create_tree

try:
    lsf_config = os.environ['REPROMAN_LSF_TEST_CONFIG'].split(':')
    lsf_config = {
        "host": lsf_config[0],
        "user": lsf_config[1],
        "tmpdir_root": lsf_config[2]
    }
except (KeyError, ValueError):
    lsf_config = None

docker_container = get_docker_fixture(TEST_SSH_DOCKER_DIGEST,
                                      name="testing-container",
                                      scope="module")


@pytest.fixture(scope="module")
def docker_resource(docker_container):
    # TODO: This could be reworked to be included in fixtures.py. It is similar
    # to get_singularity_fixture, which should probably be renamed to include
    # "resource".
    from reproman.resource.docker_container import DockerContainer
    return DockerContainer("testing-container")


@pytest.fixture(scope="module")
def shell():
    return Shell("localshell")