Best Python code snippet using tempest_python
qos.py
Source:qos.py
...358 self.client().delete_minimum_packet_rate_rule(359 self.resource_id, self.policy_id)360 def handle_update(self, json_snippet, tmpl_diff, prop_diff):361 if prop_diff:362 self.client().update_minimum_packet_rate_rule(363 self.resource_id,364 self.policy_id,365 {'minimum_packet_rate_rule': prop_diff})366 def _res_get_args(self):367 return [self.resource_id, self.policy_id]368def resource_mapping():369 return {370 'OS::Neutron::QoSPolicy': QoSPolicy,371 'OS::Neutron::QoSBandwidthLimitRule': QoSBandwidthLimitRule,372 'OS::Neutron::QoSDscpMarkingRule': QoSDscpMarkingRule,373 'OS::Neutron::QoSMinimumBandwidthRule': QoSMinimumBandwidthRule,374 'OS::Neutron::QoSMinimumPacketRateRule': QoSMinimumPacketRateRule,...
test_qos_minimum_packet_rate_rules_client.py
Source:test_qos_minimum_packet_rate_rules_client.py
1# Licensed under the Apache License, Version 2.0 (the "License"); you may2# not use this file except in compliance with the License. You may obtain3# a copy of the License at4#5# http://www.apache.org/licenses/LICENSE-2.06#7# Unless required by applicable law or agreed to in writing, software8# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT9# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the10# License for the specific language governing permissions and limitations11# under the License.12import copy13from tempest.lib.services.network import qos_minimum_packet_rate_rules_client14from tempest.tests.lib import fake_auth_provider15from tempest.tests.lib.services import base16class TestQosMinimumPacketRateRulesClient(base.BaseServiceTest):17 FAKE_QOS_POLICY_ID = "f1011b08-1297-11e9-a1e7-c7e6825a2616"18 FAKE_MIN_PPS_RULE_ID = "e758c89e-1297-11e9-a6cf-cf46a71e6699"19 FAKE_MIN_PPS_RULE_REQUEST = {20 'qos_policy_id': FAKE_QOS_POLICY_ID,21 'min_kpps': 1000,22 'direction': 'ingress'23 }24 FAKE_MIN_PPS_RULE_RESPONSE = {25 'minimum_packet_rate_rule': {26 'id': FAKE_MIN_PPS_RULE_ID,27 'min_kpps': 1000,28 'direction': 'ingress'29 }30 }31 FAKE_MIN_PPS_RULES = {32 'minimum_packet_rate_rules': [33 FAKE_MIN_PPS_RULE_RESPONSE['minimum_packet_rate_rule']34 ]35 }36 def setUp(self):37 super(TestQosMinimumPacketRateRulesClient, self).setUp()38 fake_auth = fake_auth_provider.FakeAuthProvider()39 self.qos_min_pps_client = qos_minimum_packet_rate_rules_client.\40 QosMinimumPacketRateRulesClient(fake_auth, "network", "regionOne")41 def _test_create_minimum_packet_rate_rule(self, bytes_body=False):42 self.check_service_client_function(43 self.qos_min_pps_client.create_minimum_packet_rate_rule,44 "tempest.lib.common.rest_client.RestClient.post",45 self.FAKE_MIN_PPS_RULE_RESPONSE,46 bytes_body,47 201,48 **self.FAKE_MIN_PPS_RULE_REQUEST49 )50 def _test_list_minimum_packet_rate_rules(self, bytes_body=False):51 self.check_service_client_function(52 self.qos_min_pps_client.list_minimum_packet_rate_rules,53 "tempest.lib.common.rest_client.RestClient.get",54 self.FAKE_MIN_PPS_RULES,55 bytes_body,56 200,57 qos_policy_id=self.FAKE_QOS_POLICY_ID58 )59 def _test_show_minimum_packet_rate_rule(self, bytes_body=False):60 self.check_service_client_function(61 self.qos_min_pps_client.show_minimum_packet_rate_rule,62 "tempest.lib.common.rest_client.RestClient.get",63 self.FAKE_MIN_PPS_RULE_RESPONSE,64 bytes_body,65 200,66 qos_policy_id=self.FAKE_QOS_POLICY_ID,67 rule_id=self.FAKE_MIN_PPS_RULE_ID68 )69 def _test_update_qos_polcy(self, bytes_body=False):70 update_kwargs = {71 "min_kpps": "20000"72 }73 resp_body = {74 "minimum_packet_rate_rule": copy.deepcopy(75 self.FAKE_MIN_PPS_RULE_RESPONSE['minimum_packet_rate_rule']76 )77 }78 resp_body["minimum_packet_rate_rule"].update(update_kwargs)79 self.check_service_client_function(80 self.qos_min_pps_client.update_minimum_packet_rate_rule,81 "tempest.lib.common.rest_client.RestClient.put",82 resp_body,83 bytes_body,84 200,85 qos_policy_id=self.FAKE_QOS_POLICY_ID,86 rule_id=self.FAKE_MIN_PPS_RULE_ID,87 **update_kwargs)88 def test_create_minimum_packet_rate_rule_with_str_body(self):89 self._test_create_minimum_packet_rate_rule()90 def test_create_minimum_packet_rate_rule_with_bytes_body(self):91 self._test_create_minimum_packet_rate_rule(bytes_body=True)92 def test_update_minimum_packet_rate_rule_with_str_body(self):93 self._test_update_qos_polcy()94 def test_update_minimum_packet_rate_rule_with_bytes_body(self):95 self._test_update_qos_polcy(bytes_body=True)96 def test_show_minimum_packet_rate_rule_with_str_body(self):97 self._test_show_minimum_packet_rate_rule()98 def test_show_minimum_packet_rate_rule_with_bytes_body(self):99 self._test_show_minimum_packet_rate_rule(bytes_body=True)100 def test_delete_minimum_packet_rate_rule(self):101 self.check_service_client_function(102 self.qos_min_pps_client.delete_minimum_packet_rate_rule,103 "tempest.lib.common.rest_client.RestClient.delete",104 {},105 status=204,106 qos_policy_id=self.FAKE_QOS_POLICY_ID,107 rule_id=self.FAKE_MIN_PPS_RULE_ID)108 def test_list_minimum_packet_rate_rule_with_str_body(self):109 self._test_list_minimum_packet_rate_rules()110 def test_list_minimum_packet_rate_rule_with_bytes_body(self):...
qos_minimum_packet_rate_rules_client.py
Source:qos_minimum_packet_rate_rules_client.py
...19 """20 uri = '/qos/policies/%s/minimum_packet_rate_rules' % qos_policy_id21 post_data = {'minimum_packet_rate_rule': kwargs}22 return self.create_resource(uri, post_data)23 def update_minimum_packet_rate_rule(24 self, qos_policy_id, rule_id, **kwargs25 ):26 """Updates a minimum packet rate rule.27 For full list of available parameters, please refer to the official28 API reference:29 https://docs.openstack.org/api-ref/network/v2/index.html#update-minimum-packet-rate-rule30 """31 uri = '/qos/policies/%s/minimum_packet_rate_rules/%s' % (32 qos_policy_id, rule_id)33 post_data = {'minimum_packet_rate_rule': kwargs}34 return self.update_resource(uri, post_data)35 def show_minimum_packet_rate_rule(self, qos_policy_id, rule_id, **fields):36 """Show details of a minimum packet rate rule.37 For full list of available parameters, please refer to the official...
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!!