functional tests: Make tests compatible with pytest-bdd v4.0

- In pytest-bdd v4.0, given steps are no longer fixtures. Mark steps
  as fixtures when needed.
- Remove 'test_' prefix from step function names, so that pytest doesn't
  run those twice.

Test performed:
- Run all tests, no more pytest-bdd v4.0 related failures
- All the openvpn, snapshot and users module tests pass

Signed-off-by: Veiko Aasa <veiko17@disroot.org>
Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
This commit is contained in:
Veiko Aasa 2020-12-29 12:33:40 +02:00 committed by Sunil Mohan Adapa
parent 0a10d02605
commit 1ea6b0b176
No known key found for this signature in database
GPG Key ID: 43EA1CFF0AA7C5F2
3 changed files with 7 additions and 8 deletions

View File

@ -13,7 +13,7 @@ base_url = functional.config['DEFAULT']['URL']
shortcut_href = '?selected=shortcut-openvpn'
@given('I download openvpn profile')
@given('I download openvpn profile', target_fixture='openvpn_profile')
def openvpn_download_profile(session_browser):
return _download_profile(session_browser)
@ -31,10 +31,9 @@ def openvpn_app_not_on_front_page(session_browser):
@then('the openvpn profile downloaded should be same as before')
def openvpn_profile_download_compare(session_browser,
openvpn_download_profile):
def openvpn_profile_download_compare(session_browser, openvpn_profile):
new_profile = _download_profile(session_browser)
assert openvpn_download_profile == new_profile
assert openvpn_profile == new_profile
def _download_profile(browser):

View File

@ -18,7 +18,7 @@ def is_snapshots_supported(session_browser):
assert True
@given('the list of snapshots is empty')
@given('the list of snapshots is empty', target_fixture='empty_snapshots_list')
def empty_snapshots_list(session_browser):
_delete_all(session_browser)
return _get_count(session_browser)

View File

@ -58,7 +58,7 @@ def new_user_does_not_exist(session_browser, name):
@given(parsers.parse('the user {name:w} exists'))
def test_user_exists(session_browser, name):
def user_exists(session_browser, name):
functional.nav_to_module(session_browser, 'users')
user_link = session_browser.find_link_by_href(
'/plinth/sys/users/{}/edit/'.format(name))
@ -71,7 +71,7 @@ def test_user_exists(session_browser, name):
@given(
parsers.parse('the admin user {name:w} with password {password:w} exists'))
def test_admin_user_exists(session_browser, name, password):
def admin_user_exists(session_browser, name, password):
functional.nav_to_module(session_browser, 'users')
user_link = session_browser.find_link_by_href('/plinth/sys/users/' + name +
'/edit/')
@ -82,7 +82,7 @@ def test_admin_user_exists(session_browser, name, password):
@given(parsers.parse('the user {name:w} with password {password:w} exists'))
def user_exists(session_browser, name, password):
def user_exists_with_password(session_browser, name, password):
functional.nav_to_module(session_browser, 'users')
user_link = session_browser.find_link_by_href('/plinth/sys/users/' + name +
'/edit/')