Replace mocked find_image tests with real ones

pull/1421/head
YuviPanda 2025-02-28 13:11:34 -08:00
rodzic 9753570370
commit c04652e706
5 zmienionych plików z 25 dodań i 31 usunięć

Wyświetl plik

@ -65,7 +65,7 @@ jobs:
- unit
- venv
- contentproviders
- registry
- norun
# Playwright test
- ui
include:

Wyświetl plik

@ -0,0 +1,23 @@
import secrets
from pathlib import Path
from repo2docker.__main__ import make_r2d
HERE = Path(__file__).parent
def test_find_image():
image_name = f"{secrets.token_hex(8)}:latest"
r2d = make_r2d(["--image", image_name, "--no-run", str(HERE)])
r2d.start()
assert r2d.find_image()
def test_dont_find_image():
image_name = f"{secrets.token_hex(8)}:latest"
r2d = make_r2d(["--image", image_name, "--no-run", str(HERE)])
# Just don't actually start the build, so image won't be found
assert not r2d.find_image()

Wyświetl plik

@ -116,4 +116,4 @@ def test_registry(registry, dind):
r2d.start()
proc = subprocess.run(["docker", "manifest", "inspect", "--insecure", image_name])
assert proc.returncode == 0
assert proc.returncode == 0

Wyświetl plik

@ -10,35 +10,6 @@ from repo2docker.__main__ import make_r2d
from repo2docker.app import Repo2Docker
from repo2docker.utils import chdir
def test_find_image():
images = [{"RepoTags": ["some-org/some-repo:latest"]}]
with patch("repo2docker.docker.docker.APIClient") as FakeDockerClient:
instance = FakeDockerClient.return_value
instance.images.return_value = images
r2d = Repo2Docker()
r2d.output_image_spec = "some-org/some-repo"
assert r2d.find_image()
instance.images.assert_called_with()
def test_dont_find_image():
images = [{"RepoTags": ["some-org/some-image-name:latest"]}]
with patch("repo2docker.docker.docker.APIClient") as FakeDockerClient:
instance = FakeDockerClient.return_value
instance.images.return_value = images
r2d = Repo2Docker()
r2d.output_image_spec = "some-org/some-other-image-name"
assert not r2d.find_image()
instance.images.assert_called_with()
def test_image_name_remains_unchanged():
# if we specify an image name, it should remain unmodified
with TemporaryDirectory() as src: