How to use create_port method in tempest

Best Python code snippet using tempest_python

test_ports_negative.py

Source:test_ports_negative.py Github

copy

Full Screen

...54 def test_create_port_duplicated_port_uuid(self):55 node_id = self.node['uuid']56 address = data_utils.rand_mac_address()57 uuid = data_utils.rand_uuid()58 self.create_port(node_id=node_id, address=address, uuid=uuid)59 self.assertRaises(lib_exc.Conflict, self.create_port, node_id=node_id,60 address=address, uuid=uuid)61 @decorators.attr(type=['negative'])62 @decorators.idempotent_id('65e84917-733c-40ae-ae4b-96a4adff931c')63 def test_create_port_no_mandatory_field_node_id(self):64 address = data_utils.rand_mac_address()65 self.assertRaises(lib_exc.BadRequest, self.create_port, node_id=None,66 address=address)67 @decorators.attr(type=['negative'])68 @decorators.idempotent_id('bcea3476-7033-4183-acfe-e56a30809b46')69 def test_create_port_no_mandatory_field_mac(self):70 node_id = self.node['uuid']71 self.assertRaises(lib_exc.BadRequest, self.create_port,72 node_id=node_id, address=None)73 @decorators.attr(type=['negative'])74 @decorators.idempotent_id('2b51cd18-fb95-458b-9780-e6257787b649')75 def test_create_port_malformed_port_uuid(self):76 node_id = self.node['uuid']77 address = data_utils.rand_mac_address()78 uuid = 'malformed:uuid'79 self.assertRaises(lib_exc.BadRequest, self.create_port,80 node_id=node_id, address=address, uuid=uuid)81 @decorators.attr(type=['negative'])82 @decorators.idempotent_id('583a6856-6a30-4ac4-889f-14e2adff8105')83 def test_create_port_malformed_node_id(self):84 address = data_utils.rand_mac_address()85 self.assertRaises(lib_exc.BadRequest, self.create_port,86 node_id='malformed:nodeid', address=address)87 @decorators.attr(type=['negative'])88 @decorators.idempotent_id('e27f8b2e-42c6-4a43-a3cd-accff716bc5c')89 def test_create_port_duplicated_mac(self):90 node_id = self.node['uuid']91 address = data_utils.rand_mac_address()92 self.create_port(node_id=node_id, address=address)93 self.assertRaises(lib_exc.Conflict,94 self.create_port, node_id=node_id,95 address=address)96 @decorators.attr(type=['negative'])97 @decorators.idempotent_id('8907082d-ac5e-4be3-b05f-d072ede82020')98 def test_update_port_by_mac_not_allowed(self):99 node_id = self.node['uuid']100 address = data_utils.rand_mac_address()101 extra = {'key': 'value'}102 self.create_port(node_id=node_id, address=address, extra=extra)103 patch = [{'path': '/extra/key',104 'op': 'replace',105 'value': 'new-value'}]106 self.assertRaises(lib_exc.BadRequest,107 self.client.update_port, address,108 patch)109 @decorators.attr(type=['negative'])110 @decorators.idempotent_id('df1ac70c-db9f-41d9-90f1-78cd6b905718')111 def test_update_port_nonexistent(self):112 node_id = self.node['uuid']113 address = data_utils.rand_mac_address()114 extra = {'key': 'value'}115 _, port = self.create_port(node_id=node_id, address=address,116 extra=extra)117 port_id = port['uuid']118 _, body = self.client.delete_port(port_id)119 patch = [{'path': '/extra/key',120 'op': 'replace',121 'value': 'new-value'}]122 self.assertRaises(lib_exc.NotFound,123 self.client.update_port, port_id, patch)124 @decorators.attr(type=['negative'])125 @decorators.idempotent_id('c701e315-aa52-41ea-817c-65c5ca8ca2a8')126 def test_update_port_malformed_port_uuid(self):127 node_id = self.node['uuid']128 address = data_utils.rand_mac_address()129 self.create_port(node_id=node_id, address=address)130 new_address = data_utils.rand_mac_address()131 self.assertRaises(lib_exc.BadRequest, self.client.update_port,132 uuid='malformed:uuid',133 patch=[{'path': '/address', 'op': 'replace',134 'value': new_address}])135 @decorators.attr(type=['negative'])136 @decorators.idempotent_id('f8f15803-34d6-45dc-b06f-e5e04bf1b38b')137 def test_update_port_add_nonexistent_property(self):138 node_id = self.node['uuid']139 address = data_utils.rand_mac_address()140 _, port = self.create_port(node_id=node_id, address=address)141 port_id = port['uuid']142 self.assertRaises(lib_exc.BadRequest, self.client.update_port, port_id,143 [{'path': '/nonexistent', ' op': 'add',144 'value': 'value'}])145 @decorators.attr(type=['negative'])146 @decorators.idempotent_id('898ec904-38b1-4fcb-9584-1187d4263a2a')147 def test_update_port_replace_node_id_with_malformed(self):148 node_id = self.node['uuid']149 address = data_utils.rand_mac_address()150 _, port = self.create_port(node_id=node_id, address=address)151 port_id = port['uuid']152 patch = [{'path': '/node_uuid',153 'op': 'replace',154 'value': 'malformed:node_uuid'}]155 self.assertRaises(lib_exc.BadRequest,156 self.client.update_port, port_id, patch)157 @decorators.attr(type=['negative'])158 @decorators.idempotent_id('2949f30f-5f59-43fa-a6d9-4eac578afab4')159 def test_update_port_replace_mac_with_duplicated(self):160 node_id = self.node['uuid']161 address1 = data_utils.rand_mac_address()162 address2 = data_utils.rand_mac_address()163 _, port1 = self.create_port(node_id=node_id, address=address1)164 _, port2 = self.create_port(node_id=node_id, address=address2)165 port_id = port2['uuid']166 patch = [{'path': '/address',167 'op': 'replace',168 'value': address1}]169 self.assertRaises(lib_exc.Conflict,170 self.client.update_port, port_id, patch)171 @decorators.attr(type=['negative'])172 @decorators.idempotent_id('97f6e048-6e4f-4eba-a09d-fbbc78b77a77')173 def test_update_port_replace_node_id_with_nonexistent(self):174 node_id = self.node['uuid']175 address = data_utils.rand_mac_address()176 _, port = self.create_port(node_id=node_id, address=address)177 port_id = port['uuid']178 patch = [{'path': '/node_uuid',179 'op': 'replace',180 'value': data_utils.rand_uuid()}]181 self.assertRaises(lib_exc.BadRequest,182 self.client.update_port, port_id, patch)183 @decorators.attr(type=['negative'])184 @decorators.idempotent_id('375022c5-9e9e-4b11-9ca4-656729c0c9b2')185 def test_update_port_replace_mac_with_malformed(self):186 node_id = self.node['uuid']187 address = data_utils.rand_mac_address()188 _, port = self.create_port(node_id=node_id, address=address)189 port_id = port['uuid']190 patch = [{'path': '/address',191 'op': 'replace',192 'value': 'malformed:mac'}]193 self.assertRaises(lib_exc.BadRequest,194 self.client.update_port, port_id, patch)195 @decorators.attr(type=['negative'])196 @decorators.idempotent_id('5722b853-03fc-4854-8308-2036a1b67d85')197 def test_update_port_replace_nonexistent_property(self):198 node_id = self.node['uuid']199 address = data_utils.rand_mac_address()200 _, port = self.create_port(node_id=node_id, address=address)201 port_id = port['uuid']202 patch = [{'path': '/nonexistent', ' op': 'replace', 'value': 'value'}]203 self.assertRaises(lib_exc.BadRequest,204 self.client.update_port, port_id, patch)205 @decorators.attr(type=['negative'])206 @decorators.idempotent_id('ae2696ca-930a-4a7f-918f-30ae97c60f56')207 def test_update_port_remove_mandatory_field_mac(self):208 node_id = self.node['uuid']209 address = data_utils.rand_mac_address()210 _, port = self.create_port(node_id=node_id, address=address)211 port_id = port['uuid']212 self.assertRaises(lib_exc.BadRequest, self.client.update_port, port_id,213 [{'path': '/address', 'op': 'remove'}])214 @decorators.attr(type=['negative'])215 @decorators.idempotent_id('5392c1f0-2071-4697-9064-ec2d63019018')216 def test_update_port_remove_mandatory_field_port_uuid(self):217 node_id = self.node['uuid']218 address = data_utils.rand_mac_address()219 _, port = self.create_port(node_id=node_id, address=address)220 port_id = port['uuid']221 self.assertRaises(lib_exc.BadRequest, self.client.update_port, port_id,222 [{'path': '/uuid', 'op': 'remove'}])223 @decorators.attr(type=['negative'])224 @decorators.idempotent_id('06b50d82-802a-47ef-b079-0a3311cf85a2')225 def test_update_port_remove_nonexistent_property(self):226 node_id = self.node['uuid']227 address = data_utils.rand_mac_address()228 _, port = self.create_port(node_id=node_id, address=address)229 port_id = port['uuid']230 self.assertRaises(lib_exc.BadRequest, self.client.update_port, port_id,231 [{'path': '/nonexistent', 'op': 'remove'}])232 @decorators.attr(type=['negative'])233 @decorators.idempotent_id('03d42391-2145-4a6c-95bf-63fe55eb64fd')234 def test_delete_port_by_mac_not_allowed(self):235 node_id = self.node['uuid']236 address = data_utils.rand_mac_address()237 self.create_port(node_id=node_id, address=address)238 self.assertRaises(lib_exc.BadRequest, self.client.delete_port, address)239 @decorators.attr(type=['negative'])240 @decorators.idempotent_id('0629e002-818e-4763-b25b-ae5e07b1cb23')241 def test_update_port_mixed_ops_integrity(self):242 node_id = self.node['uuid']243 address = data_utils.rand_mac_address()244 extra = {'key1': 'value1', 'key2': 'value2'}245 _, port = self.create_port(node_id=node_id, address=address,246 extra=extra)247 port_id = port['uuid']248 new_address = data_utils.rand_mac_address()249 new_extra = {'key1': 'new-value1', 'key3': 'new-value3'}250 patch = [{'path': '/address',251 'op': 'replace',252 'value': new_address},253 {'path': '/extra/key1',254 'op': 'replace',255 'value': new_extra['key1']},256 {'path': '/extra/key2',257 'op': 'remove'},258 {'path': '/extra/key3',259 'op': 'add',260 'value': new_extra['key3']},261 {'path': '/nonexistent',262 'op': 'replace',263 'value': 'value'}]264 self.assertRaises(lib_exc.BadRequest, self.client.update_port, port_id,265 patch)266 # patch should not be applied267 _, body = self.client.show_port(port_id)268 self.assertEqual(address, body['address'])269 self.assertEqual(extra, body['extra'])270class TestPortsWithPhysicalNetworkOldAPI(base.BaseBaremetalTest):271 """Negative tests for ports with physical network information."""272 def setUp(self):273 super(TestPortsWithPhysicalNetworkOldAPI, self).setUp()274 _, self.chassis = self.create_chassis()275 _, self.node = self.create_node(self.chassis['uuid'])276 @decorators.attr(type=['negative'])277 @decorators.idempotent_id('307e57e9-082f-4830-9480-91affcbfda08')278 def test_create_port_with_physical_network_old_api(self):279 node_id = self.node['uuid']280 address = data_utils.rand_mac_address()281 self.assertRaises((lib_exc.BadRequest, lib_exc.UnexpectedResponseCode),282 self.create_port,283 node_id=node_id, address=address,284 physical_network='physnet1')285 @decorators.attr(type=['negative'])286 @decorators.idempotent_id('0b278c0a-d334-424e-a5c5-b6d001c2a715')287 def test_update_port_replace_physical_network_old_api(self):288 _, port = self.create_port(self.node['uuid'],289 data_utils.rand_mac_address())290 new_physnet = 'physnet1'291 patch = [{'path': '/physical_network',292 'op': 'replace',293 'value': new_physnet}]294 self.assertRaises((lib_exc.BadRequest, lib_exc.UnexpectedResponseCode),295 self.client.update_port,296 port['uuid'], patch)297class TestPortsNegativeWithPhysicalNetwork(base.BaseBaremetalTest):298 """Negative tests for ports with physical network information."""299 min_microversion = '1.34'300 def setUp(self):301 super(TestPortsNegativeWithPhysicalNetwork, self).setUp()302 self.useFixture(303 api_microversion_fixture.APIMicroversionFixture(304 TestPortsNegativeWithPhysicalNetwork.min_microversion)305 )306 _, self.chassis = self.create_chassis()307 _, self.node = self.create_node(self.chassis['uuid'])308 @decorators.attr(type=['negative'])309 @decorators.idempotent_id('e20156fb-956b-4d5b-89a4-f379044a1d3c')310 def test_create_ports_in_portgroup_with_inconsistent_physical_network(311 self):312 node_id = self.node['uuid']313 address = data_utils.rand_mac_address()314 _, portgroup = self.create_portgroup(node_id, address=address)315 _, _ = self.create_port(node_id=node_id, address=address,316 portgroup_uuid=portgroup['uuid'],317 physical_network='physnet1')318 address = data_utils.rand_mac_address()319 self.assertRaises(lib_exc.Conflict,320 self.create_port,321 node_id=node_id, address=address,322 portgroup_uuid=portgroup['uuid'],323 physical_network='physnet2')324 @decorators.attr(type=['negative'])325 @decorators.idempotent_id('050e792c-22c9-4e4a-ae89-dfbfc52ad00d')326 def test_update_ports_in_portgroup_with_inconsistent_physical_network(327 self):328 node_id = self.node['uuid']329 address = data_utils.rand_mac_address()330 _, portgroup = self.create_portgroup(node_id, address=address)331 _, _ = self.create_port(node_id=node_id, address=address,332 portgroup_uuid=portgroup['uuid'],333 physical_network='physnet1')334 address = data_utils.rand_mac_address()335 _, port2 = self.create_port(node_id=node_id, address=address,336 physical_network='physnet2')337 patch = [{'path': '/portgroup_uuid',338 'op': 'replace',339 'value': portgroup['uuid']}]340 self.assertRaises(lib_exc.Conflict,341 self.client.update_port,342 port2['uuid'], patch)343 @decorators.attr(type=['negative'])344 @decorators.idempotent_id('3cd1c8ec-57d1-40cb-922b-dd02431beea3')345 def test_update_ports_in_portgroup_with_inconsistent_physical_network_2(346 self):347 node_id = self.node['uuid']348 address = data_utils.rand_mac_address()349 _, portgroup = self.create_portgroup(node_id, address=address)350 _, _ = self.create_port(node_id=node_id, address=address,351 portgroup_uuid=portgroup['uuid'],352 physical_network='physnet1')353 address = data_utils.rand_mac_address()354 _, port2 = self.create_port(node_id=node_id, address=address,355 portgroup_uuid=portgroup['uuid'],356 physical_network='physnet1')357 patch = [{'path': '/physical_network',358 'op': 'replace',359 'value': 'physnet2'}]360 self.assertRaises(lib_exc.Conflict,361 self.client.update_port,...

Full Screen

Full Screen

test_connection.py

Source:test_connection.py Github

copy

Full Screen

...4 def test_connection_class_attributes_exist(self):5 oSystem = de.system.create('Top Level')6 oComponent1 = oSystem.add_component(de.component.create('Component1', 'Component1'))7 oInterface1 = oComponent1.create_interface('Interface1')8 oInterface1.create_port('I1 P1', 1, 'out')9 oInterface1.create_port('I1 P2', 1, 'out')10 oInterface1.create_port('I1 P3', 1, 'out')11 oInterface1.create_port('I1 P4', 1, 'out')12 oComponent2 = oSystem.add_component(de.component.create('Component2', 'Component2'))13 oInterface2 = oComponent2.create_interface('Interface2')14 oInterface2.create_port('I2 P1', 1, 'out')15 oInterface2.create_port('I2 P2', 1, 'out')16 oInterface2.create_port('I2 P3', 1, 'out')17 oInterface2.create_port('I2 P4', 1, 'out')18 oConnection = de.connection.create('con1', oSystem, 'Component1.Interface1', 'Component2.Interface2')19 self.assertEqual(oConnection.name, 'con1')20 self.assertEqual(oConnection.source.name, 'Interface1')21 self.assertEqual(oConnection.sink.name, 'Interface2')22 self.assertEqual(oConnection.source.path, None)23 self.assertEqual(oConnection.sink.path, None)24 dMap = {}25 dMap['I1 P1'] = 'I2 P1'26 dMap['I1 P2'] = 'I2 P2'27 dMap['I1 P3'] = 'I2 P3'28 dMap['I1 P4'] = 'I2 P4'29 self.assertEqual(dMap, oConnection.map)30 def test_connection_map_port_method(self):31 oSystem = de.system.create('Top Level')32 oComponent1 = oSystem.add_component(de.component.create('Component1', 'Component1'))33 oInterface1 = oComponent1.create_interface('Interface1')34 oInterface1.create_port('I1 P1', 1, 'out')35 oInterface1.create_port('I1 P2', 1, 'out')36 oInterface1.create_port('I1 P3', 1, 'out')37 oInterface1.create_port('I1 P4', 1, 'out')38 oComponent2 = oSystem.add_component(de.component.create('Component2', 'Component2'))39 oInterface2 = oComponent2.create_interface('Interface2')40 oInterface2.create_port('I2 P1', 1, 'out')41 oInterface2.create_port('I2 P2', 1, 'out')42 oInterface2.create_port('I2 P3', 1, 'out')43 oInterface2.create_port('I2 P4', 1, 'out')44 oConnection = de.connection.create('con1', oSystem, 'Component1.Interface1', 'Component2.Interface2', False)45 self.assertEqual(None, oConnection.map)46 oConnection.map_port('I1 P1', 'I2 P4')47 dMap = {}48 dMap['I1 P1'] = 'I2 P4'49 self.assertEqual(dMap, oConnection.map)50 def test_multilevel_connection(self):51 oSystem = de.system.create('top')52 oCca1 = de.hw.cca.create('Cca1')53 oCca2 = de.hw.cca.create('Cca2')54 oCca3 = de.hw.cca.create('Cca3')55 oCca4 = de.hw.cca.create('Cca4')56 oCca5 = de.hw.cca.create('Cca5')57 oCca6 = de.hw.cca.create('Cca6')...

Full Screen

Full Screen

test_routing.py

Source:test_routing.py Github

copy

Full Screen

...4"""5import pytest6from syslog2irc.network import Port, TransportProtocol7from syslog2irc.routing import map_channel_names_to_ports, Route, Router8def create_port(number):9 return Port(number, TransportProtocol.UDP)10@pytest.mark.parametrize(11 'routes, expected',12 [13 (14 {15 create_port(514): ['#example1'],16 },17 {18 '#example1': {create_port(514)},19 },20 ),21 (22 {23 create_port(514): ['#example1', '#example2'],24 create_port(55514): ['#example2'],25 },26 {27 '#example1': {create_port(514)},28 '#example2': {create_port(514), create_port(55514)},29 },30 ),31 ],32)33def test_map_channel_names_to_ports(routes, expected):34 assert map_channel_names_to_ports(routes) == expected35def test_do_not_enable_channel_without_routed_ports():36 routes = {37 Route(create_port(514), '#one'),38 }39 router = Router(routes)40 router.enable_channel(None, channel_name='#one')41 router.enable_channel(None, channel_name='#two')42 assert router.is_channel_enabled('#one')...

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