mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-11-29 08:25:10 +00:00
functional-tests: Merge plinth-tester into plinth
- Rename Plinth-tester to FreedomBox - Add pytest.ini to discover the root directory for tests easily - Update README to say that py.test should be run from functional_tests directory. - Add geckodriver.log to .gitignore Signed-off-by: Joseph Nuthalapati <njoseph@thoughtworks.com> Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
1 parent
73bac986e4
commit
0bdc2802f2
45 files changed
+2130
No files matched your search
@@ -0,0 +1,101 @@
|
||||
#
|
||||
# This file is part of Plinth-tester.
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as
|
||||
# published by the Free Software Foundation, either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
from support import config
|
||||
|
||||
sys_modules = [
|
||||
'avahi', 'cockpit', 'config', 'datetime', 'diagnostics', 'firewall',
|
||||
'letsencrypt', 'monkeysphere', 'names', 'networks', 'power', 'snapshot',
|
||||
'upgrades', 'users'
|
||||
]
|
||||
|
||||
default_url = config['DEFAULT']['url']
|
||||
|
||||
|
||||
def login(browser, url, username, password):
|
||||
browser.visit(url)
|
||||
if browser.find_by_id('logout-nojs'):
|
||||
return # already logged in
|
||||
|
||||
login_button = browser.find_link_by_href('/plinth/accounts/login/')
|
||||
if login_button:
|
||||
login_button.first.click()
|
||||
login_submit = browser.find_by_value('Login')
|
||||
if login_button:
|
||||
browser.fill('username', username)
|
||||
browser.fill('password', password)
|
||||
login_submit.click()
|
||||
else:
|
||||
browser.visit(default_url + '/plinth/firstboot/welcome')
|
||||
browser.find_by_value('Start Setup').click()
|
||||
create_admin_account(browser, 'tester', 'testingtesting')
|
||||
login(browser, url, username, password)
|
||||
|
||||
|
||||
def is_login_prompt(browser):
|
||||
return all(
|
||||
[browser.find_by_id('id_username'),
|
||||
browser.find_by_id('id_password')])
|
||||
|
||||
|
||||
def nav_to_module(browser, module):
|
||||
browser.find_link_by_href('/plinth/').first.click()
|
||||
if module in sys_modules:
|
||||
browser.find_link_by_href('/plinth/sys/').first.click()
|
||||
browser.find_link_by_href('/plinth/sys/' + module + '/').first.click()
|
||||
else:
|
||||
browser.find_link_by_href('/plinth/apps/').first.click()
|
||||
browser.find_link_by_href('/plinth/apps/' + module + '/').first.click()
|
||||
|
||||
|
||||
def submit(browser):
|
||||
browser.find_by_value('Submit').click()
|
||||
|
||||
|
||||
def create_user(browser, name, password):
|
||||
nav_to_module(browser, 'users')
|
||||
browser.find_link_by_href('/plinth/sys/users/create/').first.click()
|
||||
browser.find_by_id('id_username').fill(name)
|
||||
browser.find_by_id('id_password1').fill(password)
|
||||
browser.find_by_id('id_password2').fill(password)
|
||||
browser.find_by_value('Create User').click()
|
||||
|
||||
|
||||
def rename_user(browser, old_name, new_name):
|
||||
nav_to_module(browser, 'users')
|
||||
browser.find_link_by_href('/plinth/sys/users/' + old_name +
|
||||
'/edit/').first.click()
|
||||
browser.find_by_id('id_username').fill(new_name)
|
||||
browser.find_by_value('Save Changes').click()
|
||||
|
||||
|
||||
def delete_user(browser, name):
|
||||
nav_to_module(browser, 'users')
|
||||
browser.find_link_by_href('/plinth/sys/users/' + name +
|
||||
'/delete/').first.click()
|
||||
browser.find_by_value('Delete ' + name).click()
|
||||
|
||||
|
||||
def is_user(browser, name):
|
||||
nav_to_module(browser, 'users')
|
||||
return browser.is_text_present(name)
|
||||
|
||||
|
||||
def create_admin_account(browser, username, password):
|
||||
browser.find_by_id('id_username').fill(username)
|
||||
browser.find_by_id('id_password1').fill(password)
|
||||
browser.find_by_id('id_password2').fill(password)
|
||||
browser.find_by_value('Create Account').click()
|
||||
Reference in new issue
Block a user