2021-03-01 07:25:31 +00:00
|
|
|
import os
|
2018-11-30 00:40:18 +00:00
|
|
|
import sys
|
2023-05-01 08:28:11 +00:00
|
|
|
|
2022-02-20 06:04:12 +00:00
|
|
|
import pytest
|
2018-11-01 06:01:44 +00:00
|
|
|
import vorta
|
2021-06-05 11:15:38 +00:00
|
|
|
import vorta.application
|
2021-11-12 07:05:31 +00:00
|
|
|
import vorta.borg.jobs_manager
|
2023-05-01 08:28:11 +00:00
|
|
|
from peewee import SqliteDatabase
|
2018-11-01 06:01:44 +00:00
|
|
|
|
2018-11-05 10:30:59 +00:00
|
|
|
|
2018-11-27 11:33:16 +00:00
|
|
|
def pytest_configure(config):
|
|
|
|
sys._called_from_test = True
|
2021-02-17 02:14:58 +00:00
|
|
|
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')
|
2021-11-16 06:32:40 +00:00
|
|
|
mock_db = SqliteDatabase(str(tmp_db))
|
2021-11-17 09:14:11 +00:00
|
|
|
vorta.store.connection.init_db(mock_db)
|
2021-02-17 02:14:58 +00:00
|
|
|
|
2023-04-17 10:17:01 +00:00
|
|
|
# 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()
|
|
|
|
|
2021-02-17 02:14:58 +00:00
|
|
|
from vorta.application import VortaApp
|
2022-08-15 17:02:40 +00:00
|
|
|
|
2021-02-17 02:14:58 +00:00
|
|
|
qapp = VortaApp([]) # Only init QApplication once to avoid segfaults while testing.
|
|
|
|
|
|
|
|
yield qapp
|
2021-03-01 07:25:31 +00:00
|
|
|
mock_db.close()
|
2021-02-22 01:45:43 +00:00
|
|
|
qapp.quit()
|