Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Oct 29, 2025

Addresses #5184 by adding comprehensive test coverage for the Interface._map_nm_wifi static method, which maps NetworkManager wireless interface data to internal WifiConfig objects.

Tests Added

Added 12 test cases covering:

  • Early returns: Non-wireless interfaces, missing settings
  • Authentication methods: OPEN, WEP, WPA-PSK, unsupported (wpa-eap)
  • WiFi modes: infrastructure, mesh, adhoc, ap
  • Signal strength: Present, absent, wireless object without active AP
  • Edge cases: Missing wireless settings, missing mode (defaults to infrastructure)

Implementation

All tests use mocking to avoid NetworkManager D-Bus dependencies:

def test_map_nm_wifi_wpa_psk_authentication():
    """Test _map_nm_wifi with WPA-PSK authentication."""
    mock_interface = Mock()
    mock_interface.type = DeviceType.WIRELESS
    mock_interface.settings = Mock()
    mock_interface.settings.wireless_security = Mock()
    mock_interface.settings.wireless_security.key_mgmt = "wpa-psk"
    mock_interface.settings.wireless_security.psk = "SecretPassword123"
    # ... additional setup ...
    
    result = Interface._map_nm_wifi(mock_interface)
    
    assert result.auth == AuthMethod.WPA_PSK
    assert result.psk == "SecretPassword123"

Tests follow existing patterns in test_configuration.py and validate all code paths including the warning path for unsupported authentication methods.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • esm.ubuntu.com
    • Triggering command: /usr/lib/apt/methods/https (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

This section details on the original issue you should resolve

<issue_title>Add test coverage for _map_nm_wifi</issue_title>
<issue_description>### Description

Related to #5184. We should have general test coverage for that method.

Additional context

No response</issue_description>

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI changed the title [WIP] Add test coverage for _map_nm_wifi method Add test coverage for _map_nm_wifi method Oct 29, 2025
Copilot AI requested a review from agners October 29, 2025 16:51
Copilot finished work on behalf of agners October 29, 2025 16:51
@agners agners added the test Adding missing tests or correcting existing tests label Nov 3, 2025
@agners agners marked this pull request as ready for review November 3, 2025 08:47
@agners agners merged commit a8b7923 into main Nov 3, 2025
26 of 39 checks passed
@agners agners deleted the copilot/add-test-coverage-map-nm-wifi branch November 3, 2025 09:04
@github-actions github-actions bot locked and limited conversation to collaborators Nov 5, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

test Adding missing tests or correcting existing tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add test coverage for _map_nm_wifi

2 participants