def test_ofctl_arg_supported(self): with mock.patch('neutron.common.utils.get_random_string') as utils: utils.return_value = 'test' supported = ovs_lib.ofctl_arg_supported(self.root_helper, 'cmd', ['args']) self.execute.assert_has_calls([ mock.call(['ovs-vsctl', self.TO, '--', '--if-exists', 'del-br', 'br-test-test'], root_helper=self.root_helper), mock.call(['ovs-vsctl', self.TO, '--', '--may-exist', 'add-br', 'br-test-test'], root_helper=self.root_helper), mock.call(['ovs-ofctl', 'cmd', 'br-test-test', 'args'], root_helper=self.root_helper), mock.call(['ovs-vsctl', self.TO, '--', '--if-exists', 'del-br', 'br-test-test'], root_helper=self.root_helper) ]) self.assertTrue(supported) self.execute.side_effect = Exception supported = ovs_lib.ofctl_arg_supported(self.root_helper, 'cmd', ['args']) self.execute.assert_has_calls([ mock.call(['ovs-vsctl', self.TO, '--', '--if-exists', 'del-br', 'br-test-test'], root_helper=self.root_helper), mock.call(['ovs-vsctl', self.TO, '--', '--may-exist', 'add-br', 'br-test-test'], root_helper=self.root_helper), mock.call(['ovs-ofctl', 'cmd', 'br-test-test', 'args'], root_helper=self.root_helper), mock.call(['ovs-vsctl', self.TO, '--', '--if-exists', 'del-br', 'br-test-test'], root_helper=self.root_helper) ]) self.assertFalse(supported)
def test_ofctl_arg_supported(self): with mock.patch("neutron.common.utils.get_random_string") as utils: utils.return_value = "test" supported = ovs_lib.ofctl_arg_supported(self.root_helper, "cmd", ["args"]) self.execute.assert_has_calls( [ mock.call( ["ovs-vsctl", self.TO, "--", "--if-exists", "del-br", "br-test-test"], root_helper=self.root_helper, ), mock.call( ["ovs-vsctl", self.TO, "--", "--may-exist", "add-br", "br-test-test"], root_helper=self.root_helper, ), mock.call(["ovs-ofctl", "cmd", "br-test-test", "args"], root_helper=self.root_helper), mock.call( ["ovs-vsctl", self.TO, "--", "--if-exists", "del-br", "br-test-test"], root_helper=self.root_helper, ), ] ) self.assertTrue(supported) self.execute.side_effect = Exception supported = ovs_lib.ofctl_arg_supported(self.root_helper, "cmd", ["args"]) self.execute.assert_has_calls( [ mock.call( ["ovs-vsctl", self.TO, "--", "--if-exists", "del-br", "br-test-test"], root_helper=self.root_helper, ), mock.call( ["ovs-vsctl", self.TO, "--", "--may-exist", "add-br", "br-test-test"], root_helper=self.root_helper, ), mock.call(["ovs-ofctl", "cmd", "br-test-test", "args"], root_helper=self.root_helper), mock.call( ["ovs-vsctl", self.TO, "--", "--if-exists", "del-br", "br-test-test"], root_helper=self.root_helper, ), ] ) self.assertFalse(supported)