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)
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()
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
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()
def test_get_imageID(pull_docker_image): from sc import dockercli dockertester = dockercli.DockerCli('images') imageID = dockertester.get_imageID(pull_docker_image)
def test_do_command_run(): from sc import dockercli dockertester = dockercli.DockerCli('run /usr/bin/uname') dockertester.do_command()
def test_do_command_simple(): from sc import dockercli dockertester = dockercli.DockerCli('--help') dockertester.do_command()
def test_sanity(): from sc import dockercli dockertester = dockercli.DockerCli('help') dockertester.sanity_check()
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")