コード例 #1
0
def test_put_label_image(pull_docker_image):
    from sc import dockercli
    dockertester = dockercli.DockerCli('images')
    imageID = dockertester.get_imageID(pull_docker_image)
    dockertester.set_image(imageID)
    label = '{"Description":"A containerized foobar","Usage":"docker run --rm example/foobar [args]","License":"GPL","Version":"0.0.1-beta","aBoolean":true,"aNumber":0.01234,"aNestedArray":["a","b","c"]}'
    dockertester.put_label_image(label)
コード例 #2
0
def test_check_docker_connection():
    from sc import dockercli
    dockertester = dockercli.DockerCli("--help")
    if _platform == "darwin":
        docker_host = os.environ["DOCKER_HOST"]
        with pytest.raises(dockercli.DockerServerError):
            os.environ["DOCKER_HOST"] = "tcp://127.0.0.1:1000"
            dockertester.check_docker_connection()
        os.environ["DOCKER_HOST"] = docker_host
        dockertester.check_docker_connection()
    else:
        dockertester.check_docker_connection()
コード例 #3
0
def test_find_docker():
    from sc import dockercli
    oldenv = os.environ.copy()
    # Test location first
    oldpath = os.environ["PATH"]
    with pytest.raises(dockercli.DockerNotFoundError):
        dockertester = dockercli.DockerCli('help')
        # check that exceptions are being raised.
        os.environ["PATH"] = "NULL"
        location = dockertester.find_docker()
    os.environ["PATH"] = oldpath
    # Test environment variables on MacOS
    if _platform == "darwin":
        docker_host = os.environ["DOCKER_HOST"]
        with pytest.raises(dockercli.DockerNotFoundError):
            os.environ.clear()
            dockertester.find_docker()
        os.environ.update(oldenv)
        dockertester.check_docker_connection()
    if _platform == "linux":
        dockertester.find_docker()

    location = dockertester.find_docker()
    assert location is not None
コード例 #4
0
def test_docker_get_metadata(pull_docker_image):
    from sc import dockercli
    dockertester = dockercli.DockerCli('images')
    imageID = dockertester.get_imageID(pull_docker_image)
    dockertester.set_image(imageID)
    label = dockertester.get_metadata()
コード例 #5
0
def test_get_imageID(pull_docker_image):
    from sc import dockercli
    dockertester = dockercli.DockerCli('images')
    imageID = dockertester.get_imageID(pull_docker_image)
コード例 #6
0
def test_do_command_run():
    from sc import dockercli
    dockertester = dockercli.DockerCli('run /usr/bin/uname')
    dockertester.do_command()
コード例 #7
0
def test_do_command_simple():
    from sc import dockercli
    dockertester = dockercli.DockerCli('--help')
    dockertester.do_command()
コード例 #8
0
def test_sanity():
    from sc import dockercli
    dockertester = dockercli.DockerCli('help')
    dockertester.sanity_check()
コード例 #9
0
def test_docker_version():
    from sc import dockercli
    with pytest.raises(dockercli.DockerInsuficientVersionError):
        # This will fail if docker ever gets to version 100
        dockertester = dockercli.DockerCli("--help")
        dockertester.check_docker_version("100.100.100")