How to use _check_expected_response method in tempest

Best Python code snippet using tempest_python

test_security_group_rules.py

Source:test_security_group_rules.py Github

copy

Full Screen

...42 'to_port': to_port,43 'ip_range': ip_range,44 'group': group45 }46 def _check_expected_response(self, actual_rule):47 for key in self.expected:48 if key == 'id':49 continue50 self.assertEqual(self.expected[key], actual_rule[key],51 "Miss-matched key is %s" % key)52 @test.attr(type='smoke')53 @test.idempotent_id('850795d7-d4d3-4e55-b527-a774c0123d3a')54 @test.services('network')55 def test_security_group_rules_create(self):56 # Positive test: Creation of Security Group rule57 # should be successful58 # Creating a Security Group to add rules to it59 security_group = self.create_security_group()60 securitygroup_id = security_group['id']61 # Adding rules to the created Security Group62 rule = \63 self.client.create_security_group_rule(securitygroup_id,64 self.ip_protocol,65 self.from_port,66 self.to_port)67 self.expected['parent_group_id'] = securitygroup_id68 self.expected['ip_range'] = {'cidr': '0.0.0.0/0'}69 self._check_expected_response(rule)70 @test.idempotent_id('7a01873e-3c38-4f30-80be-31a043cfe2fd')71 @test.services('network')72 def test_security_group_rules_create_with_optional_cidr(self):73 # Positive test: Creation of Security Group rule74 # with optional argument cidr75 # should be successful76 # Creating a Security Group to add rules to it77 security_group = self.create_security_group()78 parent_group_id = security_group['id']79 # Adding rules to the created Security Group with optional cidr80 cidr = '10.2.3.124/24'81 rule = \82 self.client.create_security_group_rule(parent_group_id,83 self.ip_protocol,84 self.from_port,85 self.to_port,86 cidr=cidr)87 self.expected['parent_group_id'] = parent_group_id88 self.expected['ip_range'] = {'cidr': cidr}89 self._check_expected_response(rule)90 @test.idempotent_id('7f5d2899-7705-4d4b-8458-4505188ffab6')91 @test.services('network')92 def test_security_group_rules_create_with_optional_group_id(self):93 # Positive test: Creation of Security Group rule94 # with optional argument group_id95 # should be successful96 # Creating a Security Group to add rules to it97 security_group = self.create_security_group()98 parent_group_id = security_group['id']99 # Creating a Security Group so as to assign group_id to the rule100 security_group = self.create_security_group()101 group_id = security_group['id']102 group_name = security_group['name']103 # Adding rules to the created Security Group with optional group_id104 rule = \105 self.client.create_security_group_rule(parent_group_id,106 self.ip_protocol,107 self.from_port,108 self.to_port,109 group_id=group_id)110 self.expected['parent_group_id'] = parent_group_id111 self.expected['group'] = {'tenant_id': self.client.tenant_id,112 'name': group_name}113 self._check_expected_response(rule)114 @test.attr(type='smoke')115 @test.idempotent_id('a6154130-5a55-4850-8be4-5e9e796dbf17')116 @test.services('network')117 def test_security_group_rules_list(self):118 # Positive test: Created Security Group rules should be119 # in the list of all rules120 # Creating a Security Group to add rules to it121 security_group = self.create_security_group()122 securitygroup_id = security_group['id']123 # Add a first rule to the created Security Group124 rule = \125 self.client.create_security_group_rule(securitygroup_id,126 self.ip_protocol,127 self.from_port,...

Full Screen

Full Screen

Automation Testing Tutorials

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.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run tempest automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful