Skip to content

Commit 1fabd9f

Browse files
committed
f-d
1 parent 5d3cf30 commit 1fabd9f

File tree

3 files changed

+30
-6
lines changed

3 files changed

+30
-6
lines changed

aiidalab_launch/__main__.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -359,12 +359,6 @@ async def _async_start(
359359
fg="yellow",
360360
)
361361

362-
if instance.image is None:
363-
raise click.ClickException(
364-
f"Unable to find image '{profile.image}'. "
365-
"Try to use '--pull' to pull the image prior to start."
366-
)
367-
368362
# Check if the container configuration has changed.
369363
if instance.container:
370364
configuration_changed = any(instance.configuration_changes())

tests/conftest.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,19 @@ def docker_client():
5757
pytest.skip("docker not available")
5858

5959

60+
@pytest.fixture(scope="function")
61+
def remove_created_images(docker_client):
62+
"""Remove all images created by the tests."""
63+
images = docker_client.images.list()
64+
yield
65+
for image in docker_client.images.list():
66+
if image not in images:
67+
try:
68+
image.remove()
69+
except docker.errors.APIError:
70+
pass
71+
72+
6073
@pytest.fixture(autouse=True)
6174
def _select_default_image(monkeypatch_session, pytestconfig):
6275
_default_image = pytestconfig.getoption("default_image")

tests/test_util.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ def test_get_latest_version_timeout(mock_pypi_request_timeout):
1717

1818

1919
@pytest.mark.usefixtures("enable_docker_pull")
20+
@pytest.mark.usefixtures("remove_created_images")
2021
def test_image_is_latest(docker_client):
2122
"""Test that the latest version is identified correctly."""
2223
# download the alpine image for testing
@@ -25,3 +26,19 @@ def test_image_is_latest(docker_client):
2526

2627
# check that the image is identified as latest
2728
assert image_is_latest(docker_client, image_name)
29+
30+
31+
@pytest.mark.usefixtures("enable_docker_pull")
32+
@pytest.mark.usefixtures("remove_created_images")
33+
def test_image_is_not_latest(docker_client):
34+
"""Test that the outdate version is identified correctly and will ask for pull the latest."""
35+
# download the alpine image for testing
36+
old_image_name = "alpine:2.6"
37+
latest_image_name = "alpine:latest"
38+
39+
# pull the old image and retag it as latest to mock the outdated image
40+
old_image = docker_client.images.pull(old_image_name)
41+
old_image.tag(latest_image_name)
42+
43+
# check that the image is identified as latest
44+
assert not image_is_latest(docker_client, latest_image_name)

0 commit comments

Comments
 (0)