From f16fe404f229006fa7371f0a62575c81d8424954 Mon Sep 17 00:00:00 2001 From: Joseph Nuthalapati Date: Wed, 10 Oct 2018 10:15:17 -0700 Subject: [PATCH] datetime: Add functional test for setting time zone Reviewed-by: James Valleroy --- functional_tests/features/date_and_time.feature | 4 ++++ functional_tests/step_definitions/application.py | 10 ++++++++++ functional_tests/support/application.py | 13 +++++++++++++ 3 files changed, 27 insertions(+) diff --git a/functional_tests/features/date_and_time.feature b/functional_tests/features/date_and_time.feature index 2ff8e0624..1a5e136e0 100644 --- a/functional_tests/features/date_and_time.feature +++ b/functional_tests/features/date_and_time.feature @@ -31,3 +31,7 @@ Scenario: Disable network time application Given the network time application is enabled When I disable the network time application Then the network time service should not be running + +Scenario: Set timezone + When I set the time zone to Africa/Abidjan + Then the time zone should be Africa/Abidjan diff --git a/functional_tests/step_definitions/application.py b/functional_tests/step_definitions/application.py index bcab8354c..794148222 100644 --- a/functional_tests/step_definitions/application.py +++ b/functional_tests/step_definitions/application.py @@ -47,6 +47,16 @@ def ntp_is_disabled(browser): application.disable(browser, 'ntp') +@when(parsers.parse('I set the time zone to {time_zone:S}')) +def time_zone_set(browser, time_zone): + application.time_zone_set(browser, time_zone) + + +@then(parsers.parse('the time zone should be {time_zone:S}')) +def time_zone_assert(browser, time_zone): + assert time_zone == application.time_zone_get(browser) + + @given(parsers.parse('the service discovery application is enabled')) def avahi_is_enabled(browser): application.enable(browser, 'avahi') diff --git a/functional_tests/support/application.py b/functional_tests/support/application.py index 4d5e6b6d0..49a6a0dd8 100644 --- a/functional_tests/support/application.py +++ b/functional_tests/support/application.py @@ -322,3 +322,16 @@ def ikiwiki_wiki_exists(browser): browser.find_link_by_href('/plinth/apps/ikiwiki/manage/').first.click() wiki = browser.find_link_by_href('/ikiwiki/wiki') return bool(wiki) + + +def time_zone_set(browser, time_zone): + """Set the system time zone.""" + interface.nav_to_module(browser, 'datetime') + browser.select('time_zone', time_zone) + interface.submit(browser, form_class='form-configuration') + + +def time_zone_get(browser): + """Set the system time zone.""" + interface.nav_to_module(browser, 'datetime') + return browser.find_by_name('time_zone').first.value