mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-04-15 09:51:21 +00:00
storage: tests: functional: Fix tests always getting skipped
- The method to check if we are running inside a container is not being called. Call it. - Also fix the assumption that tests and freedombox service run on the same machine. Be conservative and assume running in container if we can't determine the accurate state. Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org> Reviewed-by: Fioddor Superconcentrado <fioddor@gmail.com>
This commit is contained in:
parent
2b525a1930
commit
4b708214e4
@ -3,6 +3,7 @@
|
||||
Functional, browser based tests for storage app.
|
||||
"""
|
||||
import pytest
|
||||
|
||||
from plinth.tests import functional
|
||||
|
||||
pytestmark = [pytest.mark.system, pytest.mark.essential, pytest.mark.storage]
|
||||
@ -16,7 +17,7 @@ def fixture_background(session_browser):
|
||||
|
||||
def test_list_disks(session_browser):
|
||||
"""Test that root disk is shown on storage page."""
|
||||
if functional.running_inside_container:
|
||||
if functional.running_inside_container():
|
||||
pytest.skip('Storage doesn\'t work inside a container')
|
||||
else:
|
||||
functional.nav_to_module(session_browser, 'storage')
|
||||
|
||||
@ -439,9 +439,17 @@ def service_is_not_running(browser, app_name):
|
||||
|
||||
def running_inside_container():
|
||||
"""Check if freedombox is running inside a container"""
|
||||
# If the URL to connect to was overridden then assume that we are running
|
||||
# tests on a different machine than the machine running freedombox. Assume
|
||||
# running inside container to be conservative about tests.
|
||||
if config['DEFAULT']['url'] != 'https://localhost':
|
||||
return True
|
||||
|
||||
# If URL is not overridden then testing code and freedombox are running on
|
||||
# the same machine. Proceed with a proper test.
|
||||
result = subprocess.run(['systemd-detect-virt', '--container'],
|
||||
stdout=subprocess.PIPE)
|
||||
return bool(result.stdout.decode('utf-8').lower() != "none\n")
|
||||
stdout=subprocess.PIPE, check=False)
|
||||
return result.stdout.decode('utf-8').strip().lower() != 'none'
|
||||
|
||||
|
||||
##############################
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user