Best Python code snippet using tempest_python
test_instance_usage_audit_log.py
Source:test_instance_usage_audit_log.py
...22 def setUpClass(cls):23 super(InstanceUsageAuditLogV3Test, cls).setUpClass()24 cls.adm_client = cls.instance_usages_audit_log_admin_client25 @test.attr(type='gate')26 def test_list_instance_usage_audit_logs(self):27 # list instance usage audit logs28 resp, body = self.adm_client.list_instance_usage_audit_logs()29 self.assertEqual(200, resp.status)30 expected_items = ['total_errors', 'total_instances', 'log',31 'num_hosts_running', 'num_hosts_done',32 'num_hosts', 'hosts_not_run', 'overall_status',33 'period_ending', 'period_beginning',34 'num_hosts_not_run']35 for item in expected_items:36 self.assertIn(item, body)37 @test.attr(type='gate')38 def test_list_instance_usage_audit_logs_with_filter_before(self):39 # Get instance usage audit log before specified time40 ending_time = datetime.datetime(2012, 12, 24)41 resp, body = self.adm_client.list_instance_usage_audit_logs(42 urllib.quote(ending_time.strftime("%Y-%m-%d %H:%M:%S")))43 self.assertEqual(200, resp.status)44 expected_items = ['total_errors', 'total_instances', 'log',45 'num_hosts_running', 'num_hosts_done', 'num_hosts',46 'hosts_not_run', 'overall_status', 'period_ending',47 'period_beginning', 'num_hosts_not_run']48 for item in expected_items:49 self.assertIn(item, body)...
instance_usage_audit_log_client.py
Source:instance_usage_audit_log_client.py
...16from automation.api_schema.response.compute.v2_1 import \17 instance_usage_audit_logs as schema18from automation.common import service_client19class InstanceUsagesAuditLogClient(service_client.ServiceClient):20 def list_instance_usage_audit_logs(self):21 url = 'os-instance_usage_audit_log'22 resp, body = self.get(url)23 body = json.loads(body)24 self.validate_response(schema.list_instance_usage_audit_log,25 resp, body)26 return service_client.ResponseBody(resp,27 body["instance_usage_audit_logs"])28 def show_instance_usage_audit_log(self, time_before):29 url = 'os-instance_usage_audit_log/%s' % time_before30 resp, body = self.get(url)31 body = json.loads(body)32 self.validate_response(schema.get_instance_usage_audit_log, resp, body)33 return service_client.ResponseBody(resp,34 body["instance_usage_audit_log"])
test_instance_usage_audit_log_negative.py
Source:test_instance_usage_audit_log_negative.py
1# Copyright 2013 IBM Corporation2# All Rights Reserved.3#4# Licensed under the Apache License, Version 2.0 (the "License"); you may5# not use this file except in compliance with the License. You may obtain6# a copy of the License at7#8# http://www.apache.org/licenses/LICENSE-2.09#10# Unless required by applicable law or agreed to in writing, software11# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT12# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the13# License for the specific language governing permissions and limitations14# under the License.15from tempest.api.compute import base16from tempest import exceptions17from tempest import test18class InstanceUsageLogNegativeV3Test(base.BaseV3ComputeAdminTest):19 _interface = 'json'20 @classmethod21 def setUpClass(cls):22 super(InstanceUsageLogNegativeV3Test, cls).setUpClass()23 cls.adm_client = cls.instance_usages_audit_log_admin_client24 @test.attr(type=['negative', 'gate'])25 def test_instance_usage_audit_logs_with_nonadmin_user(self):26 # the instance_usage_audit_logs API just can be accessed by admin user27 self.assertRaises(exceptions.Unauthorized,28 self.instance_usages_audit_log_client.29 list_instance_usage_audit_logs)30 @test.attr(type=['negative', 'gate'])31 def test_get_instance_usage_audit_logs_with_invalid_time(self):32 self.assertRaises(exceptions.BadRequest,33 self.adm_client.list_instance_usage_audit_logs,...
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!!