How to use assertNotEmpty method in tempest

Best Python code snippet using tempest_python

test_list_image_filters.py

Source:test_list_image_filters.py Github

copy

Full Screen

...109 # The list of images should contain only images with the110 # provided status111 params = {'status': 'ACTIVE'}112 images = self.client.list_images(**params)['images']113 self.assertNotEmpty([i for i in images if i['id'] == self.image1_id])114 self.assertNotEmpty([i for i in images if i['id'] == self.image2_id])115 self.assertNotEmpty([i for i in images if i['id'] == self.image3_id])116 @decorators.idempotent_id('33163b73-79f5-4d07-a7ea-9213bcc468ff')117 def test_list_images_filter_by_name(self):118 # List of all images should contain the expected images filtered119 # by name120 params = {'name': self.image1['name']}121 images = self.client.list_images(**params)['images']122 self.assertNotEmpty([i for i in images if i['id'] == self.image1_id])123 self.assertEmpty([i for i in images if i['id'] == self.image2_id])124 self.assertEmpty([i for i in images if i['id'] == self.image3_id])125 @decorators.idempotent_id('9f238683-c763-45aa-b848-232ec3ce3105')126 @testtools.skipUnless(CONF.compute_feature_enabled.snapshot,127 'Snapshotting is not available.')128 def test_list_images_filter_by_server_id(self):129 # The images should contain images filtered by server id130 params = {'server': self.server1['id']}131 images = self.client.list_images(**params)['images']132 self.assertNotEmpty([i for i in images133 if i['id'] == self.snapshot1_id],134 "Failed to find image %s in images. "135 "Got images %s" % (self.image1_id, images))136 self.assertNotEmpty([i for i in images137 if i['id'] == self.snapshot2_id])138 self.assertEmpty([i for i in images if i['id'] == self.snapshot3_id])139 @decorators.idempotent_id('05a377b8-28cf-4734-a1e6-2ab5c38bf606')140 @testtools.skipUnless(CONF.compute_feature_enabled.snapshot,141 'Snapshotting is not available.')142 def test_list_images_filter_by_server_ref(self):143 # The list of servers should be filtered by server ref144 server_links = self.server2['links']145 # Try all server link types146 for link in server_links:147 params = {'server': link['href']}148 images = self.client.list_images(**params)['images']149 self.assertEmpty([i for i in images150 if i['id'] == self.snapshot1_id])151 self.assertEmpty([i for i in images152 if i['id'] == self.snapshot2_id])153 self.assertNotEmpty([i for i in images154 if i['id'] == self.snapshot3_id])155 @decorators.idempotent_id('e3356918-4d3e-4756-81d5-abc4524ba29f')156 @testtools.skipUnless(CONF.compute_feature_enabled.snapshot,157 'Snapshotting is not available.')158 def test_list_images_filter_by_type(self):159 # The list of servers should be filtered by image type160 params = {'type': 'snapshot'}161 images = self.client.list_images(**params)['images']162 self.assertNotEmpty([i for i in images163 if i['id'] == self.snapshot1_id])164 self.assertNotEmpty([i for i in images165 if i['id'] == self.snapshot2_id])166 self.assertNotEmpty([i for i in images167 if i['id'] == self.snapshot3_id])168 self.assertEmpty([i for i in images if i['id'] == self.image_ref])169 @decorators.idempotent_id('3a484ca9-67ba-451e-b494-7fcf28d32d62')170 def test_list_images_limit_results(self):171 # Verify only the expected number of results are returned172 params = {'limit': '1'}173 images = self.client.list_images(**params)['images']174 self.assertEqual(1, len([x for x in images if 'id' in x]))175 @decorators.idempotent_id('18bac3ae-da27-436c-92a9-b22474d13aab')176 def test_list_images_filter_by_changes_since(self):177 # Verify only updated images are returned in the detailed list178 # Becoming ACTIVE will modify the updated time179 # Filter by the image's created time180 params = {'changes-since': self.image3['created']}181 images = self.client.list_images(**params)['images']182 found = [i for i in images if i['id'] == self.image3_id]183 self.assertNotEmpty(found)184 @decorators.idempotent_id('9b0ea018-6185-4f71-948a-a123a107988e')185 def test_list_images_with_detail_filter_by_status(self):186 # Detailed list of all images should only contain images187 # with the provided status188 params = {'status': 'ACTIVE'}189 images = self.client.list_images(detail=True, **params)['images']190 self.assertNotEmpty([i for i in images if i['id'] == self.image1_id])191 self.assertNotEmpty([i for i in images if i['id'] == self.image2_id])192 self.assertNotEmpty([i for i in images if i['id'] == self.image3_id])193 @decorators.idempotent_id('644ea267-9bd9-4f3b-af9f-dffa02396a17')194 def test_list_images_with_detail_filter_by_name(self):195 # Detailed list of all images should contain the expected196 # images filtered by name197 params = {'name': self.image1['name']}198 images = self.client.list_images(detail=True, **params)['images']199 self.assertNotEmpty([i for i in images if i['id'] == self.image1_id])200 self.assertEmpty([i for i in images if i['id'] == self.image2_id])201 self.assertEmpty([i for i in images if i['id'] == self.image3_id])202 @decorators.idempotent_id('ba2fa9a9-b672-47cc-b354-3b4c0600e2cb')203 def test_list_images_with_detail_limit_results(self):204 # Verify only the expected number of results (with full details)205 # are returned206 params = {'limit': '1'}207 images = self.client.list_images(detail=True, **params)['images']208 self.assertEqual(1, len(images))209 @decorators.idempotent_id('8c78f822-203b-4bf6-8bba-56ebd551cf84')210 @testtools.skipUnless(CONF.compute_feature_enabled.snapshot,211 'Snapshotting is not available.')212 def test_list_images_with_detail_filter_by_server_ref(self):213 # Detailed list of servers should be filtered by server ref214 server_links = self.server2['links']215 # Try all server link types216 for link in server_links:217 params = {'server': link['href']}218 images = self.client.list_images(detail=True, **params)['images']219 self.assertEmpty([i for i in images220 if i['id'] == self.snapshot1_id])221 self.assertEmpty([i for i in images222 if i['id'] == self.snapshot2_id])223 self.assertNotEmpty([i for i in images224 if i['id'] == self.snapshot3_id])225 @decorators.idempotent_id('888c0cc0-7223-43c5-9db0-b125fd0a393b')226 @testtools.skipUnless(CONF.compute_feature_enabled.snapshot,227 'Snapshotting is not available.')228 def test_list_images_with_detail_filter_by_type(self):229 # The detailed list of servers should be filtered by image type230 params = {'type': 'snapshot'}231 images = self.client.list_images(detail=True, **params)['images']232 self.client.show_image(self.image_ref)233 self.assertNotEmpty([i for i in images234 if i['id'] == self.snapshot1_id])235 self.assertNotEmpty([i for i in images236 if i['id'] == self.snapshot2_id])237 self.assertNotEmpty([i for i in images238 if i['id'] == self.snapshot3_id])239 self.assertEmpty([i for i in images if i['id'] == self.image_ref])240 @decorators.idempotent_id('7d439e18-ac2e-4827-b049-7e18004712c4')241 def test_list_images_with_detail_filter_by_changes_since(self):242 # Verify an update image is returned243 # Becoming ACTIVE will modify the updated time244 # Filter by the image's created time245 params = {'changes-since': self.image1['created']}246 images = self.client.list_images(detail=True, **params)['images']...

Full Screen

Full Screen

buildbot_results_unittest.py

Source:buildbot_results_unittest.py Github

copy

Full Screen

...36from webkitpy.layout_tests.views import buildbot_results37class BuildBotPrinterTests(unittest.TestCase):38 def assertEmpty(self, stream):39 self.assertFalse(stream.getvalue())40 def assertNotEmpty(self, stream):41 self.assertTrue(stream.getvalue())42 def get_printer(self):43 stream = StringIO.StringIO()44 printer = buildbot_results.BuildBotPrinter(stream, debug_logging=True)45 return printer, stream46 def test_print_unexpected_results(self):47 port = MockHost().port_factory.get('test')48 printer, out = self.get_printer()49 # test everything running as expected50 DASHED_LINE = "-" * 78 + "\n"51 summary = test_run_results_unittest.summarized_results(port, expected=True, passing=False, flaky=False)52 printer.print_unexpected_results(summary)53 self.assertEqual(out.getvalue(), DASHED_LINE)54 # test failures55 printer, out = self.get_printer()56 summary = test_run_results_unittest.summarized_results(port, expected=False, passing=False, flaky=False)57 printer.print_unexpected_results(summary)58 self.assertNotEmpty(out)59 # test unexpected flaky60 printer, out = self.get_printer()61 summary = test_run_results_unittest.summarized_results(port, expected=False, passing=False, flaky=True)62 printer.print_unexpected_results(summary)63 self.assertNotEmpty(out)64 printer, out = self.get_printer()65 summary = test_run_results_unittest.summarized_results(port, expected=False, passing=False, flaky=False)66 printer.print_unexpected_results(summary)67 self.assertNotEmpty(out)68 printer, out = self.get_printer()69 summary = test_run_results_unittest.summarized_results(port, expected=False, passing=False, flaky=False)70 printer.print_unexpected_results(summary)71 self.assertNotEmpty(out)72 printer, out = self.get_printer()73 summary = test_run_results_unittest.summarized_results(port, expected=False, passing=True, flaky=False)74 printer.print_unexpected_results(summary)75 self.assertNotEmpty(out)76 def test_print_results(self):77 port = MockHost().port_factory.get('test')78 printer, out = self.get_printer()79 initial_results = test_run_results_unittest.run_results(port)80 summary = test_run_results_unittest.summarized_results(port, expected=False, passing=True, flaky=False)81 details = test_run_results.RunDetails(summary['num_regressions'], summary, initial_results, None)82 printer.print_results(details)...

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