mirror of
https://github.com/borgbase/vorta
synced 2024-12-22 15:57:34 +00:00
b015368fee
Move existing tests into subfolder `tests/unit`. Write integration tests that actually run the installed borg executable. Those tests can be found in `tests/integration`. Those pytest fixtures that are the same for both kinds of tests remain in `tests/conftest.py`. The others can be found in `tests/integration/conftest.py` or `tests/unit/conftest.py`. This adds nox to the project and configures it to run the tests with different borg versions. This also updates the ci workflow to run the integration tests using nox. * noxfile.py : Run pytest with a matrix of borg versions OR a specific borg version * Makefile : Run using nox. Add phonies `test-unit` and `test-integration`. * tests/conftest.py : Move some fixtures/functions to `tests/unit/conftest.py`. * tests/test_*.py --> tests/unit/ : Move unittests and assets into subfolder * tests/integration/ : Write integration tests. * requirements.d/dev.txt: Add `nox` and `pkgconfig`. The latter is needed for installing new borg versions. * .github/actions/setup/action.yml : Update to install pre-commit and nox when needed. The action now no longer installs Vorta. * .github/actions/install-dependencies/action.yml : Install system deps of borg with this new composite action. * .github/workflows/test.yml : Rename `test` ci to `test-unit` and update it for the new test setup. Implement `test-integration` ci. Signed-off-by: Chirag Aggarwal <thechiragaggarwal@gmail.com>
36 lines
998 B
Python
36 lines
998 B
Python
import os
|
|
import sys
|
|
|
|
import pytest
|
|
import vorta
|
|
import vorta.application
|
|
import vorta.borg.jobs_manager
|
|
from peewee import SqliteDatabase
|
|
|
|
|
|
def pytest_configure(config):
|
|
sys._called_from_test = True
|
|
pytest._wait_defaults = {'timeout': 20000}
|
|
os.environ['LANG'] = 'en' # Ensure we test an English UI
|
|
|
|
|
|
@pytest.fixture(scope='session')
|
|
def qapp(tmpdir_factory):
|
|
# DB is required to init QApplication. New DB used for every test.
|
|
tmp_db = tmpdir_factory.mktemp('Vorta').join('settings.sqlite')
|
|
mock_db = SqliteDatabase(str(tmp_db))
|
|
vorta.store.connection.init_db(mock_db)
|
|
|
|
# Needs to be disabled before calling VortaApp()
|
|
if sys.platform == 'darwin':
|
|
cfg = vorta.store.models.SettingsModel.get(key='check_full_disk_access')
|
|
cfg.value = False
|
|
cfg.save()
|
|
|
|
from vorta.application import VortaApp
|
|
|
|
qapp = VortaApp([]) # Only init QApplication once to avoid segfaults while testing.
|
|
|
|
yield qapp
|
|
mock_db.close()
|
|
qapp.quit()
|