Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

source: add a default value for search_drivers in POST /source #1287

Merged
merged 1 commit into from
Apr 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion subiquity/common/apidef.py
Expand Up @@ -145,7 +145,7 @@ def GET(index: Optional[str]) -> AnyStep: ...

class source:
def GET() -> SourceSelectionAndSetting: ...
def POST(source_id: str, search_drivers: bool) -> None: ...
def POST(source_id: str, search_drivers: bool = False) -> None: ...

class zdev:
def GET() -> List[ZdevInfo]: ...
Expand Down
3 changes: 2 additions & 1 deletion subiquity/server/controllers/source.py
Expand Up @@ -126,7 +126,8 @@ async def configured(self):
await super().configured()
self.app.base_model.set_source_variant(self.model.current.variant)

async def POST(self, source_id: str, search_drivers: bool) -> None:
async def POST(self, source_id: str,
search_drivers: bool = False) -> None:
self.model.search_drivers = search_drivers
for source in self.model.sources:
if source.id == source_id:
Expand Down
18 changes: 18 additions & 0 deletions subiquity/tests/api/test_api.py
Expand Up @@ -1041,3 +1041,21 @@ async def test_cancel_drivers(self):
# should not raise ServerDisconnectedError
resp = await inst.get('/drivers', wait=True)
self.assertEqual(['nvidia-driver-470-server'], resp['drivers'])


class TestSource(TestAPI):
async def test_optional_search_drivers(self):
async with start_server('examples/simple.json') as inst:
await inst.post('/source', source_id='ubuntu-server')
resp = await inst.get('/source')
self.assertFalse(resp['search_drivers'])

await inst.post('/source', source_id='ubuntu-server',
search_drivers=True)
resp = await inst.get('/source')
self.assertTrue(resp['search_drivers'])

await inst.post('/source', source_id='ubuntu-server',
search_drivers=False)
resp = await inst.get('/source')
self.assertFalse(resp['search_drivers'])