Best Python code snippet using tempest_python
bp_admin_main.py
Source:bp_admin_main.py
...47 except:48 do_log(4, "add_flavor:åæ°ç¼ºå¤±æä¸è§è")49 return json({'state': -1, 'info': 'åæ°ç¼ºå¤±æä¸è§è'})50@bp_admin_main.route("/admin/flavor", methods=['PATCH'])51async def update_flavor(request):52 try:53 get_info = request.raw_args54 id = int(get_info['id'])55 data = request.json56 except:57 do_log(4, "update_flavor:åæ°ç¼ºå¤±æä¸è§è")58 return json({'state': -1, 'info': 'åæ°ç¼ºå¤±æä¸è§è'})59 time = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")60 try:61 if await db_update("flavor",set={ "updated_at":time, "name":data['name'], "author":int(data['author']), "ram":int(data['ram']), "cpu":int(data['cpu'])}, id=id):62 do_log(2, "update_flavor:é
置修æ¹æåï¼[id=%d]" % (id,))63 return json({'state': 0, 'info': 'æå'})64 else:65 do_log(4, "update_flavor:æ°æ®åºæä½å¤±è´¥[id=%d]" % (id,))...
test_flavors_rbac.py
Source:test_flavors_rbac.py
...42 @rbac_rule_validation.action(service="neutron",43 rules=["get_flavor",44 "update_flavor"],45 expected_error_codes=[404, 403])46 def test_update_flavor(self):47 """Update flavor.48 RBAC test for the neutron "update_flavor" policy49 """50 flavor = self.ntp_client.create_flavor(service_type=self.service_type)51 self.addCleanup(52 test_utils.call_and_ignore_notfound_exc,53 self.ntp_client.delete_flavor, flavor["flavor"]["id"])54 name = data_utils.rand_name(self.__class__.__name__ + '-Flavor')55 with self.override_role():56 self.ntp_client.update_flavor(flavor["flavor"]["id"], name=name)57 @decorators.idempotent_id('1de15f9e-5080-4259-ab41-e230bb312de8')58 @rbac_rule_validation.action(service="neutron",59 rules=["get_flavor",60 "delete_flavor"],61 expected_error_codes=[404, 403])62 def test_delete_flavor(self):63 """Delete flavor.64 RBAC test for the neutron "delete_flavor" policy65 """66 flavor = self.ntp_client.create_flavor(service_type=self.service_type)67 self.addCleanup(68 test_utils.call_and_ignore_notfound_exc,69 self.ntp_client.delete_flavor, flavor["flavor"]["id"])70 with self.override_role():...
TestUserProfile.py
Source:TestUserProfile.py
...20 assert server.delete_user(user["userid"])21 def testUpdateUser(self):22 server = UserProfileDBHelper('uProfile_test')23 for user in update_users:24 assert server.update_flavor(user['userid'], user['salt'], user['sour'], user['sweet'], user['spicy'])25 user_data = server.get_user(user["userid"])26 assert user_data['userid'] == user['userid'] and user_data['spicy'] == user['spicy'] and \27 user_data['sour'] == user['sour'] and user_data['sweet'] == user['sweet'] and \28 user_data['salt'] == user['salt']29 for user in users:30 assert server.update_flavor(user['userid'], user['salt'], user['sour'], user['sweet'], user['spicy'])31if __name__ == '__main__':32 unittest.main()33# server = UserProfileDBHelper("uProfile_test")34# for user in users:...
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!!