mirror of
https://github.com/borgbase/vorta
synced 2025-01-31 03:41:12 +00:00
Add test for scheduler tab.
This commit is contained in:
parent
6e4fcb9583
commit
ef46cb91d6
6 changed files with 56 additions and 24 deletions
1
MANIFEST.in
Normal file
1
MANIFEST.in
Normal file
|
@ -0,0 +1 @@
|
|||
recursive-exclude tests *
|
|
@ -20,6 +20,7 @@ Missing features: (PRs welcome)
|
|||
- [ ] Repo pruning
|
||||
- [ ] Repo checking
|
||||
- [ ] Full test coverage
|
||||
- [ ] Use static type checks via mypy
|
||||
- [ ] Packaging for Linux
|
||||
|
||||
## Installation and Download
|
||||
|
@ -48,7 +49,7 @@ Then run via
|
|||
$ vorta
|
||||
```
|
||||
|
||||
Qt Creator is used to edit views. Install using Homebrew and then open the .ui files in `vorta/UI`:
|
||||
Qt Creator is used to edit views. Install from [their site](https://www.qt.io/download) or using Homebrew and then open the .ui files in `vorta/UI`:
|
||||
```
|
||||
$ brew cask install qt-creator
|
||||
$ brew install qt
|
||||
|
@ -62,7 +63,7 @@ $ pyinstaller --clean --noconfirm vorta.spec
|
|||
### Testing (work in progress)
|
||||
Tests are in the folder `/tests`. Testing happens at the level of UI components. Calls to `borg` are mocked and can be replaced with some example json-output. To run tests:
|
||||
```
|
||||
$ python setup.py test
|
||||
$ pytest
|
||||
```
|
||||
|
||||
## Privacy Policy
|
||||
|
@ -78,5 +79,5 @@ $ python setup.py test
|
|||
## License and Credits
|
||||
- Licensed under GPLv3. See LICENSE.txt for details.
|
||||
- Uses the excellent [BorgBackup](https://www.borgbackup.org)
|
||||
- Based on PyQt and Qt.
|
||||
- Based on [PyQt](https://riverbankcomputing.com/software/pyqt/intro) and [Qt](https://www.qt.io).
|
||||
- Icons by [FontAwesome](https://fontawesome.com)
|
||||
|
|
|
@ -23,9 +23,6 @@ long_description = file: README.md
|
|||
long_description_content_type = text/markdown
|
||||
license_file = LICENSE.txt
|
||||
|
||||
[aliases]
|
||||
test=pytest
|
||||
|
||||
[options]
|
||||
python_requires = >= 3.6
|
||||
setup_requires =
|
||||
|
@ -50,6 +47,7 @@ tests =
|
|||
pytest
|
||||
pytest-qt
|
||||
pytest-mock
|
||||
pytest-faulthandler
|
||||
mypy
|
||||
mypy-extensions
|
||||
|
||||
|
@ -59,7 +57,7 @@ gui_scripts =
|
|||
|
||||
|
||||
[tool:pytest]
|
||||
addopts = -s
|
||||
addopts = -vs
|
||||
testpaths = tests
|
||||
qt_default_raising = true
|
||||
filterwarnings =
|
||||
|
|
19
tests/fixtures.py
Normal file
19
tests/fixtures.py
Normal file
|
@ -0,0 +1,19 @@
|
|||
|
||||
import pytest
|
||||
import peewee
|
||||
|
||||
import vorta
|
||||
from vorta.application import VortaApp
|
||||
|
||||
@pytest.fixture()
|
||||
def app(tmpdir):
|
||||
tmp_db = tmpdir.join('settings.sqlite')
|
||||
mock_db = peewee.SqliteDatabase(str(tmp_db))
|
||||
vorta.models.init_db(mock_db)
|
||||
return VortaApp([])
|
||||
|
||||
|
||||
@pytest.fixture()
|
||||
def main(app):
|
||||
main = app.main_window
|
||||
return main
|
|
@ -1,30 +1,14 @@
|
|||
|
||||
import pytest
|
||||
import io
|
||||
import peewee
|
||||
from PyQt5 import QtCore
|
||||
|
||||
import vorta.borg_runner
|
||||
import vorta.models
|
||||
from vorta.application import VortaApp
|
||||
from vorta.views.repo_add import AddRepoWindow
|
||||
from vorta.models import EventLogModel, RepoModel
|
||||
|
||||
|
||||
@pytest.fixture()
|
||||
def app(tmpdir):
|
||||
tmp_db = tmpdir.join('settings.sqlite')
|
||||
mock_db = peewee.SqliteDatabase(str(tmp_db))
|
||||
vorta.models.init_db(mock_db)
|
||||
return VortaApp([])
|
||||
|
||||
|
||||
@pytest.fixture()
|
||||
def main(app, qtbot):
|
||||
main = app.main_window
|
||||
qtbot.addWidget(main)
|
||||
return main
|
||||
|
||||
from .fixtures import *
|
||||
|
||||
def test_repo_tab(main, qtbot):
|
||||
qtbot.mouseClick(main.createStartBtn, QtCore.Qt.LeftButton)
|
||||
|
|
29
tests/test_schedule.py
Normal file
29
tests/test_schedule.py
Normal file
|
@ -0,0 +1,29 @@
|
|||
from datetime import datetime as dt, date, time
|
||||
from PyQt5 import QtCore
|
||||
|
||||
from vorta.views.schedule_tab import ScheduleTab
|
||||
|
||||
from .fixtures import app, main
|
||||
|
||||
def test_schedule_tab(main, qtbot):
|
||||
tab = ScheduleTab(main.scheduleTabSlot)
|
||||
qtbot.addWidget(tab)
|
||||
qtbot.mouseClick(tab.scheduleApplyButton, QtCore.Qt.LeftButton)
|
||||
assert tab.nextBackupDateTimeLabel.text() == 'Manual Backups'
|
||||
|
||||
tab.scheduleIntervalRadio.setChecked(True)
|
||||
tab.scheduleIntervalHours.setValue(5)
|
||||
tab.scheduleIntervalMinutes.setValue(10)
|
||||
qtbot.mouseClick(tab.scheduleApplyButton, QtCore.Qt.LeftButton)
|
||||
assert tab.nextBackupDateTimeLabel.text().startswith('20')
|
||||
|
||||
tab.scheduleOffRadio.setChecked(True)
|
||||
qtbot.mouseClick(tab.scheduleApplyButton, QtCore.Qt.LeftButton)
|
||||
assert tab.nextBackupDateTimeLabel.text() == 'Manual Backups'
|
||||
|
||||
tab.scheduleFixedRadio.setChecked(True)
|
||||
tab.scheduleFixedTime.setTime(QtCore.QTime(23, 59))
|
||||
qtbot.mouseClick(tab.scheduleApplyButton, QtCore.Qt.LeftButton)
|
||||
next_backup = dt.combine(date.today(), time(23, 59))
|
||||
assert tab.nextBackupDateTimeLabel.text() == next_backup.strftime('%Y-%m-%d %H:%M')
|
||||
|
Loading…
Reference in a new issue