mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-03-18 09:10:49 +00:00
- Add pytest hooks to ignore all functional tests if pytest_bdd is not installed. - Update pytest hooks to skip tests in file named 'test_functional.py' if --include-functional argument is not provided. - Move functional_tests/install.py into plinth/tests/functional and update reference in Vagrantfile. - Move scenario files into individual app folders. Rename them after the app they are testing. Merge TODO items listed in todo.org into corresponding feature files. - Add test_functional.py in each app to build tests from the features file using pytest_bdd. - Move all step_definitions, support and data into plinth/tests/functional/. Include all step_definitions from conftest.py. Update to relative imports instead of absolute imports. Tests performed: - Run py.test-3 --collect-only shows all functional tests and lists 574 tests. No errors show that name of feature files are correct. The number says that all functional test features are included. - Remove pytest_bdd (or modify the import name) and run py.test-3 --collect-only skips collecting all functional tests and shows only 300+ tests. - Run functional tests for a few apps with py.test-3 --include-functional -m app. For storage, deluge. - Run unit tests with py.test-3. Functional tests are listed by skipped. Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org> Reviewed-by: Joseph Nuthalapati <njoseph@riseup.net>
91 lines
2.7 KiB
Python
91 lines
2.7 KiB
Python
# SPDX-License-Identifier: AGPL-3.0-or-later
|
|
|
|
from pytest_bdd import given, parsers, then, when
|
|
|
|
from ..support import config, interface
|
|
|
|
default_url = config['DEFAULT']['url']
|
|
|
|
|
|
@given("I'm a logged in user")
|
|
def logged_in_user(session_browser):
|
|
interface.login(session_browser, default_url,
|
|
config['DEFAULT']['username'],
|
|
config['DEFAULT']['password'])
|
|
|
|
|
|
@given("I'm a logged out user")
|
|
def logged_out_user(session_browser):
|
|
session_browser.visit(default_url + '/plinth/accounts/logout/')
|
|
|
|
|
|
@when("I log out")
|
|
def log_out_user(session_browser):
|
|
session_browser.visit(default_url + '/plinth/accounts/logout/')
|
|
|
|
|
|
@then(parsers.parse('I should be prompted for login'))
|
|
def prompted_for_login(session_browser):
|
|
assert interface.is_login_prompt(session_browser)
|
|
|
|
|
|
@given(parsers.parse("the user {name:w} doesn't exist"))
|
|
def new_user_does_not_exist(session_browser, name):
|
|
interface.delete_user(session_browser, name)
|
|
|
|
|
|
@given(parsers.parse('the user {name:w} exists'))
|
|
def test_user_exists(session_browser, name):
|
|
interface.nav_to_module(session_browser, 'users')
|
|
user_link = session_browser.find_link_by_href('/plinth/sys/users/' + name +
|
|
'/edit/')
|
|
if not user_link:
|
|
create_user(session_browser, name, 'secret123')
|
|
|
|
|
|
@when(
|
|
parsers.parse('I create a user named {name:w} with password {password:w}'))
|
|
def create_user(session_browser, name, password):
|
|
interface.create_user(session_browser, name, password)
|
|
|
|
|
|
@when(parsers.parse('I rename the user {old_name:w} to {new_name:w}'))
|
|
def rename_user(session_browser, old_name, new_name):
|
|
interface.rename_user(session_browser, old_name, new_name)
|
|
|
|
|
|
@when(parsers.parse('I delete the user {name:w}'))
|
|
def delete_user(session_browser, name):
|
|
interface.delete_user(session_browser, name)
|
|
|
|
|
|
@then(parsers.parse('{name:w} should be listed as a user'))
|
|
def new_user_is_listed(session_browser, name):
|
|
assert interface.is_user(session_browser, name)
|
|
|
|
|
|
@then(parsers.parse('{name:w} should not be listed as a user'))
|
|
def new_user_is_not_listed(session_browser, name):
|
|
assert not interface.is_user(session_browser, name)
|
|
|
|
|
|
@given('a sample local file')
|
|
def sample_local_file():
|
|
file_path, contents = interface.create_sample_local_file()
|
|
return dict(file_path=file_path, contents=contents)
|
|
|
|
|
|
@when('I go to the status logs page')
|
|
def help_go_to_status_logs(session_browser):
|
|
interface.go_to_status_logs(session_browser)
|
|
|
|
|
|
@then('status logs should be shown')
|
|
def help_status_logs_are_shown(session_browser):
|
|
assert interface.are_status_logs_shown(session_browser)
|
|
|
|
|
|
@given(parsers.parse("I'm on the {name:w} page"))
|
|
def go_to_module(session_browser, name):
|
|
interface.nav_to_module(session_browser, name)
|