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:
commit
a0906aa4ac
|
@ -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]: ...
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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'])
|
||||
|
|
Loading…
Reference in New Issue