kopia lustrzana https://github.com/jupyterhub/repo2docker
Replace mocked find_image tests with real ones
rodzic
9753570370
commit
c04652e706
|
@ -65,7 +65,7 @@ jobs:
|
|||
- unit
|
||||
- venv
|
||||
- contentproviders
|
||||
- registry
|
||||
- norun
|
||||
# Playwright test
|
||||
- ui
|
||||
include:
|
||||
|
|
|
@ -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()
|
|
@ -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
|
|
@ -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:
|
||||
|
|
Ładowanie…
Reference in New Issue