def test_get_available_firmware_unibuild(self):
        """_get_available_firmware on unibuild board with multiple models."""
        result = utils.CmdResult(stdout=UNIBUILD_VERSION_OUTPUT, exit_status=0)
        host = mock.Mock()
        host.run.return_value = result

        fw = cros_firmware._get_available_firmware(host, 'astronaut')
        self.assertEqual(fw, 'Google_Coral.10068.37.0')

        fw = cros_firmware._get_available_firmware(host, 'blue')
        self.assertEqual(fw, 'Google_Coral.10068.39.0')

        fw = cros_firmware._get_available_firmware(host, 'bruce')
        self.assertIsNone(fw)
    def test_get_available_firmware_on_update_with_failure(self):
        """Test _get_available_firmware when update script exit_status=1."""
        result = utils.CmdResult(exit_status=1)
        host = mock.Mock()
        host.run.return_value = result

        fw = cros_firmware._get_available_firmware(host, 'lumpy')
        self.assertIsNone(fw)
    def test_get_available_firmware_returns_none(self):
        """_get_available_firmware returns None."""
        result = utils.CmdResult(stdout=NO_VERSION_OUTPUT, exit_status=0)
        host = mock.Mock()
        host.run.return_value = result

        fw = cros_firmware._get_available_firmware(host, 'lumpy')
        self.assertIsNone(fw)
    def test_get_available_firmware_returns_version(self):
        """_get_available_firmware returns BIOS version."""
        result = utils.CmdResult(stdout=VERSION_OUTPUT, exit_status=0)
        host = mock.Mock()
        host.run.return_value = result

        fw = cros_firmware._get_available_firmware(host, 'lumpy')
        self.assertEqual(fw, 'Google_Lumpy.2.111.0')