Skip to content

Commit

Permalink
Add another test function
Browse files Browse the repository at this point in the history
  • Loading branch information
winstonsmith1897 committed Aug 21, 2023
1 parent 61afe8c commit 0c79060
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 8 deletions.
Binary file modified application_manager/__pycache__/app_dht.cpython-310.pyc
Binary file not shown.
2 changes: 2 additions & 0 deletions application_manager/app_dht.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ def update_dht_list(ws, image_name):


def pull_image(ws, image_name, topic_uuid, requestor_id, request_id):
if image_name == "":
raise ValueError("Image name cannot be empty")
if image_name:
try:
client.images.pull(image_name)
Expand Down
Binary file not shown.
13 changes: 5 additions & 8 deletions tests/test_application_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,17 +74,14 @@ def test_publish_failure(self):
ws, topic_uuid, requestor_id, request_id, containers
)

def test_pull_image_invalid_image_name(self):
"""Test the pull_image function with an invalid image name."""
def test_pull_image_empty_image_name(self):
"""Test the pull_image function with an empty image name."""
ws = mock.Mock()
image_name = "invalid_image_name"
image_name = ""

# Call the pull_image function.
response = app_dht.pull_image(ws, image_name, "1", "1", "1")

# Assert that the response is not successful.
self.assertEqual(response[0], "Image not found")
self.assertEqual(response[1], 404)
with self.assertRaises(ValueError):
app_dht.pull_image(ws, image_name, "1", "1", "1")


if __name__ == "__main__":
Expand Down

0 comments on commit 0c79060

Please sign in to comment.