How to use pull_image method in localstack

Best Python code snippet using localstack_python

test_manager.py

Source:test_manager.py Github

copy

Full Screen

...148 self.container_mock.is_created.return_value = True149 self.manager.run(self.container_mock, input_data)150 # Container should be created151 self.container_mock.create.assert_not_called()152class TestContainerManager_pull_image(TestCase):153 def setUp(self):154 self.image_name = "image name"155 self.mock_docker_client = Mock()156 self.mock_docker_client.api = Mock()157 self.mock_docker_client.api.pull = Mock()158 self.manager = ContainerManager(docker_client=self.mock_docker_client)159 def test_must_pull_and_print_progress_dots(self):160 stream = io.StringIO()161 pull_result = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0]162 self.mock_docker_client.api.pull.return_value = pull_result163 expected_stream_output = "\nFetching {} Docker container image...{}\n".format(164 self.image_name, "." * len(pull_result) # Progress bar will print one dot per response from pull API165 )166 self.manager.pull_image(self.image_name, stream=stream)167 self.mock_docker_client.api.pull.assert_called_with(self.image_name, stream=True, decode=True, tag="latest")168 self.assertEqual(stream.getvalue(), expected_stream_output)169 def test_must_raise_if_image_not_found(self):170 msg = "some error"171 self.mock_docker_client.api.pull.side_effect = APIError(msg)172 with self.assertRaises(DockerImagePullFailedException) as context:173 self.manager.pull_image("imagename")174 ex = context.exception175 self.assertEqual(str(ex), msg)176 @patch("samcli.local.docker.manager.threading")177 def test_multiple_image_pulls_must_use_locks(self, mock_threading):178 self.mock_docker_client.api.pull.return_value = [1, 2, 3]179 # mock general lock180 mock_lock = MagicMock()181 self.manager._lock = mock_lock182 # mock locks per image183 mock_image1_lock = MagicMock()184 mock_image2_lock = MagicMock()185 mock_threading.Lock.side_effect = [mock_image1_lock, mock_image2_lock]186 # pull 2 different images for multiple times187 self.manager.pull_image("image1")188 self.manager.pull_image("image1")189 self.manager.pull_image("image2")190 # assert that image1 lock have been used twice and image2 lock only used once191 mock_image1_lock.assert_has_calls(2 * [call.__enter__(), call.__exit__(ANY, ANY, ANY)], any_order=True)192 mock_image2_lock.assert_has_calls([call.__enter__(), call.__exit__(ANY, ANY, ANY)])193 # assert that general lock have been used three times for all the image pulls194 mock_lock.assert_has_calls(3 * [call.__enter__(), call.__exit__(ANY, ANY, ANY)], any_order=True)195class TestContainerManager_is_docker_reachable(TestCase):196 def setUp(self):197 self.ping_mock = Mock()198 self.docker_client_mock = Mock()199 self.docker_client_mock.ping = self.ping_mock200 self.manager = ContainerManager(docker_client=self.docker_client_mock)201 def test_must_use_docker_client_ping(self):202 with patch.dict("sys.modules", patched_modules()):203 import samcli.local.docker.manager as manager_module...

Full Screen

Full Screen

urls.py

Source:urls.py Github

copy

Full Screen

1"""dockerclient URL Configuration2The `urlpatterns` list routes URLs to views. For more information please see:3 https://docs.djangoproject.com/en/3.1/topics/http/urls/4Examples:5Function views6 1. Add an import: from my_app import views7 2. Add a URL to urlpatterns: path('', views.home, name='home')8Class-based views9 1. Add an import: from other_app.views import Home10 2. Add a URL to urlpatterns: path('', Home.as_view(), name='home')11Including another URLconf12 1. Import the include() function: from django.urls import include, path13 2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))14"""15from django.contrib import admin16from django.urls import path17from app.views import *18urlpatterns = [19 path('admin/', admin.site.urls),20 path('', index, name="index"),21 path('pull_image', pull_image, name="pull_image"),22 path('create_container', create_container, name="create_container"),23 path('stop_container/<str:id>/', stop_container, name="stop_container"),24 path('start_container/<str:id>/', start_container, name="start_container"),25 path('delete_container/<str:id>/', delete_container, name="delete_container"),26 path('get_image_info/<str:name>/<str:stars>', get_image_info, name="get_image_info"),27 path('get_image_info/<str:repo>/<str:name>/<str:stars>', get_image_info, name="get_image_info2"),28 path('search_image', search_image, name="search_image"),29 path('get_image/', get_image, name="get_image"),30 path('previous_tag_list/<path:encoded_url>/', previous_tag_list, name="previous_tag_list"),31 path('next_tag_list/<path:encoded_url>/', next_tag_list, name="next_tag_list"),32 path('pull_image/<str:rpnme>/<str:tag>/', pull_image_from_docker_hub, name="pull_image"),33 path('build_image', build_image, name="build_image")...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run localstack automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful