GET /timezone no longer sets to system
The original design for timezone intentionally set the system timezone based on geoip results, before a POST /timezone. After the feedback on LP: #1936310 I'm having second thoughts on that and wish for GET to be a simple informational query with no such side effects.
This commit is contained in:
parent
c79aa602dc
commit
7808ccac84
|
@ -108,16 +108,17 @@ class TimeZoneController(SubiquityController):
|
||||||
timedatectl_settz(self.app, self.model.timezone)
|
timedatectl_settz(self.app, self.model.timezone)
|
||||||
|
|
||||||
async def GET(self) -> TimeZoneInfo:
|
async def GET(self) -> TimeZoneInfo:
|
||||||
|
# if someone POSTed before, return that
|
||||||
if self.model.timezone:
|
if self.model.timezone:
|
||||||
return TimeZoneInfo(self.model.timezone,
|
return TimeZoneInfo(self.model.timezone,
|
||||||
self.model.got_from_geoip)
|
self.model.got_from_geoip)
|
||||||
|
|
||||||
# a bare call to GET() is equivalent to autoinstall "timezone: geoip"
|
# GET requests geoip results
|
||||||
self.deserialize('geoip')
|
if self.app.geoip.timezone:
|
||||||
tz = self.model.timezone
|
return TimeZoneInfo(self.app.geoip.timezone, True)
|
||||||
if not tz:
|
|
||||||
tz = timedatectl_gettz()
|
# geoip wasn't ready for some reason, so ask the system
|
||||||
return TimeZoneInfo(tz, self.model.got_from_geoip)
|
return TimeZoneInfo(timedatectl_gettz(), False)
|
||||||
|
|
||||||
async def POST(self, tz: str):
|
async def POST(self, tz: str):
|
||||||
self.deserialize(tz)
|
self.deserialize(tz)
|
||||||
|
|
|
@ -14,7 +14,6 @@
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
import mock
|
import mock
|
||||||
import subprocess
|
|
||||||
|
|
||||||
from subiquity.common.types import TimeZoneInfo
|
from subiquity.common.types import TimeZoneInfo
|
||||||
from subiquity.models.timezone import TimeZoneModel
|
from subiquity.models.timezone import TimeZoneModel
|
||||||
|
@ -102,3 +101,9 @@ class TestTimeZoneController(SubiTestCase):
|
||||||
self.tzc.app.dry_run = True
|
self.tzc.app.dry_run = True
|
||||||
self.tzc.deserialize('geoip')
|
self.tzc.deserialize('geoip')
|
||||||
self.assertEqual('sleep', subprocess_run.call_args.args[0][0])
|
self.assertEqual('sleep', subprocess_run.call_args.args[0][0])
|
||||||
|
|
||||||
|
@mock.patch('subiquity.server.controllers.timezone.timedatectl_settz')
|
||||||
|
def test_get_tz_should_not_set(self, tdc_settz):
|
||||||
|
run_coro(self.tzc.GET())
|
||||||
|
self.assertFalse(self.tzc.model.should_set_tz)
|
||||||
|
tdc_settz.assert_not_called()
|
||||||
|
|
Loading…
Reference in New Issue