How to use get_image_id method in lisa

Best Python code snippet using lisa_python

test_sahara_client.py

Source: test_sahara_client.py Github

copy

Full Screen

...30 c = con.clients31 self.sahara_plugin = c.client_plugin('sahara')32 self.sahara_plugin._client = self.sahara_client33 self.my_image = mock.MagicMock()34 def test_get_image_id(self):35 """Tests the get_image_id function."""36 img_id = str(uuid.uuid4())37 img_name = 'myfakeimage'38 self.my_image.id = img_id39 self.my_image.name = img_name40 self.sahara_client.images.get.return_value = self.my_image41 self.sahara_client.images.find.side_effect = [[self.my_image], []]42 self.assertEqual(img_id, self.sahara_plugin.get_image_id(img_id))43 self.assertEqual(img_id, self.sahara_plugin.get_image_id(img_name))44 self.assertRaises(exception.EntityNotFound,45 self.sahara_plugin.get_image_id, 'noimage')46 calls = [mock.call(name=img_name),47 mock.call(name='noimage')]48 self.sahara_client.images.get.assert_called_once_with(img_id)49 self.sahara_client.images.find.assert_has_calls(calls)50 def test_get_image_id_by_name_in_uuid(self):51 """Tests the get_image_id function by name in uuid."""52 img_id = str(uuid.uuid4())53 img_name = str(uuid.uuid4())54 self.my_image.id = img_id55 self.my_image.name = img_name56 self.sahara_client.images.get.side_effect = [57 sahara_base.APIException(error_code=400,58 error_name='IMAGE_NOT_REGISTERED')]59 self.sahara_client.images.find.return_value = [self.my_image]60 self.assertEqual(img_id, self.sahara_plugin.get_image_id(img_name))61 self.sahara_client.images.get.assert_called_once_with(img_name)62 self.sahara_client.images.find.assert_called_once_with(name=img_name)63 def test_get_image_id_sahara_exception(self):64 """Test get_image_id when sahara raises an exception."""65 # Simulate HTTP exception66 img_name = str(uuid.uuid4())67 self.sahara_client.images.find.side_effect = [68 sahara_base.APIException(error_message="Error", error_code=404)]69 expected_error = "Error retrieving image list from sahara: Error"70 e = self.assertRaises(exception.Error,71 self.sahara_plugin.get_image_id_by_name,72 img_name)73 self.assertEqual(expected_error, six.text_type(e))74 self.sahara_client.images.find.assert_called_once_with(name=img_name)...

Full Screen

Full Screen

test_glance_client.py

Source: test_glance_client.py Github

copy

Full Screen

...30 c = con.clients31 self.glance_plugin = c.client_plugin('glance')32 self.glance_plugin._client = self.glance_client33 self.my_image = mock.MagicMock()34 def test_get_image_id(self):35 """Tests the get_image_id function."""36 img_id = str(uuid.uuid4())37 img_name = 'myfakeimage'38 self.my_image.id = img_id39 self.my_image.name = img_name40 self.glance_client.images.get.return_value = self.my_image41 self.glance_client.images.list.side_effect = ([self.my_image], [])42 self.assertEqual(img_id, self.glance_plugin.get_image_id(img_id))43 self.assertEqual(img_id, self.glance_plugin.get_image_id(img_name))44 self.assertRaises(exception.EntityNotFound,45 self.glance_plugin.get_image_id, 'noimage')46 calls = [mock.call(filters={'name': img_name}),47 mock.call(filters={'name': 'noimage'})]48 self.glance_client.images.get.assert_called_once_with(img_id)49 self.glance_client.images.list.assert_has_calls(calls)50 def test_get_image_id_by_name_in_uuid(self):51 """Tests the get_image_id function by name in uuid."""52 img_id = str(uuid.uuid4())53 img_name = str(uuid.uuid4())54 self.my_image.id = img_id55 self.my_image.name = img_name56 self.glance_client.images.get.side_effect = [57 glance_exceptions.HTTPNotFound()]58 self.glance_client.images.list.return_value = [self.my_image]59 self.assertEqual(img_id, self.glance_plugin.get_image_id(img_name))60 self.glance_client.images.get.assert_called_once_with(img_name)61 self.glance_client.images.list.assert_called_once_with(62 filters={'name': img_name})63 def test_get_image_id_glance_exception(self):64 """Test get_image_id when glance raises an exception."""65 # Simulate HTTP exception66 img_name = str(uuid.uuid4())67 self.glance_client.images.list.side_effect = [68 glance_exceptions.ClientException("Error")]69 expected_error = "Error retrieving image list from glance: Error"70 e = self.assertRaises(exception.Error,71 self.glance_plugin.get_image_id_by_name,72 img_name)73 self.assertEqual(expected_error, six.text_type(e))...

Full Screen

Full Screen

test_get.py

Source: test_get.py Github

copy

Full Screen

...19 ],20 )21 def test_get_image_policy_evaluation(self, add_alpine_latest_image, query):22 add_resp, api_conf = add_alpine_latest_image23 image_id = get_image_id(add_resp)24 wait_for_image_to_analyze(image_id, api_conf)25 image_tag = get_image_tag(add_resp)26 query["tag"] = image_tag27 if query.get("policyId"):28 query["policyId"] = get_first_policy_id(api_conf)29 resp = http_get(30 ["images", "by_id", image_id, "check"], {"tag": image_tag}, config=api_conf31 )32 assert resp == APIResponse(200)33 def test_list_image_content_types(self, add_alpine_latest_image):34 add_resp, api_conf = add_alpine_latest_image35 image_id = get_image_id(add_resp)36 resp = http_get(["images", "by_id", image_id, "content"], config=api_conf)37 assert resp == APIResponse(200)38 def test_get_image_content_files(self, add_alpine_latest_image):39 add_resp, api_conf = add_alpine_latest_image40 image_id = get_image_id(add_resp)41 wait_for_image_to_analyze(image_id, api_conf)42 resp = http_get(43 ["images", "by_id", image_id, "content", "files"], config=api_conf44 )45 assert resp == APIResponse(200)46 def test_get_image_content_java(self, add_alpine_latest_image):47 add_resp, api_conf = add_alpine_latest_image48 image_id = get_image_id(add_resp)49 wait_for_image_to_analyze(image_id, api_conf)50 resp = http_get(51 ["images", "by_id", image_id, "content", "java"], config=api_conf52 )53 assert resp == APIResponse(200)54 def test_get_image_content_ctype(self, add_alpine_latest_image):55 add_resp, api_conf = add_alpine_latest_image56 image_id = get_image_id(add_resp)57 wait_for_image_to_analyze(image_id, api_conf)58 resp = http_get(["images", "by_id", image_id, "content", "os"], config=api_conf)59 assert resp == APIResponse(200)60 def test_get_image_vuln_types(self, add_alpine_latest_image):61 add_resp, api_conf = add_alpine_latest_image62 image_id = get_image_id(add_resp)63 resp = http_get(["images", "by_id", image_id, "vuln"], config=api_conf)64 assert resp == APIResponse(200)65 def test_get_all_image_vulns_by_type(self, add_alpine_latest_image):66 add_resp, api_conf = add_alpine_latest_image67 image_id = get_image_id(add_resp)68 resp = http_get(["images", "by_id", image_id, "vuln"], config=api_conf)69 assert resp == APIResponse(200)70 wait_for_image_to_analyze(image_id, api_conf)71 vuln_types = resp.body72 for v_type in vuln_types:73 resp = http_get(74 ["images", "by_id", image_id, "vuln", v_type], config=api_conf75 )...

Full Screen

Full Screen

Blogs

Check out the latest blogs from LambdaTest on this topic:

How To Handle Multiple Windows In Selenium Python

Automating testing is a crucial step in the development pipeline of a software product. In an agile development environment, where there is continuous development, deployment, and maintenance of software products, automation testing ensures that the end software products delivered are error-free.

Joomla Testing Guide: How To Test Joomla Websites

Before we discuss the Joomla testing, let us understand the fundamentals of Joomla and how this content management system allows you to create and maintain web-based applications or websites without having to write and implement complex coding requirements.

Starting & growing a QA Testing career

The QA testing career includes following an often long, winding road filled with fun, chaos, challenges, and complexity. Financially, the spectrum is broad and influenced by location, company type, company size, and the QA tester’s experience level. QA testing is a profitable, enjoyable, and thriving career choice.

The Art of Testing the Untestable

It’s strange to hear someone declare, “This can’t be tested.” In reply, I contend that everything can be tested. However, one must be pleased with the outcome of testing, which might include failure, financial loss, or personal injury. Could anything be tested when a claim is made with this understanding?

How To Create Custom Menus with CSS Select

When it comes to UI components, there are two versatile methods that we can use to build it for your website: either we can use prebuilt components from a well-known library or framework, or we can develop our UI components from scratch.

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 lisa 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