def _test_set_static_network_config(self, adapter=True, static_val=(0,),
                                        gateway_val=(0,), dns_val=(0,)):
        conn = self._wmi_mock.WMI
        mac_address = '54:EE:75:19:F4:61'
        address = '10.10.10.10'
        broadcast = '0.0.0.0'
        dns_list = ['8.8.8.8']
        set_static_call = functools.partial(
            self._winutils.set_static_network_config,
            mac_address, address, self._NETMASK,
            broadcast, self._GATEWAY, dns_list
        )

        if adapter:
            adapter = mock.MagicMock()
        else:
            self.assertRaises(
                exception.CloudbaseInitException,
                set_static_call
            )
            return

        expected_log = []
        for (ret_val,), msg in ((static_val, "Setting static IP address"),
                                (gateway_val, "Setting static gateways"),
                                (dns_val, "Setting static DNS servers")):
            if ret_val in (0, 1):
                expected_log.append(msg)

        conn.return_value.query.return_value = adapter
        adapter_config = adapter[0].associators.return_value[0]
        adapter_config.EnableStatic.return_value = static_val
        adapter_config.SetGateways.return_value = gateway_val
        adapter_config.SetDNSServerSearchOrder.return_value = dns_val
        adapter.__len__.return_value = 1
        if static_val[0] > 1 or gateway_val[0] > 1 or dns_val[0] > 1:
            self.assertRaises(
                exception.CloudbaseInitException,
                set_static_call)
        else:
            with self.snatcher:
                response = set_static_call()
            if static_val[0] or gateway_val[0] or dns_val[0]:
                self.assertTrue(response)
            else:
                self.assertFalse(response)
            self.assertEqual(expected_log, self.snatcher.output)

            select = ("SELECT * FROM Win32_NetworkAdapter WHERE "
                      "MACAddress = '{}'".format(mac_address))
            conn.return_value.query.assert_called_once_with(select)
            adapter[0].associators.assert_called_with(
                wmi_result_class='Win32_NetworkAdapterConfiguration')
            adapter_config.EnableStatic.assert_called_with(
                [address], [self._NETMASK])
            adapter_config.SetGateways.assert_called_with(
                [self._GATEWAY], [1])
            adapter_config.SetDNSServerSearchOrder.assert_called_with(
                dns_list)
dataset/ETHPy150Open openstack/cloudbase-init/cloudbaseinit/tests/osutils/test_windows.py/TestWindowsUtils._test_set_static_network_config/original