diff --git a/providers/base/bin/wifi_nmcli_test.py b/providers/base/bin/wifi_nmcli_test.py index 67fee936dc..31affc98bb 100755 --- a/providers/base/bin/wifi_nmcli_test.py +++ b/providers/base/bin/wifi_nmcli_test.py @@ -94,6 +94,8 @@ def turn_down_nm_connections(): print_head("Turn off NM all connections") connections = _get_nm_wireless_connections() for name, value in connections.items(): + if value["state"] != "activated": + continue uuid = value["uuid"] print("Turn down connection", name) cmd = "nmcli c down {}".format(uuid) diff --git a/providers/base/tests/test_wifi_nmcli_test.py b/providers/base/tests/test_wifi_nmcli_test.py index 4a58f8fa25..26683277c0 100644 --- a/providers/base/tests/test_wifi_nmcli_test.py +++ b/providers/base/tests/test_wifi_nmcli_test.py @@ -152,7 +152,10 @@ def test_no_connections_to_turn_down( @patch("wifi_nmcli_test.sp.check_call") @patch( "wifi_nmcli_test._get_nm_wireless_connections", - return_value={"Wireless1": {"uuid": "uuid1", "state": "activated"}}, + return_value={ + "Wireless1": {"uuid": "uuid1", "state": "activated"}, + "Wireless2": {"uuid": "uuid2", "state": "deactivated"}, + }, ) def test_turn_down_single_connection( self, get_connections_mock, sp_check_call_mock