Best Python code snippet using tempest_python
aggregate_operations.py
Source:aggregate_operations.py
...66def patch_aggregate() -> None:67 """ Create aggregate"""68 print("----------Create Aggregate-----------")69 print()70 show_aggregate()71 aggr_name = input("Enter the name of the Aggregate Name to be Updated :- ")72 aggr_new_name = input(73 "Enter the new name of the aggregate to be updated :- ")74 try:75 aggr = Aggregate.find(name=aggr_name)76 aggr.name = aggr_new_name77 aggr.patch(poll=True)78 except NetAppRestError as error:79 print("Exception caught :" + str(error))80def delete_aggregate() -> None:81 """ Delete aggregate"""82 print("----------Delete Aggregate-----------")83 print()84 show_aggregate()85 aggr_name = input("Enter the name of the Aggregate Name to be Deleted:- ")86 print()87 try:88 aggr = Aggregate.find(name=aggr_name)89 aggr.delete(poll=True)90 except NetAppRestError as error:91 print("Exception caught :" + str(error))92def aggr_ops() -> None:93 """Aggregate Operations"""94 print()95 print("THE FOLLOWING SCRIPT SHOWS AGGREGATE OPERATIONS USING REST API PYTHON CLIENT LIBRARY:- ")96 print("=======================================================================================")97 print()98 aggrbool = input(...
aggregates_client.py
Source:aggregates_client.py
...22 resp, body = self.get("os-aggregates")23 body = json.loads(body)24 self.validate_response(schema.list_aggregates, resp, body)25 return service_client.ResponseBodyList(resp, body['aggregates'])26 def show_aggregate(self, aggregate_id):27 """Get details of the given aggregate."""28 resp, body = self.get("os-aggregates/%s" % aggregate_id)29 body = json.loads(body)30 self.validate_response(schema.get_aggregate, resp, body)31 return service_client.ResponseBody(resp, body['aggregate'])32 def create_aggregate(self, **kwargs):33 """Creates a new aggregate."""34 post_body = json.dumps({'aggregate': kwargs})35 resp, body = self.post('os-aggregates', post_body)36 body = json.loads(body)37 self.validate_response(schema.create_aggregate, resp, body)38 return service_client.ResponseBody(resp, body['aggregate'])39 def update_aggregate(self, aggregate_id, **kwargs):40 """Update a aggregate."""41 put_body = json.dumps({'aggregate': kwargs})42 resp, body = self.put('os-aggregates/%s' % aggregate_id, put_body)43 body = json.loads(body)44 self.validate_response(schema.update_aggregate, resp, body)45 return service_client.ResponseBody(resp, body['aggregate'])46 def delete_aggregate(self, aggregate_id):47 """Deletes the given aggregate."""48 resp, body = self.delete("os-aggregates/%s" % aggregate_id)49 self.validate_response(schema.delete_aggregate, resp, body)50 return service_client.ResponseBody(resp, body)51 def is_resource_deleted(self, id):52 try:53 self.show_aggregate(id)54 except exceptions.NotFound:55 return True56 return False57 @property58 def resource_type(self):59 """Returns the primary type of resource this client works with."""60 return 'aggregate'61 def add_host(self, aggregate_id, **kwargs):62 """Adds a host to the given aggregate."""63 post_body = json.dumps({'add_host': kwargs})64 resp, body = self.post('os-aggregates/%s/action' % aggregate_id,65 post_body)66 body = json.loads(body)67 self.validate_response(schema.aggregate_add_remove_host, resp, body)...
test_aggregates.py
Source:test_aggregates.py
...42 self.aggregate = self.baremetal_compute_client.delete_aggregate(43 aggregate['uuid'])44 @decorators.idempotent_id('c7062d65-09f7-4efa-8852-3ac543416c31')45 def test_aggregate_show(self):46 aggregate = self.baremetal_compute_client.show_aggregate(47 self.aggregate['uuid'])48 self.assertEqual("tempest-test-aggregate", aggregate['name'])49 self.assertItemsEqual({'k1': 'v1'}, aggregate['metadata'])50 @decorators.idempotent_id('a0520c12-4e7d-46ac-a0bc-c4c42fe3a344')51 def test_aggregates_list(self):52 aggregates = self.baremetal_compute_client.list_aggregates()53 self.assertEqual(1, len(aggregates))54 aggregate = aggregates[0]55 self.assertEqual("tempest-test-aggregate", aggregate['name'])56 self.assertItemsEqual({'k1': 'v1'}, aggregate['metadata'])57 @decorators.idempotent_id('65614c7e-a1d9-4d1b-aa9a-6893616c0cc1')58 def test_aggregate_delete(self):59 aggregate_body = {60 "name": "test-aggregate1",...
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!!