def test_create_container_from_scratch(config, docker_client): flexmock(exec_).should_receive("_build_initial_docker_image").with_args(docker_client, config).and_return("img1") flexmock(docker_client).should_receive("create_container").with_args( user="******", image="img1", tty=True, command="/bin/bash" ).and_return({"Id": "abcd"}) result = exec_._create_container(docker_client, config) assert result == "abcd" config.reload() assert config["global"]["snapshots"] == ["img1"]
def test_create_container_with_snapshot(config, docker_client): config["global"]["snapshots"] = ["img1", "img2", "img3"] config.write() flexmock(exec_).should_receive("_image_exists").and_return(False).and_return(True) flexmock(docker_client).should_receive("create_container").with_args( user="******", image="img2", tty=True, command="/bin/bash" ).and_return({"Id": "abcd", "Warnings": "Recreated"}) result = exec_._create_container(docker_client, config) assert result == "abcd" config.reload() assert config["global"]["snapshots"] == ["img1", "img2"]