1
0
Fork 0
mirror of https://github.com/borgbase/vorta synced 2025-01-03 05:36:19 +00:00
vorta/tests/conftest.py
Manuel Riel 3c519e4928
v0.5.3 (#80)
* Apply selection status to children in restore-dialog. Fixes #69

* Backup triggered from system tray wont use correct profile. Fixes #78

* Use the term FILE if both FILE or FOLDER is meant. Fixes #55

* Implement update check on/off setting for macOS

* Implement autostart setting for macOS. Fixes #56
2018-12-05 17:05:47 +08:00

61 lines
1.5 KiB
Python

import pytest
import peewee
import sys
from datetime import datetime as dt
import vorta
from vorta.application import VortaApp
from vorta.models import RepoModel, SourceFileModel, ArchiveModel, BackupProfileModel
def pytest_configure(config):
sys._called_from_test = True
@pytest.fixture
def app(tmpdir, qtbot):
tmp_db = tmpdir.join('settings.sqlite')
mock_db = peewee.SqliteDatabase(str(tmp_db))
vorta.models.init_db(mock_db)
new_repo = RepoModel(url='i0fi93@i593.repo.borgbase.com:repo')
new_repo.save()
profile = BackupProfileModel.get(id=1)
profile.repo = new_repo.id
profile.save()
test_archive = ArchiveModel(snapshot_id='99999', name='test-archive', time=dt(2000, 1, 1, 0, 0), repo=1)
test_archive.save()
source_dir = SourceFileModel(dir='/tmp/another', repo=new_repo)
source_dir.save()
app = VortaApp([])
app.main_window.show()
qtbot.addWidget(app.main_window)
return app
@pytest.fixture
def choose_file_dialog(*args):
class MockFileDialog:
def __init__(self, *args, **kwargs):
pass
def open(self, func):
func()
def selectedFiles(self):
return ['/tmp']
return MockFileDialog
@pytest.fixture
def borg_json_output():
def _read_json(subcommand):
stdout = open(f'tests/borg_json_output/{subcommand}_stdout.json')
stderr = open(f'tests/borg_json_output/{subcommand}_stderr.json')
return stdout, stderr
return _read_json