File: test_functional.py

package info (click to toggle)
freedombox 26.3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 83,092 kB
  • sloc: python: 48,542; javascript: 1,730; xml: 481; makefile: 290; sh: 137; php: 32
file content (42 lines) | stat: -rw-r--r-- 1,269 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# SPDX-License-Identifier: AGPL-3.0-or-later
"""
Functional, browser based tests for config app.
"""

import pytest

from plinth.tests import functional

pytestmark = [pytest.mark.system, pytest.mark.essential, pytest.mark.config]


@pytest.fixture(scope='module', autouse=True)
def fixture_background(session_browser):
    """Login."""
    functional.login(session_browser)


def test_change_home_page(session_browser):
    """Test changing webserver home page."""
    functional.install(session_browser, 'syncthing')
    functional.app_enable(session_browser, 'syncthing')
    _set_home_page(session_browser, 'syncthing')

    _set_home_page(session_browser, 'plinth')
    assert _check_home_page_redirect(session_browser, 'plinth')


def _set_home_page(browser, home_page):
    if 'plinth' not in home_page and 'apache' not in home_page:
        home_page = 'shortcut-' + home_page

    functional.nav_to_module(browser, 'config')
    drop_down = browser.find_by_id('id_homepage')
    drop_down.select(home_page)
    functional.submit(browser, form_class='form-configuration')


def _check_home_page_redirect(browser, app_name):
    functional.visit(browser, '/')
    return browser.find_by_xpath(
        "//a[contains(@href, '/plinth/') and @title='FreedomBox']")