mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-05-20 10:34:30 +00:00
snapshot: Add functional tests for setting configuration
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
parent
a5d66a1362
commit
2c1372c26d
@ -27,3 +27,8 @@ Scenario: Create a snapshot
|
||||
Given the list of snapshots is empty
|
||||
When I manually create a snapshot
|
||||
Then there should be 1 snapshot in the list
|
||||
|
||||
Scenario: Configure snapshots
|
||||
Given snapshots are configured with timeline snapshots disabled, software snapshots disabled, hourly limit 10, daily limit 3, weekly limit 2, monthly limit 2, yearly limit 0, delete old software snapshots 15
|
||||
When I configure snapshots with timeline snapshots enabled, software snapshots enabled, hourly limit 3, daily limit 2, weekly limit 1, monthly limit 1, yearly limit 1, delete old software snapshots 2
|
||||
Then snapshots should be configured with timeline snapshots enabled, software snapshots enabled, hourly limit 3, daily limit 2, weekly limit 1, monthly limit 1, yearly limit 1, delete old software snapshots 2
|
||||
|
||||
@ -97,6 +97,56 @@ def verify_snapshot_count(browser, count):
|
||||
assert num_snapshots == count
|
||||
|
||||
|
||||
@given(
|
||||
parsers.parse(
|
||||
'snapshots are configured with timeline snapshots '
|
||||
'{timeline_enabled:w}, software snapshots {software_enabled:w}, hourly '
|
||||
'limit {hourly:d}, daily limit {daily:d}, weekly limit {weekly:d}, '
|
||||
'monthly limit {monthly:d}, yearly limit {yearly:d}, delete old '
|
||||
'software snapshots {delete_old:d}'))
|
||||
def snapshot_given_set_configuration(browser, timeline_enabled,
|
||||
software_enabled, hourly, daily, weekly,
|
||||
monthly, yearly, delete_old):
|
||||
timeline_enabled = (timeline_enabled == 'enabled')
|
||||
software_enabled = (software_enabled == 'enabled')
|
||||
system.snapshot_set_configuration(browser, timeline_enabled,
|
||||
software_enabled, hourly, daily, weekly,
|
||||
monthly, yearly, delete_old)
|
||||
|
||||
|
||||
@when(
|
||||
parsers.parse(
|
||||
'I configure snapshots with timeline snapshots {timeline_enabled:w}, '
|
||||
'software snapshots {software_enabled:w}, hourly limit {hourly:d}, '
|
||||
'daily limit {daily:d}, weekly limit {weekly:d}, monthly limit '
|
||||
'{monthly:d}, yearly limit {yearly:d}, delete old software snapshots '
|
||||
'{delete_old:d}'))
|
||||
def snapshot_set_configuration(browser, timeline_enabled, software_enabled,
|
||||
hourly, daily, weekly, monthly, yearly,
|
||||
delete_old):
|
||||
timeline_enabled = (timeline_enabled == 'enabled')
|
||||
software_enabled = (software_enabled == 'enabled')
|
||||
system.snapshot_set_configuration(browser, timeline_enabled,
|
||||
software_enabled, hourly, daily, weekly,
|
||||
monthly, yearly, delete_old)
|
||||
|
||||
|
||||
@then(
|
||||
parsers.parse(
|
||||
'snapshots should be configured with timeline snapshots '
|
||||
'{timeline_enabled:w}, software snapshots {software_enabled:w}, hourly '
|
||||
'limit {hourly:d}, daily limit {daily:d}, weekly limit {weekly:d}, '
|
||||
'monthly limit {monthly:d}, yearly limit {yearly:d}, delete old '
|
||||
'software snapshots {delete_old:d}'))
|
||||
def snapshot_assert_configuration(browser, timeline_enabled, software_enabled,
|
||||
hourly, daily, weekly, monthly, yearly,
|
||||
delete_old):
|
||||
timeline_enabled = (timeline_enabled == 'enabled')
|
||||
software_enabled = (software_enabled == 'enabled')
|
||||
assert (timeline_enabled, software_enabled, hourly, daily, weekly, monthly,
|
||||
yearly, delete_old) == system.snapshot_get_configuration(browser)
|
||||
|
||||
|
||||
@then(parsers.parse('the default app should be {app_name:w}'))
|
||||
def default_app_should_be(browser, app_name):
|
||||
assert system.check_home_page_redirect(browser, app_name)
|
||||
|
||||
@ -95,6 +95,37 @@ def get_snapshot_count(browser):
|
||||
return len(browser.find_by_xpath('//tr')) - 1
|
||||
|
||||
|
||||
def snapshot_set_configuration(browser, timeline_enabled, software_enabled,
|
||||
hourly, daily, weekly, monthly, yearly,
|
||||
delete_old):
|
||||
"""Set the configuration for snapshots."""
|
||||
nav_to_module(browser, 'snapshot')
|
||||
browser.find_by_name('enable_timeline_snapshots').select(
|
||||
'yes' if timeline_enabled else 'no')
|
||||
browser.find_by_name('enable_software_snapshots').select(
|
||||
'yes' if software_enabled else 'no')
|
||||
browser.find_by_name('hourly_limit').fill(hourly)
|
||||
browser.find_by_name('daily_limit').fill(daily)
|
||||
browser.find_by_name('weekly_limit').fill(weekly)
|
||||
browser.find_by_name('monthly_limit').fill(monthly)
|
||||
browser.find_by_name('yearly_limit').fill(yearly)
|
||||
browser.find_by_name('number_min_age').fill(delete_old)
|
||||
submit(browser)
|
||||
|
||||
|
||||
def snapshot_get_configuration(browser):
|
||||
"""Return the current configuration for snapshots."""
|
||||
nav_to_module(browser, 'snapshot')
|
||||
return (browser.find_by_name('enable_timeline_snapshots').value == 'yes',
|
||||
browser.find_by_name('enable_software_snapshots').value == 'yes',
|
||||
int(browser.find_by_name('hourly_limit').value),
|
||||
int(browser.find_by_name('daily_limit').value),
|
||||
int(browser.find_by_name('weekly_limit').value),
|
||||
int(browser.find_by_name('monthly_limit').value),
|
||||
int(browser.find_by_name('yearly_limit').value),
|
||||
int(browser.find_by_name('number_min_age').value))
|
||||
|
||||
|
||||
def check_home_page_redirect(browser, app_name):
|
||||
browser.visit(config['DEFAULT']['url'])
|
||||
return browser.find_by_xpath(
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user