timezone: remove possible tzs from schema
This commit is contained in:
parent
9818ca9717
commit
c37535c530
|
@ -78,16 +78,22 @@ class TimeZoneController(SubiquityController):
|
|||
|
||||
endpoint = API.timezone
|
||||
|
||||
possible = generate_possible_tzs()
|
||||
|
||||
autoinstall_key = model_name = 'timezone'
|
||||
autoinstall_schema = {
|
||||
'type': 'string',
|
||||
'enum': possible
|
||||
}
|
||||
|
||||
autoinstall_default = ''
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
self.possible = None
|
||||
super().__init__(*args, **kwargs)
|
||||
|
||||
def get_possible_tzs(self):
|
||||
if self.possible is None:
|
||||
self.possible = generate_possible_tzs()
|
||||
return self.possible
|
||||
|
||||
def load_autoinstall_data(self, data):
|
||||
self.deserialize(data)
|
||||
|
||||
|
@ -100,7 +106,7 @@ class TimeZoneController(SubiquityController):
|
|||
def deserialize(self, data):
|
||||
if data is None:
|
||||
return
|
||||
if data not in self.possible:
|
||||
if data not in self.get_possible_tzs():
|
||||
raise ValueError(f'Unrecognized time zone request "{data}"')
|
||||
self.model.set(data)
|
||||
if self.model.detect_with_geoip and self.app.geoip.timezone:
|
||||
|
|
|
@ -99,6 +99,7 @@ class TestTimeZoneController(SubiTestCase):
|
|||
def test_set_tz_escape_dryrun(self, tdc_gettz, subprocess_run):
|
||||
tdc_gettz.return_value = tz_utc
|
||||
self.tzc.app.dry_run = True
|
||||
self.tzc.possible = ['geoip']
|
||||
self.tzc.deserialize('geoip')
|
||||
self.assertEqual('sleep', subprocess_run.call_args.args[0][0])
|
||||
|
||||
|
|
Loading…
Reference in New Issue