-
Notifications
You must be signed in to change notification settings - Fork 101
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move most of the remaining tests to use docker_client or ctr_client f…
…ixture (#535)
- Loading branch information
Showing
9 changed files
with
298 additions
and
250 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,45 @@ | ||
from pathlib import Path | ||
|
||
import pytest | ||
|
||
from python_on_whales import docker | ||
from python_on_whales import DockerClient | ||
|
||
|
||
@pytest.mark.usefixtures("swarm_mode") | ||
def test_list_configs(): | ||
assert docker.config.list() == [] | ||
def test_list_configs(docker_client: DockerClient): | ||
assert docker_client.config.list() == [] | ||
|
||
|
||
@pytest.mark.usefixtures("swarm_mode") | ||
def test_create_delete_config(tmp_path): | ||
def test_create_delete_config(docker_client: DockerClient, tmp_path: Path): | ||
config_file = tmp_path / "config.conf" | ||
config_file.write_text("hello world") | ||
my_conf = docker.config.create("my_conf", config_file) | ||
my_conf = docker_client.config.create("my_conf", config_file) | ||
with my_conf: | ||
assert my_conf.spec.name == "my_conf" | ||
assert docker.config.list() == [my_conf] | ||
assert docker.config.inspect("my_conf") == my_conf | ||
repr(docker.config.list()) | ||
assert docker_client.config.list() == [my_conf] | ||
assert docker_client.config.inspect("my_conf") == my_conf | ||
repr(docker_client.config.list()) | ||
|
||
|
||
@pytest.mark.usefixtures("swarm_mode") | ||
def test_labels_config(tmp_path): | ||
def test_labels_config(docker_client: DockerClient, tmp_path: Path): | ||
config_file = tmp_path / "config.conf" | ||
config_file.write_text("hello world") | ||
my_conf = docker.config.create("my_conf", config_file, labels=dict(dodo="dada")) | ||
my_conf = docker_client.config.create( | ||
"my_conf", config_file, labels=dict(dodo="dada") | ||
) | ||
with my_conf: | ||
assert my_conf.spec.name == "my_conf" | ||
assert docker.config.list(filters=dict(label="dodo=dada")) == [my_conf] | ||
assert docker.config.list(filters=dict(label="dodo=dadu")) == [] | ||
assert docker_client.config.list(filters=dict(label="dodo=dada")) == [my_conf] | ||
assert docker_client.config.list(filters=dict(label="dodo=dadu")) == [] | ||
|
||
|
||
@pytest.mark.usefixtures("swarm_mode") | ||
def test_remove_empty_config_list(tmp_path): | ||
def test_remove_empty_config_list(docker_client: DockerClient, tmp_path: Path): | ||
config_file = tmp_path / "config.conf" | ||
config_file.write_text("hello world") | ||
with docker.config.create("my_conf", config_file) as my_conf: | ||
assert docker.config.list() == [my_conf] | ||
docker.config.remove([]) | ||
assert docker.config.list() == [my_conf] | ||
with docker_client.config.create("my_conf", config_file) as my_conf: | ||
assert docker_client.config.list() == [my_conf] | ||
docker_client.config.remove([]) | ||
assert docker_client.config.list() == [my_conf] |
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
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
Oops, something went wrong.