vorta/tests/conftest.py

44 lines
1.0 KiB
Python
Raw Normal View History

2018-11-01 06:01:44 +00:00
import pytest
import peewee
import vorta
from vorta.application import VortaApp
2018-11-06 06:47:04 +00:00
from vorta.models import RepoModel, SourceDirModel
2018-11-01 06:01:44 +00:00
def pytest_configure(config):
import sys
sys._called_from_test = True
2018-11-01 06:01:44 +00:00
@pytest.fixture()
2018-11-06 06:47:04 +00:00
def app(tmpdir, qtbot):
2018-11-01 06:01:44 +00:00
tmp_db = tmpdir.join('settings.sqlite')
mock_db = peewee.SqliteDatabase(str(tmp_db))
vorta.models.init_db(mock_db)
2018-11-06 06:47:04 +00:00
app = VortaApp([])
qtbot.addWidget(app.main_window)
return app
2018-11-06 06:47:04 +00:00
@pytest.fixture()
def app_with_repo(app):
2018-11-17 10:12:00 +00:00
profile = app.main_window.current_profile
2018-11-06 06:47:04 +00:00
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
2018-11-06 06:47:04 +00:00
@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
2018-11-06 06:47:04 +00:00
return _read_json