How to use rand_mac_address method in tempest

Best Python code snippet using tempest_python

test_ports_negative.py

Source:test_ports_negative.py Github

copy

Full Screen

...29 @test.attr(type=['negative'])30 @test.idempotent_id('30277ee8-0c60-4f1d-b125-0e51c2f43369')31 def test_create_port_nonexsistent_node_id(self):32 node_id = str(data_utils.rand_uuid())33 address = data_utils.rand_mac_address()34 self.assertRaises(lib_exc.BadRequest, self.create_port,35 node_id=node_id, address=address)36 @test.attr(type=['negative'])37 @test.idempotent_id('029190f6-43e1-40a3-b64a-65173ba653a3')38 def test_show_port_malformed_uuid(self):39 self.assertRaises(lib_exc.BadRequest, self.client.show_port,40 'malformed:uuid')41 @test.attr(type=['negative'])42 @test.idempotent_id('0d00e13d-e2e0-45b1-bcbc-55a6d90ca793')43 def test_show_port_nonexistent_uuid(self):44 self.assertRaises(lib_exc.NotFound, self.client.show_port,45 data_utils.rand_uuid())46 @test.attr(type=['negative'])47 @test.idempotent_id('4ad85266-31e9-4942-99ac-751897dc9e23')48 def test_show_port_by_mac_not_allowed(self):49 self.assertRaises(lib_exc.BadRequest, self.client.show_port,50 data_utils.rand_mac_address())51 @test.attr(type=['negative'])52 @test.idempotent_id('89a34380-3c61-4c32-955c-2cd9ce94da21')53 def test_create_port_duplicated_port_uuid(self):54 node_id = self.node['uuid']55 address = data_utils.rand_mac_address()56 uuid = data_utils.rand_uuid()57 self.create_port(node_id=node_id, address=address, uuid=uuid)58 self.assertRaises(lib_exc.Conflict, self.create_port, node_id=node_id,59 address=address, uuid=uuid)60 @test.attr(type=['negative'])61 @test.idempotent_id('65e84917-733c-40ae-ae4b-96a4adff931c')62 def test_create_port_no_mandatory_field_node_id(self):63 address = data_utils.rand_mac_address()64 self.assertRaises(lib_exc.BadRequest, self.create_port, node_id=None,65 address=address)66 @test.attr(type=['negative'])67 @test.idempotent_id('bcea3476-7033-4183-acfe-e56a30809b46')68 def test_create_port_no_mandatory_field_mac(self):69 node_id = self.node['uuid']70 self.assertRaises(lib_exc.BadRequest, self.create_port,71 node_id=node_id, address=None)72 @test.attr(type=['negative'])73 @test.idempotent_id('2b51cd18-fb95-458b-9780-e6257787b649')74 def test_create_port_malformed_port_uuid(self):75 node_id = self.node['uuid']76 address = data_utils.rand_mac_address()77 uuid = 'malformed:uuid'78 self.assertRaises(lib_exc.BadRequest, self.create_port,79 node_id=node_id, address=address, uuid=uuid)80 @test.attr(type=['negative'])81 @test.idempotent_id('583a6856-6a30-4ac4-889f-14e2adff8105')82 def test_create_port_malformed_node_id(self):83 address = data_utils.rand_mac_address()84 self.assertRaises(lib_exc.BadRequest, self.create_port,85 node_id='malformed:nodeid', address=address)86 @test.attr(type=['negative'])87 @test.idempotent_id('e27f8b2e-42c6-4a43-a3cd-accff716bc5c')88 def test_create_port_duplicated_mac(self):89 node_id = self.node['uuid']90 address = data_utils.rand_mac_address()91 self.create_port(node_id=node_id, address=address)92 self.assertRaises(lib_exc.Conflict,93 self.create_port, node_id=node_id,94 address=address)95 @test.attr(type=['negative'])96 @test.idempotent_id('8907082d-ac5e-4be3-b05f-d072ede82020')97 def test_update_port_by_mac_not_allowed(self):98 node_id = self.node['uuid']99 address = data_utils.rand_mac_address()100 extra = {'key': 'value'}101 self.create_port(node_id=node_id, address=address, extra=extra)102 patch = [{'path': '/extra/key',103 'op': 'replace',104 'value': 'new-value'}]105 self.assertRaises(lib_exc.BadRequest,106 self.client.update_port, address,107 patch)108 @test.attr(type=['negative'])109 @test.idempotent_id('df1ac70c-db9f-41d9-90f1-78cd6b905718')110 def test_update_port_nonexistent(self):111 node_id = self.node['uuid']112 address = data_utils.rand_mac_address()113 extra = {'key': 'value'}114 _, port = self.create_port(node_id=node_id, address=address,115 extra=extra)116 port_id = port['uuid']117 _, body = self.client.delete_port(port_id)118 patch = [{'path': '/extra/key',119 'op': 'replace',120 'value': 'new-value'}]121 self.assertRaises(lib_exc.NotFound,122 self.client.update_port, port_id, patch)123 @test.attr(type=['negative'])124 @test.idempotent_id('c701e315-aa52-41ea-817c-65c5ca8ca2a8')125 def test_update_port_malformed_port_uuid(self):126 node_id = self.node['uuid']127 address = data_utils.rand_mac_address()128 self.create_port(node_id=node_id, address=address)129 new_address = data_utils.rand_mac_address()130 self.assertRaises(lib_exc.BadRequest, self.client.update_port,131 uuid='malformed:uuid',132 patch=[{'path': '/address', 'op': 'replace',133 'value': new_address}])134 @test.attr(type=['negative'])135 @test.idempotent_id('f8f15803-34d6-45dc-b06f-e5e04bf1b38b')136 def test_update_port_add_nonexistent_property(self):137 node_id = self.node['uuid']138 address = data_utils.rand_mac_address()139 _, port = self.create_port(node_id=node_id, address=address)140 port_id = port['uuid']141 self.assertRaises(lib_exc.BadRequest, self.client.update_port, port_id,142 [{'path': '/nonexistent', ' op': 'add',143 'value': 'value'}])144 @test.attr(type=['negative'])145 @test.idempotent_id('898ec904-38b1-4fcb-9584-1187d4263a2a')146 def test_update_port_replace_node_id_with_malformed(self):147 node_id = self.node['uuid']148 address = data_utils.rand_mac_address()149 _, port = self.create_port(node_id=node_id, address=address)150 port_id = port['uuid']151 patch = [{'path': '/node_uuid',152 'op': 'replace',153 'value': 'malformed:node_uuid'}]154 self.assertRaises(lib_exc.BadRequest,155 self.client.update_port, port_id, patch)156 @test.attr(type=['negative'])157 @test.idempotent_id('2949f30f-5f59-43fa-a6d9-4eac578afab4')158 def test_update_port_replace_mac_with_duplicated(self):159 node_id = self.node['uuid']160 address1 = data_utils.rand_mac_address()161 address2 = data_utils.rand_mac_address()162 _, port1 = self.create_port(node_id=node_id, address=address1)163 _, port2 = self.create_port(node_id=node_id, address=address2)164 port_id = port2['uuid']165 patch = [{'path': '/address',166 'op': 'replace',167 'value': address1}]168 self.assertRaises(lib_exc.Conflict,169 self.client.update_port, port_id, patch)170 @test.attr(type=['negative'])171 @test.idempotent_id('97f6e048-6e4f-4eba-a09d-fbbc78b77a77')172 def test_update_port_replace_node_id_with_nonexistent(self):173 node_id = self.node['uuid']174 address = data_utils.rand_mac_address()175 _, port = self.create_port(node_id=node_id, address=address)176 port_id = port['uuid']177 patch = [{'path': '/node_uuid',178 'op': 'replace',179 'value': data_utils.rand_uuid()}]180 self.assertRaises(lib_exc.BadRequest,181 self.client.update_port, port_id, patch)182 @test.attr(type=['negative'])183 @test.idempotent_id('375022c5-9e9e-4b11-9ca4-656729c0c9b2')184 def test_update_port_replace_mac_with_malformed(self):185 node_id = self.node['uuid']186 address = data_utils.rand_mac_address()187 _, port = self.create_port(node_id=node_id, address=address)188 port_id = port['uuid']189 patch = [{'path': '/address',190 'op': 'replace',191 'value': 'malformed:mac'}]192 self.assertRaises(lib_exc.BadRequest,193 self.client.update_port, port_id, patch)194 @test.attr(type=['negative'])195 @test.idempotent_id('5722b853-03fc-4854-8308-2036a1b67d85')196 def test_update_port_replace_nonexistent_property(self):197 node_id = self.node['uuid']198 address = data_utils.rand_mac_address()199 _, port = self.create_port(node_id=node_id, address=address)200 port_id = port['uuid']201 patch = [{'path': '/nonexistent', ' op': 'replace', 'value': 'value'}]202 self.assertRaises(lib_exc.BadRequest,203 self.client.update_port, port_id, patch)204 @test.attr(type=['negative'])205 @test.idempotent_id('ae2696ca-930a-4a7f-918f-30ae97c60f56')206 def test_update_port_remove_mandatory_field_mac(self):207 node_id = self.node['uuid']208 address = data_utils.rand_mac_address()209 _, port = self.create_port(node_id=node_id, address=address)210 port_id = port['uuid']211 self.assertRaises(lib_exc.BadRequest, self.client.update_port, port_id,212 [{'path': '/address', 'op': 'remove'}])213 @test.attr(type=['negative'])214 @test.idempotent_id('5392c1f0-2071-4697-9064-ec2d63019018')215 def test_update_port_remove_mandatory_field_port_uuid(self):216 node_id = self.node['uuid']217 address = data_utils.rand_mac_address()218 _, port = self.create_port(node_id=node_id, address=address)219 port_id = port['uuid']220 self.assertRaises(lib_exc.BadRequest, self.client.update_port, port_id,221 [{'path': '/uuid', 'op': 'remove'}])222 @test.attr(type=['negative'])223 @test.idempotent_id('06b50d82-802a-47ef-b079-0a3311cf85a2')224 def test_update_port_remove_nonexistent_property(self):225 node_id = self.node['uuid']226 address = data_utils.rand_mac_address()227 _, port = self.create_port(node_id=node_id, address=address)228 port_id = port['uuid']229 self.assertRaises(lib_exc.BadRequest, self.client.update_port, port_id,230 [{'path': '/nonexistent', 'op': 'remove'}])231 @test.attr(type=['negative'])232 @test.idempotent_id('03d42391-2145-4a6c-95bf-63fe55eb64fd')233 def test_delete_port_by_mac_not_allowed(self):234 node_id = self.node['uuid']235 address = data_utils.rand_mac_address()236 self.create_port(node_id=node_id, address=address)237 self.assertRaises(lib_exc.BadRequest, self.client.delete_port, address)238 @test.attr(type=['negative'])239 @test.idempotent_id('0629e002-818e-4763-b25b-ae5e07b1cb23')240 def test_update_port_mixed_ops_integrity(self):241 node_id = self.node['uuid']242 address = data_utils.rand_mac_address()243 extra = {'key1': 'value1', 'key2': 'value2'}244 _, port = self.create_port(node_id=node_id, address=address,245 extra=extra)246 port_id = port['uuid']247 new_address = data_utils.rand_mac_address()248 new_extra = {'key1': 'new-value1', 'key3': 'new-value3'}249 patch = [{'path': '/address',250 'op': 'replace',251 'value': new_address},252 {'path': '/extra/key1',253 'op': 'replace',254 'value': new_extra['key1']},255 {'path': '/extra/key2',256 'op': 'remove'},257 {'path': '/extra/key3',258 'op': 'add',259 'value': new_extra['key3']},260 {'path': '/nonexistent',261 'op': 'replace',...

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