tests: functional: Refactor install/setup fixture for apps

- Fixes an issue with zoph not being setup after uninstall+install setup and
makes a test pass.

- Some failures exist but don't seem related to this change.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
Sunil Mohan Adapa 2024-03-08 19:38:59 -08:00 committed by James Valleroy
parent 8096c14b14
commit 5dbf890881
No known key found for this signature in database
GPG Key ID: 77C0C75E7B650808
7 changed files with 27 additions and 31 deletions

View File

@ -21,7 +21,10 @@ class TestMatrixSynapseApp(functional.BaseAppTests):
"""Setup the app.""" """Setup the app."""
functional.login(session_browser) functional.login(session_browser)
functional.set_domain_name(session_browser, 'mydomain.example') functional.set_domain_name(session_browser, 'mydomain.example')
functional.install(session_browser, self.app_name)
def install_and_setup(self, session_browser):
"""Install the app and run setup."""
super().install_and_setup(session_browser)
functional.app_select_domain_name(session_browser, self.app_name, functional.app_select_domain_name(session_browser, self.app_name,
'mydomain.example') 'mydomain.example')

View File

@ -20,12 +20,9 @@ class TestMediawikiApp(functional.BaseAppTests):
has_service = False has_service = False
has_web = True has_web = True
@pytest.fixture(scope='class', autouse=True) def install_and_setup(self, session_browser):
def fixture_setup(self, session_browser): """Install the app and run setup."""
"""Setup the app.""" super().install_and_setup(session_browser)
functional.login(session_browser)
functional.install(session_browser, 'mediawiki')
functional.app_enable(session_browser, 'mediawiki')
_set_domain(session_browser) _set_domain(session_browser)
_set_admin_password(session_browser, 'whatever123') _set_admin_password(session_browser, 'whatever123')

View File

@ -17,12 +17,9 @@ class TestShaarliApp(functional.BaseAppTests):
has_service = False has_service = False
has_web = True has_web = True
@pytest.fixture(scope='class', autouse=True) def install_and_setup(self, session_browser):
def fixture_setup(self, session_browser): """Install the app and set it up if needed."""
"""Setup the app.""" super().install_and_setup(session_browser)
functional.login(session_browser)
functional.install(session_browser, self.app_name)
functional.app_enable(session_browser, self.app_name)
self._shaarli_is_setup(session_browser) self._shaarli_is_setup(session_browser)
def _shaarli_is_setup(self, session_browser): def _shaarli_is_setup(self, session_browser):

View File

@ -15,11 +15,9 @@ class TestShadowsocksApp(functional.BaseAppTests):
has_service = True has_service = True
has_web = False has_web = False
@pytest.fixture(scope='class', autouse=True) def install_and_setup(self, session_browser):
def fixture_setup(self, session_browser): """Install the app and run setup."""
"""Setup the app.""" super().install_and_setup(session_browser)
functional.login(session_browser)
functional.install(session_browser, 'shadowsocks')
_configure(session_browser, 'example.com', 'fakepassword') _configure(session_browser, 'example.com', 'fakepassword')
@pytest.mark.backups @pytest.mark.backups

View File

@ -15,11 +15,9 @@ class TestShadowsocksServerApp(functional.BaseAppTests):
has_service = True has_service = True
has_web = False has_web = False
@pytest.fixture(scope='class', autouse=True) def install_and_setup(self, session_browser):
def fixture_setup(self, session_browser): """Install the app and run setup."""
"""Setup the app.""" super().install_and_setup(session_browser)
functional.login(session_browser)
functional.install(session_browser, 'shadowsocksserver')
_configure(session_browser, 'fakepassword') _configure(session_browser, 'fakepassword')
@pytest.mark.backups @pytest.mark.backups

View File

@ -15,17 +15,16 @@ class TestZophApp(functional.BaseAppTests):
has_service = False has_service = False
has_web = True has_web = True
@pytest.fixture(scope='class', autouse=True) def install_and_setup(self, session_browser):
def fixture_setup(self, session_browser): """Install the app and run setup."""
"""Setup the app.""" super().install_and_setup(session_browser)
functional.login(session_browser)
functional.install(session_browser, self.app_name)
self._zoph_is_setup(session_browser) self._zoph_is_setup(session_browser)
def _zoph_is_setup(self, session_browser): def _zoph_is_setup(self, session_browser):
"""Click setup button on the setup page.""" """Click setup button on the setup page."""
functional.nav_to_module(session_browser, self.app_name) functional.nav_to_module(session_browser, self.app_name)
functional.submit(session_browser, form_class='form-configuration') if session_browser.find_by_css('.form-configuration'):
functional.submit(session_browser, form_class='form-configuration')
def assert_app_running(self, session_browser): def assert_app_running(self, session_browser):
assert functional.app_is_enabled(session_browser, self.app_name) assert functional.app_is_enabled(session_browser, self.app_name)

View File

@ -675,11 +675,15 @@ class BaseAppTests:
if self.has_web: if self.has_web:
assert not is_available(session_browser, self.app_name) assert not is_available(session_browser, self.app_name)
def install_and_setup(self, session_browser):
"""Install the app and set it up if needed."""
install(session_browser, self.app_name)
@pytest.fixture(autouse=True) @pytest.fixture(autouse=True)
def fixture_background(self, session_browser): def fixture_background(self, session_browser):
"""Login, install, and enable the app.""" """Login, install, and enable the app."""
login(session_browser) login(session_browser)
install(session_browser, self.app_name) self.install_and_setup(session_browser)
app_enable(session_browser, self.app_name) app_enable(session_browser, self.app_name)
yield yield
login(session_browser) login(session_browser)
@ -728,4 +732,4 @@ class BaseAppTests:
uninstall(session_browser, self.app_name) uninstall(session_browser, self.app_name)
assert not is_installed(session_browser, self.app_name) assert not is_installed(session_browser, self.app_name)
install(session_browser, self.app_name) self.install_and_setup(session_browser)