diff --git a/checkbox-support/checkbox_support/parsers/tests/test_udevadm.py b/checkbox-support/checkbox_support/parsers/tests/test_udevadm.py index 20d8445ca..e403faa6c 100644 --- a/checkbox-support/checkbox_support/parsers/tests/test_udevadm.py +++ b/checkbox-support/checkbox_support/parsers/tests/test_udevadm.py @@ -1140,7 +1140,6 @@ def test_VRAID_machine(self): """ devices = self.parse("With_VRAID", with_partitions=True) - def verify_devices(self, devices, expected_device_list): """ Verify we have the expected quantity of each device given in the list, diff --git a/checkbox-support/checkbox_support/parsers/udevadm.py b/checkbox-support/checkbox_support/parsers/udevadm.py index 6010e6ca8..6ad463b9c 100644 --- a/checkbox-support/checkbox_support/parsers/udevadm.py +++ b/checkbox-support/checkbox_support/parsers/udevadm.py @@ -221,7 +221,7 @@ def bus(self): else: return "usb" else: - if len(self._stack)>=2: + if len(self._stack) >= 2: return self._stack[-2]._environment.get("SUBSYSTEM") else: return self._stack[0]._environment.get("SUBSYSTEM") diff --git a/providers/base/bin/get_firmware_info_fwupd.py b/providers/base/bin/get_firmware_info_fwupd.py index c0d295785..641fe91a3 100755 --- a/providers/base/bin/get_firmware_info_fwupd.py +++ b/providers/base/bin/get_firmware_info_fwupd.py @@ -33,8 +33,8 @@ def get_fwupdmgr_services_versions(): list: fwupd client and daemon versions """ fwupd_vers = subprocess.run( - shlex.split("fwupdmgr --version --json"), - capture_output=True) + shlex.split("fwupdmgr --version --json"), capture_output=True + ) fwupd_vers = json.loads(fwupd_vers.stdout).get("Versions", []) return fwupd_vers @@ -49,8 +49,10 @@ def get_fwupd_runtime_version(): runtime_ver = () for ver in get_fwupdmgr_services_versions(): - if (ver.get("Type") == "runtime" and - ver.get("AppstreamId") == "org.freedesktop.fwupd"): + if ( + ver.get("Type") == "runtime" + and ver.get("AppstreamId") == "org.freedesktop.fwupd" + ): runtime_ver = tuple(map(int, ver.get("Version").split("."))) return runtime_ver diff --git a/providers/base/tests/test_get_firmware_info_fwupd.py b/providers/base/tests/test_get_firmware_info_fwupd.py index dbc8b6bba..b7a58a986 100644 --- a/providers/base/tests/test_get_firmware_info_fwupd.py +++ b/providers/base/tests/test_get_firmware_info_fwupd.py @@ -17,60 +17,62 @@ def test_get_deb_fwupd_version_success(self, mock_subporcess, mock_json): { "Type": "runtime", "AppstreamId": "org.freedesktop.fwupd", - "Version": "1.9.14" + "Version": "1.9.14", }, { "Type": "compile", "AppstreamId": "org.freedesktop.fwupd", - "Version": "1.7.9" - } + "Version": "1.7.9", + }, ] } json_resp = json.dumps(dict_resp) mock_subporcess.return_value = subprocess.CompletedProcess( - returncode=0, - stdout=json_resp, - args=["fwupdmgr", "--version", "--json"] - ) + returncode=0, + stdout=json_resp, + args=["fwupdmgr", "--version", "--json"], + ) mock_json.return_value = dict_resp fwupd_vers = get_firmware_info_fwupd.get_fwupdmgr_services_versions() mock_subporcess.assert_called_with( - ['fwupdmgr', '--version', '--json'], - capture_output=True) + ["fwupdmgr", "--version", "--json"], capture_output=True + ) mock_json.assert_called_with(json_resp) self.assertListEqual(dict_resp["Versions"], fwupd_vers) @patch("json.loads") @patch("subprocess.run") def test_get_deb_fwupd_version_key_not_match( - self, mock_subporcess, mock_json): + self, mock_subporcess, mock_json + ): dict_resp = { "Services": [ { "Type": "runtime", "AppstreamId": "org.freedesktop.fwupd", - "Version": "1.9.14" + "Version": "1.9.14", }, { "Type": "compile", "AppstreamId": "org.freedesktop.fwupd", - "Version": "1.7.9" - } + "Version": "1.7.9", + }, ] } json_resp = json.dumps(dict_resp) mock_subporcess.return_value = subprocess.CompletedProcess( - returncode=0, - stdout=json_resp, - args=["fwupdmgr", "--version", "--json"] - ) + returncode=0, + stdout=json_resp, + args=["fwupdmgr", "--version", "--json"], + ) mock_json.return_value = dict_resp fwupd_vers = get_firmware_info_fwupd.get_fwupdmgr_services_versions() mock_subporcess.assert_called_with( - ['fwupdmgr', '--version', '--json'], capture_output=True) + ["fwupdmgr", "--version", "--json"], capture_output=True + ) mock_json.assert_called_with(json_resp) self.assertListEqual([], fwupd_vers) @@ -82,13 +84,13 @@ def test_get_deb_fwupd_runtime_version_success(self, mock_fwupd_vers): { "Type": "runtime", "AppstreamId": "org.freedesktop.fwupd", - "Version": "1.7.9" + "Version": "1.7.9", }, { "Type": "compile", "AppstreamId": "org.freedesktop.fwupd", - "Version": "1.7.9" - } + "Version": "1.7.9", + }, ] mock_fwupd_vers.return_value = fwupd_vers_resp @@ -102,7 +104,7 @@ def test_get_deb_fwupd_runtime_version_failed(self, mock_fwupd_vers): { "Type": "compile", "AppstreamId": "org.freedesktop.fwupd", - "Version": "1.7.9" + "Version": "1.7.9", } ] @@ -113,41 +115,45 @@ def test_get_deb_fwupd_runtime_version_failed(self, mock_fwupd_vers): @patch("subprocess.run") @patch("checkbox_support.snap_utils.snapd.Snapd.list") def test_get_firmware_data_by_fwupd_snap( - self, mock_snapd, mock_subporcess): + self, mock_snapd, mock_subporcess + ): mock_snapd.return_value = { "id": "HpOj37PuyuaMUZY0NQhtwnp7oS5P8u5R", "title": "fwupd", - "summary": "Firmware updates for Linux" + "summary": "Firmware updates for Linux", } get_firmware_info_fwupd.get_firmware_info_fwupd() mock_snapd.assert_called_with("fwupd") mock_subporcess.assert_called_with( - ['fwupd.fwupdmgr', 'get-devices', '--json']) + ["fwupd.fwupdmgr", "get-devices", "--json"] + ) @patch.dict(os.environ, {"SNAP": "checkbox-snap"}) @patch("subprocess.run") @patch("get_firmware_info_fwupd.get_fwupd_runtime_version") @patch("checkbox_support.snap_utils.snapd.Snapd.list") def test_get_firmware_data_by_fwupd1914_deb_on_checkbox_snap( - self, mock_snapd, mock_fwupd_ver, mock_subporcess): + self, mock_snapd, mock_fwupd_ver, mock_subporcess + ): mock_snapd.return_value = None mock_fwupd_ver.return_value = (1, 9, 14) get_firmware_info_fwupd.get_firmware_info_fwupd() mock_snapd.assert_called_with("fwupd") - self.assertEqual( - os.environ.get("SNAP"), "checkbox-snap") + self.assertEqual(os.environ.get("SNAP"), "checkbox-snap") mock_subporcess.assert_called_with( - ['fwupdmgr', 'get-devices', '--json']) + ["fwupdmgr", "get-devices", "--json"] + ) @patch.dict(os.environ, {"SNAP": "checkbox-snap"}) @patch("subprocess.run") @patch("get_firmware_info_fwupd.get_fwupd_runtime_version") @patch("checkbox_support.snap_utils.snapd.Snapd.list") def test_get_firmware_data_by_fwupd_deb179_on_checkbox_snap( - self, mock_snapd, mock_fwupd_ver, mock_subporcess): + self, mock_snapd, mock_fwupd_ver, mock_subporcess + ): mock_snapd.return_value = False mock_fwupd_ver.return_value = (1, 7, 9) @@ -159,13 +165,15 @@ def test_get_firmware_data_by_fwupd_deb179_on_checkbox_snap( # SNAP env is empty after get_firmware_info_fwupd been called self.assertIsNone(os.environ.get("SNAP")) mock_subporcess.assert_called_with( - ['fwupdmgr', 'get-devices', '--json']) + ["fwupdmgr", "get-devices", "--json"] + ) @patch("subprocess.run") @patch("get_firmware_info_fwupd.get_fwupd_runtime_version") @patch("checkbox_support.snap_utils.snapd.Snapd.list") def test_get_firmware_data_by_fwupd_deb_on_checkbox_deb( - self, mock_snapd, mock_fwupd_ver, mock_subporcess): + self, mock_snapd, mock_fwupd_ver, mock_subporcess + ): mock_snapd.return_value = False mock_fwupd_ver.return_value = (1, 7, 9) @@ -175,4 +183,5 @@ def test_get_firmware_data_by_fwupd_deb_on_checkbox_deb( get_firmware_info_fwupd.get_firmware_info_fwupd() mock_snapd.assert_called_with("fwupd") mock_subporcess.assert_called_with( - ['fwupdmgr', 'get-devices', '--json']) + ["fwupdmgr", "get-devices", "--json"] + )