'Tests is_interface_valid when the adapter is required as AP but
is managed by NetworkManager'

def test_is_interface_valid_mode_ap_is_managed_by_nm_error(self):

    interface_name = 'wlan0'
    adapter = interfaces.NetworkAdapter(interface_name, 'CARD', '00:00:00:00:00:00')
    adapter.is_managed_by_nm = True
    adapter.has_ap_mode = True
    self.network_manager._name_to_object[interface_name] = adapter
    self.assertRaises(interfaces.InterfaceManagedByNetworkManagerError, self.network_manager.is_interface_valid, interface_name, 'AP')
