1
0
Fork 0
mirror of https://github.com/borgbase/vorta synced 2024-12-24 08:45:34 +00:00
vorta/tests/conftest.py
Manuel Riel 7b881953a1
Extract cmd (#61)
* Add extract feature (#26), fix stdout/err blocking (#21)
* Other small fixes.
2018-11-27 19:33:16 +08:00

43 lines
1 KiB
Python

import pytest
import peewee
import vorta
from vorta.application import VortaApp
from vorta.models import RepoModel, SourceDirModel
def pytest_configure(config):
import sys
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)
app = VortaApp([])
qtbot.addWidget(app.main_window)
return app
@pytest.fixture()
def app_with_repo(app):
profile = app.main_window.current_profile
new_repo = RepoModel(url='i0fi93@i593.repo.borgbase.com:repo')
new_repo.save()
profile.repo = new_repo
profile.save()
source_dir = SourceDirModel(dir='/tmp', repo=new_repo)
source_dir.save()
return app
@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