How to use device_exists method in avocado

Best Python code snippet using avocado_python

test_interface.py

Source: test_interface.py Github

copy

Full Screen

...95 if additional_expectation is None:96 additional_expectation = []97 if not bridge:98 bridge = 'br-int'99 def device_exists(dev, namespace=None):100 return dev == bridge101 vsctl_cmd = ['ovs-vsctl', '--', '--may-exist', 'add-port',102 bridge, 'tap0', '--', 'set', 'Interface', 'tap0',103 'type=internal', '--', 'set', 'Interface', 'tap0',104 'external-ids:iface-id=port-1234', '--', 'set',105 'Interface', 'tap0',106 'external-ids:iface-status=active', '--', 'set',107 'Interface', 'tap0',108 'external-ids:attached-mac=aa:bb:cc:dd:ee:ff']109 with mock.patch.object(utils, 'execute') as execute:110 ovs = interface.OVSInterfaceDriver()111 self.device_exists.side_effect = device_exists112 ovs.plug('tap0',113 'port-1234',114 'aa:bb:cc:dd:ee:ff',115 bridge=bridge,116 namespace=namespace)117 execute.assert_called_once_with(*vsctl_cmd, run_as_root=True)118 expected = [mock.call(),119 mock.call().device('tap0'),120 mock.call().device().link.set_address('aa:bb:cc:dd:ee:ff')]121 expected.extend(additional_expectation)122 if namespace:123 expected.extend(124 [mock.call().ensure_namespace(namespace),125 mock.call().ensure_namespace().add_device_to_namespace(126 mock.ANY)])127 expected.extend([mock.call().device().link.set_up()])128 self.ip.assert_has_calls(expected)129 def test_unplug(self, bridge=None):130 if not bridge:131 bridge = 'br-int'132 with mock.patch('manila.network.linux.ovs_lib.OVSBridge') as ovs_br:133 ovs = interface.OVSInterfaceDriver()134 ovs.unplug('tap0')135 ovs_br.assert_has_calls([mock.call(bridge),136 mock.call().delete_port('tap0')])137class TestBridgeInterfaceDriver(TestBase):138 def test_get_device_name(self):139 br = interface.BridgeInterfaceDriver()140 device_name = br.get_device_name(FakePort)141 self.assertEqual('ns-abcdef01-12', device_name)142 def test_plug_no_ns(self):143 self._test_plug()144 def test_plug_with_ns(self):145 self._test_plug(namespace='01234567-1234-1234-99')146 def _test_plug(self, namespace=None, mtu=None):147 def device_exists(device, root_helper=None, namespace=None):148 return device.startswith('brq')149 root_veth = mock.Mock()150 ns_veth = mock.Mock()151 self.ip().add_veth = mock.Mock(return_value=(root_veth, ns_veth))152 self.device_exists.side_effect = device_exists153 br = interface.BridgeInterfaceDriver()154 mac_address = 'aa:bb:cc:dd:ee:ff'155 br.plug('ns-0',156 'port-1234',157 mac_address,158 namespace=namespace)159 ip_calls = [mock.call(),160 mock.call().add_veth('tap0', 'ns-0', namespace2=namespace)]161 ns_veth.assert_has_calls([mock.call.link.set_address(mac_address)])...

Full Screen

Full Screen

Blogs

Check out the latest blogs from LambdaTest on this topic:

Nov’22 Updates: Live With Automation Testing On OTT Streaming Devices, Test On Samsung Galaxy Z Fold4, Galaxy Z Flip4, & More

Hola Testers! Hope you all had a great Thanksgiving weekend! To make this time more memorable, we at LambdaTest have something to offer you as a token of appreciation.

Considering Agile Principles from a different angle

In addition to the four values, the Agile Manifesto contains twelve principles that are used as guides for all methodologies included under the Agile movement, such as XP, Scrum, and Kanban.

How To Choose The Best JavaScript Unit Testing Frameworks

JavaScript is one of the most widely used programming languages. This popularity invites a lot of JavaScript development and testing frameworks to ease the process of working with it. As a result, numerous JavaScript testing frameworks can be used to perform unit testing.

How To Write End-To-End Tests Using Cypress App Actions

When I started writing tests with Cypress, I was always going to use the user interface to interact and change the application’s state when running tests.

[LambdaTest Spartans Panel Discussion]: What Changed For Testing & QA Community And What Lies Ahead

The rapid shift in the use of technology has impacted testing and quality assurance significantly, especially around the cloud adoption of agile development methodologies. With this, the increasing importance of quality and automation testing has risen enough to deliver quality work.

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 avocado 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