-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #45 from esben/container-create
Improvements to container_create()
- Loading branch information
Showing
5 changed files
with
118 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import pytest | ||
import contextlib | ||
import os | ||
import re | ||
|
||
from xd.docker.client import * | ||
from xd.docker.container import * | ||
from xd.docker.parameters import * | ||
|
||
|
||
def test_pull_needed(docker, stdout): | ||
with stdout.redirect(): | ||
container = docker.container_create( | ||
ContainerConfig("busybox:latest"), | ||
"xd-docker-container-create-1") | ||
assert container is not None | ||
assert isinstance(container, Container) | ||
assert re.match('^[0-9a-f]+$', container.id) | ||
|
||
|
||
def test_pull_but_not_needed(docker, stdout): | ||
docker.image_pull("busybox:latest") | ||
with stdout.redirect(): | ||
container = docker.container_create( | ||
ContainerConfig("busybox:latest"), | ||
"xd-docker-container-create-2") | ||
assert container is not None | ||
assert isinstance(container, Container) | ||
assert re.match('^[0-9a-f]+$', container.id) | ||
|
||
|
||
def test_no_pull_but_needed(docker, stdout): | ||
with pytest.raises(ClientError): | ||
docker.container_create( | ||
ContainerConfig("busybox:latest"), | ||
"xd-docker-container-create-3", | ||
pull=False) | ||
|
||
|
||
def test_no_pull_and_not_needed(docker, stdout): | ||
docker.image_pull("busybox:latest") | ||
with stdout.redirect(): | ||
container = docker.container_create( | ||
ContainerConfig("busybox:latest"), | ||
"xd-docker-container-create-4", | ||
pull=False) | ||
assert container is not None | ||
assert isinstance(container, Container) | ||
assert re.match('^[0-9a-f]+$', container.id) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters