Merge pull request #1287 from ogayot/optional-search_drivers

source: add a default value for search_drivers in POST /source
This commit is contained in:
Michael Hudson-Doyle 2022-04-29 14:01:05 +12:00 committed by GitHub
commit a0906aa4ac
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 21 additions and 2 deletions

View File

@ -145,7 +145,7 @@ class API:
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]: ...

View File

@ -126,7 +126,8 @@ class SourceController(SubiquityController):
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:

View File

@ -1041,3 +1041,21 @@ class TestCancel(TestAPI):
# 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'])