Best Python code snippet using tempest_python
test_range_search.py
Source: test_range_search.py
...21 if flavor['name'].startswith("m1."):22 new_results.append(flavor)23 return new_results24 def test_range_search_bad_range(self):25 flavors = self.user_cloud.list_flavors(get_extra=False)26 self.assertRaises(27 exc.OpenStackCloudException,28 self.user_cloud.range_search, flavors, {"ram": "<1a0"})29 def test_range_search_exact(self):30 flavors = self.user_cloud.list_flavors(get_extra=False)31 result = self.user_cloud.range_search(flavors, {"ram": "4096"})32 self.assertIsInstance(result, list)33 # should only be 1 m1 flavor with 4096 ram34 result = self._filter_m1_flavors(result)35 self.assertEqual(1, len(result))36 self.assertEqual("m1.medium", result[0]['name'])37 def test_range_search_min(self):38 flavors = self.user_cloud.list_flavors(get_extra=False)39 result = self.user_cloud.range_search(flavors, {"ram": "MIN"})40 self.assertIsInstance(result, list)41 self.assertEqual(1, len(result))42 # older devstack does not have cirros25643 self.assertIn(result[0]['name'], ('cirros256', 'm1.tiny'))44 def test_range_search_max(self):45 flavors = self.user_cloud.list_flavors(get_extra=False)46 result = self.user_cloud.range_search(flavors, {"ram": "MAX"})47 self.assertIsInstance(result, list)48 self.assertEqual(1, len(result))49 self.assertEqual("m1.xlarge", result[0]['name'])50 def test_range_search_lt(self):51 flavors = self.user_cloud.list_flavors(get_extra=False)52 result = self.user_cloud.range_search(flavors, {"ram": "<1024"})53 self.assertIsInstance(result, list)54 # should only be 1 m1 flavor with <1024 ram55 result = self._filter_m1_flavors(result)56 self.assertEqual(1, len(result))57 self.assertEqual("m1.tiny", result[0]['name'])58 def test_range_search_gt(self):59 flavors = self.user_cloud.list_flavors(get_extra=False)60 result = self.user_cloud.range_search(flavors, {"ram": ">4096"})61 self.assertIsInstance(result, list)62 # should only be 2 m1 flavors with >4096 ram63 result = self._filter_m1_flavors(result)64 self.assertEqual(2, len(result))65 flavor_names = [r['name'] for r in result]66 self.assertIn("m1.large", flavor_names)67 self.assertIn("m1.xlarge", flavor_names)68 def test_range_search_le(self):69 flavors = self.user_cloud.list_flavors(get_extra=False)70 result = self.user_cloud.range_search(flavors, {"ram": "<=4096"})71 self.assertIsInstance(result, list)72 # should only be 3 m1 flavors with <=4096 ram73 result = self._filter_m1_flavors(result)74 self.assertEqual(3, len(result))75 flavor_names = [r['name'] for r in result]76 self.assertIn("m1.tiny", flavor_names)77 self.assertIn("m1.small", flavor_names)78 self.assertIn("m1.medium", flavor_names)79 def test_range_search_ge(self):80 flavors = self.user_cloud.list_flavors(get_extra=False)81 result = self.user_cloud.range_search(flavors, {"ram": ">=4096"})82 self.assertIsInstance(result, list)83 # should only be 3 m1 flavors with >=4096 ram84 result = self._filter_m1_flavors(result)85 self.assertEqual(3, len(result))86 flavor_names = [r['name'] for r in result]87 self.assertIn("m1.medium", flavor_names)88 self.assertIn("m1.large", flavor_names)89 self.assertIn("m1.xlarge", flavor_names)90 def test_range_search_multi_1(self):91 flavors = self.user_cloud.list_flavors(get_extra=False)92 result = self.user_cloud.range_search(93 flavors, {"ram": "MIN", "vcpus": "MIN"})94 self.assertIsInstance(result, list)95 self.assertEqual(1, len(result))96 # older devstack does not have cirros25697 self.assertIn(result[0]['name'], ('cirros256', 'm1.tiny'))98 def test_range_search_multi_2(self):99 flavors = self.user_cloud.list_flavors(get_extra=False)100 result = self.user_cloud.range_search(101 flavors, {"ram": "<1024", "vcpus": "MIN"})102 self.assertIsInstance(result, list)103 result = self._filter_m1_flavors(result)104 self.assertEqual(1, len(result))105 flavor_names = [r['name'] for r in result]106 self.assertIn("m1.tiny", flavor_names)107 def test_range_search_multi_3(self):108 flavors = self.user_cloud.list_flavors(get_extra=False)109 result = self.user_cloud.range_search(110 flavors, {"ram": ">=4096", "vcpus": "<6"})111 self.assertIsInstance(result, list)112 result = self._filter_m1_flavors(result)113 self.assertEqual(2, len(result))114 flavor_names = [r['name'] for r in result]115 self.assertIn("m1.medium", flavor_names)116 self.assertIn("m1.large", flavor_names)117 def test_range_search_multi_4(self):118 flavors = self.user_cloud.list_flavors(get_extra=False)119 result = self.user_cloud.range_search(120 flavors, {"ram": ">=4096", "vcpus": "MAX"})121 self.assertIsInstance(result, list)122 self.assertEqual(1, len(result))123 # This is the only result that should have max vcpu...
test_flavors.py
Source: test_flavors.py
...22 super(FlavorsV2TestJSON, cls).setup_clients()23 cls.client = cls.flavors_client24 @test.attr(type='smoke')25 @test.idempotent_id('e36c0eaa-dff5-4082-ad1f-3f9a80aa3f59')26 def test_list_flavors(self):27 # List of all flavors should contain the expected flavor28 flavors = self.client.list_flavors()['flavors']29 flavor = self.client.show_flavor(self.flavor_ref)['flavor']30 flavor_min_detail = {'id': flavor['id'], 'links': flavor['links'],31 'name': flavor['name']}32 self.assertIn(flavor_min_detail, flavors)33 @test.idempotent_id('6e85fde4-b3cd-4137-ab72-ed5f418e8c24')34 def test_list_flavors_with_detail(self):35 # Detailed list of all flavors should contain the expected flavor36 flavors = self.client.list_flavors(detail=True)['flavors']37 flavor = self.client.show_flavor(self.flavor_ref)['flavor']38 self.assertIn(flavor, flavors)39 @test.attr(type='smoke')40 @test.idempotent_id('1f12046b-753d-40d2-abb6-d8eb8b30cb2f')41 def test_get_flavor(self):42 # The expected flavor details should be returned43 flavor = self.client.show_flavor(self.flavor_ref)['flavor']44 self.assertEqual(self.flavor_ref, flavor['id'])45 @test.idempotent_id('8d7691b3-6ed4-411a-abc9-2839a765adab')46 def test_list_flavors_limit_results(self):47 # Only the expected number of flavors should be returned48 params = {'limit': 1}49 flavors = self.client.list_flavors(**params)['flavors']50 self.assertEqual(1, len(flavors))51 @test.idempotent_id('b26f6327-2886-467a-82be-cef7a27709cb')52 def test_list_flavors_detailed_limit_results(self):53 # Only the expected number of flavors (detailed) should be returned54 params = {'limit': 1}55 flavors = self.client.list_flavors(detail=True, **params)['flavors']56 self.assertEqual(1, len(flavors))57 @test.idempotent_id('e800f879-9828-4bd0-8eae-4f17189951fb')58 def test_list_flavors_using_marker(self):59 # The list of flavors should start from the provided marker60 flavor = self.client.show_flavor(self.flavor_ref)['flavor']61 flavor_id = flavor['id']62 params = {'marker': flavor_id}63 flavors = self.client.list_flavors(**params)['flavors']64 self.assertFalse(any([i for i in flavors if i['id'] == flavor_id]),65 'The list of flavors did not start after the marker.')66 @test.idempotent_id('6db2f0c0-ddee-4162-9c84-0703d3dd1107')67 def test_list_flavors_detailed_using_marker(self):68 # The list of flavors should start from the provided marker69 flavor = self.client.show_flavor(self.flavor_ref)['flavor']70 flavor_id = flavor['id']71 params = {'marker': flavor_id}72 flavors = self.client.list_flavors(detail=True, **params)['flavors']73 self.assertFalse(any([i for i in flavors if i['id'] == flavor_id]),74 'The list of flavors did not start after the marker.')75 @test.idempotent_id('3df2743e-3034-4e57-a4cb-b6527f6eac79')76 def test_list_flavors_detailed_filter_by_min_disk(self):77 # The detailed list of flavors should be filtered by disk space78 flavor = self.client.show_flavor(self.flavor_ref)['flavor']79 flavor_id = flavor['id']80 params = {self._min_disk: flavor['disk'] + 1}81 flavors = self.client.list_flavors(detail=True, **params)['flavors']82 self.assertFalse(any([i for i in flavors if i['id'] == flavor_id]))83 @test.idempotent_id('09fe7509-b4ee-4b34-bf8b-39532dc47292')84 def test_list_flavors_detailed_filter_by_min_ram(self):85 # The detailed list of flavors should be filtered by RAM86 flavor = self.client.show_flavor(self.flavor_ref)['flavor']87 flavor_id = flavor['id']88 params = {self._min_ram: flavor['ram'] + 1}89 flavors = self.client.list_flavors(detail=True, **params)['flavors']90 self.assertFalse(any([i for i in flavors if i['id'] == flavor_id]))91 @test.idempotent_id('10645a4d-96f5-443f-831b-730711e11dd4')92 def test_list_flavors_filter_by_min_disk(self):93 # The list of flavors should be filtered by disk space94 flavor = self.client.show_flavor(self.flavor_ref)['flavor']95 flavor_id = flavor['id']96 params = {self._min_disk: flavor['disk'] + 1}97 flavors = self.client.list_flavors(**params)['flavors']98 self.assertFalse(any([i for i in flavors if i['id'] == flavor_id]))99 @test.idempotent_id('935cf550-e7c8-4da6-8002-00f92d5edfaa')100 def test_list_flavors_filter_by_min_ram(self):101 # The list of flavors should be filtered by RAM102 flavor = self.client.show_flavor(self.flavor_ref)['flavor']103 flavor_id = flavor['id']104 params = {self._min_ram: flavor['ram'] + 1}105 flavors = self.client.list_flavors(**params)['flavors']...
flavors.py
Source: flavors.py
...45 d['SNF:flavor-access'] = [a.project for a in flavor.access.all()46 if a.project in projects]47 return d48@api.api_method(http_method='GET', user_required=True, logger=log)49def list_flavors(request, detail=False):50 # Normal Response Codes: 200, 20351 # Error Response Codes: computeFault (400, 500),52 # serviceUnavailable (503),53 # unauthorized (401),54 # badRequest (400),55 # overLimit (413)56 log.debug('list_flavors detail=%s', detail)57 # We remove the is_public filter as it can "confuse" OpenStack clients58 # expecting all the flavors the user has access to, when the query has the59 # is_public=true option. Removing it should not require any changes on the60 # Cyclades UI, but we should revert the relevant changes made in kamaki.61 # We substitute is_public with the Cyclades-specific SNF:is_public.62 public = request.GET.get('SNF:is_public')63 project = request.GET.get('SNF:flavor-access')...
Check out the latest blogs from LambdaTest on this topic:
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?
In my last blog, I investigated both the stateless and the stateful class of model-based testing. Both have some advantages and disadvantages. You can use them for different types of systems, depending on whether a stateful solution is required or a stateless one is enough. However, a better solution is to use an aggregate technique that is appropriate for each system. Currently, the only aggregate solution is action-state testing, introduced in the book Paradigm Shift in Software Testing. This method is implemented in Harmony.
There is just one area where each member of the software testing community has a distinct point of view! Metrics! This contentious issue sparks intense disputes, and most conversations finish with no definitive conclusion. It covers a wide range of topics: How can testing efforts be measured? What is the most effective technique to assess effectiveness? Which of the many components should be quantified? How can we measure the quality of our testing performance, among other things?
Coaching is a term that is now being mentioned a lot more in the leadership space. Having grown successful teams I thought that I was well acquainted with this subject.
When software developers took years to create and introduce new products to the market is long gone. Users (or consumers) today are more eager to use their favorite applications with the latest bells and whistles. However, users today don’t have the patience to work around bugs, errors, and design flaws. People have less self-control, and if your product or application doesn’t make life easier for users, they’ll leave for a better solution.
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!