-
Notifications
You must be signed in to change notification settings - Fork 161
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2129 from Chris-Peterson444/add-core-variant-support
Introduce support for "core" variant in TUI
- Loading branch information
Showing
8 changed files
with
179 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
# Copyright 2025 Canonical, Ltd. | ||
# | ||
# This program is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License as published by | ||
# the Free Software Foundation, version 3. | ||
# | ||
# This program is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License | ||
# along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
from unittest.mock import AsyncMock, Mock, patch | ||
|
||
from subiquity.client.controllers.source import SourceController | ||
from subiquity.common.types import SourceSelectionAndSetting | ||
from subiquitycore.tests import SubiTestCase | ||
from subiquitycore.tests.mocks import make_app | ||
from subiquitycore.tests.parameterized import parameterized | ||
from subiquitycore.tuicontroller import Skip | ||
|
||
|
||
class TestSourceController(SubiTestCase): | ||
def setUp(self): | ||
self.app = make_app() | ||
self.app.client = AsyncMock() | ||
self.app.show_error_report = Mock() | ||
self.app.show_nonreportable_error = Mock() | ||
|
||
self.controller = SourceController(self.app) | ||
|
||
@parameterized.expand( | ||
( | ||
("core", 1, True), # core is the only driverless variant | ||
("core", 2, False), # don't skip if core has multiple sources | ||
("server", 1, False), # Any other variant shouldn't skip | ||
) | ||
) | ||
async def test_make_ui__skip_simple_sources(self, variant, sources, skip): | ||
"""Test source screen is skipped for single-source, driverless media.""" | ||
|
||
self.app.variant = variant | ||
resp = SourceSelectionAndSetting( | ||
sources=[Mock() for i in range(sources)], | ||
current_id=0, | ||
search_drivers=None, | ||
) | ||
|
||
with ( | ||
patch("subiquity.client.controllers.source.SourceView"), | ||
patch.object(self.controller.endpoint, "GET", return_value=resp), | ||
): | ||
if not skip: | ||
await self.controller.make_ui() | ||
else: | ||
with self.assertRaises(Skip): | ||
await self.controller.make_ui() |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# Copyright 2025 Canonical, Ltd. | ||
# | ||
# This program is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License as published by | ||
# the Free Software Foundation, version 3. | ||
# | ||
# This program is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License | ||
# along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
from unittest.mock import Mock | ||
|
||
from subiquity.client.client import SubiquityClient | ||
from subiquitycore.tests import SubiTestCase | ||
|
||
|
||
class TestClientVariantSupport(SubiTestCase): | ||
async def asyncSetUp(self): | ||
opts = Mock() | ||
opts.dry_run = True | ||
opts.output_base = self.tmp_dir() | ||
opts.machine_config = "examples/machines/simple.json" | ||
opts.answers = None | ||
self.client = SubiquityClient(opts, None) | ||
self.client.make_apport_report = Mock() | ||
|
||
def test_default_variant(self): | ||
expected = SubiquityClient.variant_to_controllers["server"] | ||
self.assertEqual( | ||
# The controllers attribute is a list of names before init | ||
SubiquityClient.controllers, | ||
expected, | ||
"default controller names do not match names for 'server' variant", | ||
) | ||
self.assertEqual( | ||
# The controllers attribute is a ControllerSet after init | ||
self.client.controllers.controller_names, | ||
expected, | ||
"controllers changed unexpectedly during init", | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters