Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix local tests #855

Merged
merged 9 commits into from
Jun 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGES/849.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fixes unittests that don't run locally due to deprecations in later versions of Docker. Tested with 26.00, v1.45.
1 change: 1 addition & 0 deletions CONTRIBUTORS.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Byeongjun Park
Cecil Tonglet
Christian Barra
Danny Song
eevelweezel
Gaopeiliang
Greg Guthe
Hiroki Kiyohara
Expand Down
2 changes: 1 addition & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ async def random_name():
docker = Docker()
images = await docker.images.list()
for img in images:
if img["RepoTags"] is None:
if not img["RepoTags"]:
continue
try:
if img["RepoTags"][0].startswith("aiodocker-"):
Expand Down
12 changes: 8 additions & 4 deletions tests/test_containers.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,12 +170,17 @@ async def test_resize(shell_container):
)
@pytest.mark.asyncio
async def test_commit(docker, image_name, shell_container):
"""
"Container" key was removed in v1.45.
"ContainerConfig" is not present, although this information is now present in "Config"
These changes have been verified against v1.45.
"""
ret = await shell_container.commit()
img_id = ret["Id"]
img = await docker.images.inspect(img_id)
assert img["Container"].startswith(shell_container.id)
assert "Image" in img["ContainerConfig"]
assert image_name == img["ContainerConfig"]["Image"]

assert "Image" in img["Config"]
assert image_name == img["Config"]["Image"]
python_img = await docker.images.inspect(image_name)
python_id = python_img["Id"]
assert "Parent" in img
Expand All @@ -191,7 +196,6 @@ async def test_commit_with_changes(docker, image_name, shell_container):
ret = await shell_container.commit(changes=["EXPOSE 8000", 'CMD ["py"]'])
img_id = ret["Id"]
img = await docker.images.inspect(img_id)
assert img["Container"].startswith(shell_container.id)
assert "8000/tcp" in img["Config"]["ExposedPorts"]
assert img["Config"]["Cmd"] == ["py"]
await docker.images.delete(img_id)
Expand Down
11 changes: 8 additions & 3 deletions tests/test_networks.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,17 @@ async def test_list_networks(docker):

@pytest.mark.asyncio
async def test_list_networks_with_filter(docker):
await docker.networks.create({
network = await docker.networks.create({
"Name": "test-net-filter",
"Labels": {"some": "label"},
})
networks = await docker.networks.list(filters={"label": "some=label"})
assert len(networks) == 1
try:
networks = await docker.networks.list(filters={"label": "some=label"})
assert len(networks) == 1
finally:
if network:
deleted = await network.delete()
assert deleted is True


@pytest.mark.asyncio
Expand Down