Skip to content

Commit ebb99c1

Browse files
committed
The search function of the Docker Engine has removed, because not used anymore.
1 parent 08ecf26 commit ebb99c1

File tree

2 files changed

+2
-42
lines changed

2 files changed

+2
-42
lines changed

dem/core/container_engine.py

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -115,17 +115,4 @@ def remove(self, image: str) -> None:
115115
except docker.errors.ImageNotFound:
116116
self.user_output.msg(f"[yellow]The {image} doesn't exist. Unable to remove it.[/]\n")
117117
except docker.errors.APIError:
118-
raise ContainerEngineError(f"The {image} is used by a container. Unable to remove it.\n")
119-
120-
def search(self, registry: str) -> list[str]:
121-
""" Search for repositories on Docker Hub.
122-
123-
Args:
124-
registry -- registry to search
125-
"""
126-
repositories = []
127-
128-
for repositories in self._docker_client.images.search(registry):
129-
repositories.append(repositories['name'])
130-
131-
return repositories
118+
raise ContainerEngineError(f"The {image} is used by a container. Unable to remove it.\n")

tests/core/test_container_engine.py

Lines changed: 1 addition & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -292,31 +292,4 @@ def test_remove_APIError(mock_from_env: MagicMock) -> None:
292292
# Check expectations
293293
assert str(exported_exception_info) == f"The {test_image_to_remove} is used by a container. Unable to remove it.[/]\n"
294294

295-
mock_docker_client.images.remove.assert_called_once_with(test_image_to_remove)
296-
297-
@patch("docker.from_env")
298-
def test_search(mock_from_env):
299-
# Test setup
300-
mock_docker_client = MagicMock()
301-
mock_from_env.return_value = mock_docker_client
302-
test_registry = "test_registry"
303-
test_repositories = [
304-
{
305-
"name": "repo1"
306-
},
307-
{
308-
"name": "repo2"
309-
},
310-
]
311-
mock_docker_client.images.search.return_value = test_repositories
312-
313-
test_container_engine = container_engine.ContainerEngine()
314-
315-
# Run unit under test
316-
actual_registry_image_list = test_container_engine.search(test_registry)
317-
318-
# Check expectations
319-
mock_docker_client.images.search.assert_called_once_with(test_registry)
320-
321-
expected_registry_image_list = ["repo1", "repo2"]
322-
assert actual_registry_image_list == expected_registry_image_list
295+
mock_docker_client.images.remove.assert_called_once_with(test_image_to_remove)

0 commit comments

Comments
 (0)