

@mock.patch('cloudferry.lib.os.compute.instance_info_caches.InstanceInfoCaches.enumerate_addresses')
def test_get_networks_with_sorting(self, mock_enumerate_addresses):
    unsorted_interfaces = [{
        'mac_address': 'fake_mac_1',
    }, {
        'mac_address': 'fake_mac_3',
    }, {
        'mac_address': 'fake_mac_2',
    }]
    sorted_interfaces = [{
        'mac_address': 'fake_mac_1',
    }, {
        'mac_address': 'fake_mac_2',
    }, {
        'mac_address': 'fake_mac_3',
    }]
    enumerated_addresses = {
        'fake_mac_1': 0,
        'fake_mac_2': 1,
        'fake_mac_3': 2,
    }
    mock_enumerate_addresses.return_value = enumerated_addresses
    res = self._test_get_networks(unsorted_interfaces, True)
    for (i, interface) in enumerate(res):
        self.assertEqual(sorted_interfaces[i]['mac_address'], interface['mac_address'])
    mock_enumerate_addresses.assert_called_once_with('fake_instance_id')

dataset/ETHPy150Open MirantisWorkloadMobility/CloudFerry/tests/lib/os/compute/test_nova.py NovaComputeTestCase.test_get_networks_with_sorting/original