snapshot: Fix failing tests

Signed-off-by: Joseph Nuthalapati <njoseph@thoughtworks.com>
Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
This commit is contained in:
Joseph Nuthalapati 2019-01-08 18:33:20 +05:30 committed by Sunil Mohan Adapa
parent 4fdd68cb3b
commit 0b9922434c
No known key found for this signature in database
GPG Key ID: 43EA1CFF0AA7C5F2
3 changed files with 43 additions and 41 deletions

View File

@ -29,13 +29,13 @@ Scenario: 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
Given snapshots are configured with free_space 30, timeline snapshots disabled, software snapshots disabled, hourly limit 10, daily limit 3, weekly limit 2, monthly limit 2, yearly limit 0
When I configure snapshots with free_space 20, timeline snapshots enabled, software snapshots enabled, hourly limit 3, daily limit 2, weekly limit 1, monthly limit 1, yearly limit 1
Then snapshots should be configured with free_space 20, timeline snapshots enabled, software snapshots enabled, hourly limit 3, daily limit 2, weekly limit 1, monthly limit 1, yearly limit 1
Scenario: Backup and restore snapshot
When I configure snapshots 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 free_space 30, timeline snapshots disabled, software snapshots disabled, hourly limit 10, daily limit 3, weekly limit 2, monthly limit 2, yearly limit 0
And I create a backup of the snapshot app data
And 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
And I configure snapshots with free_space 20, timeline snapshots enabled, software snapshots enabled, hourly limit 3, daily limit 2, weekly limit 1, monthly limit 1, yearly limit 1
And I restore the snapshot app data backup
Then snapshots should be 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
Then snapshots should be configured with free_space 30, timeline snapshots disabled, software snapshots disabled, hourly limit 10, daily limit 3, weekly limit 2, monthly limit 2, yearly limit 0

View File

@ -108,52 +108,54 @@ def verify_snapshot_count(browser, 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,
'snapshots are configured with free_space {free_space:d}, 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}'))
def snapshot_given_set_configuration(browser, free_space, timeline_enabled,
software_enabled, hourly, daily, weekly,
monthly, yearly, delete_old):
monthly, yearly):
timeline_enabled = (timeline_enabled == 'enabled')
software_enabled = (software_enabled == 'enabled')
system.snapshot_set_configuration(browser, timeline_enabled,
system.snapshot_set_configuration(browser, free_space, timeline_enabled,
software_enabled, hourly, daily, weekly,
monthly, yearly, delete_old)
monthly, yearly)
@when(
parsers.parse(
'I configure snapshots with timeline snapshots {timeline_enabled:w}, '
'I configure snapshots with free_space {free_space:d}, '
'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):
'{monthly:d}, yearly limit {yearly:d}'))
def snapshot_set_configuration(browser, free_space, timeline_enabled,
software_enabled, hourly, daily, weekly,
monthly, yearly):
timeline_enabled = (timeline_enabled == 'enabled')
software_enabled = (software_enabled == 'enabled')
system.snapshot_set_configuration(browser, timeline_enabled,
system.snapshot_set_configuration(browser, free_space, timeline_enabled,
software_enabled, hourly, daily, weekly,
monthly, yearly, delete_old)
monthly, yearly)
@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):
'snapshots should be configured with free_space {free_space:d}, '
'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}'))
def snapshot_assert_configuration(browser, free_space, timeline_enabled,
software_enabled, hourly, daily, weekly,
monthly, yearly):
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)
print(system.snapshot_get_configuration(browser))
assert (free_space, timeline_enabled, software_enabled, hourly, daily,
weekly, monthly,
yearly) == system.snapshot_get_configuration(browser)
@then(parsers.parse('the default app should be {app_name:w}'))
@ -360,4 +362,4 @@ def open_main_page(browser):
@then(parsers.parse('the main page should be shown'))
def main_page_is_shown(browser):
assert(browser.url.endswith('/plinth/'))
assert (browser.url.endswith('/plinth/'))

View File

@ -102,11 +102,12 @@ 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):
def snapshot_set_configuration(browser, free_space, timeline_enabled,
software_enabled, hourly, daily, weekly,
monthly, yearly):
"""Set the configuration for snapshots."""
nav_to_module(browser, 'snapshot')
browser.find_by_name('free_space').select(free_space / 100)
browser.find_by_name('enable_timeline_snapshots').select(
'yes' if timeline_enabled else 'no')
browser.find_by_name('enable_software_snapshots').select(
@ -116,21 +117,20 @@ def snapshot_set_configuration(browser, timeline_enabled, software_enabled,
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',
return (int(float(browser.find_by_name('free_space').value) * 100),
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))
int(browser.find_by_name('yearly_limit').value))
def check_home_page_redirect(browser, app_name):