mirror of https://github.com/borgbase/vorta
Add test for scheduler tab.
This commit is contained in:
parent
6e4fcb9583
commit
ef46cb91d6
|
@ -0,0 +1 @@
|
||||||
|
recursive-exclude tests *
|
|
@ -20,6 +20,7 @@ Missing features: (PRs welcome)
|
||||||
- [ ] Repo pruning
|
- [ ] Repo pruning
|
||||||
- [ ] Repo checking
|
- [ ] Repo checking
|
||||||
- [ ] Full test coverage
|
- [ ] Full test coverage
|
||||||
|
- [ ] Use static type checks via mypy
|
||||||
- [ ] Packaging for Linux
|
- [ ] Packaging for Linux
|
||||||
|
|
||||||
## Installation and Download
|
## Installation and Download
|
||||||
|
@ -48,7 +49,7 @@ Then run via
|
||||||
$ vorta
|
$ 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 cask install qt-creator
|
||||||
$ brew install qt
|
$ brew install qt
|
||||||
|
@ -62,7 +63,7 @@ $ pyinstaller --clean --noconfirm vorta.spec
|
||||||
### Testing (work in progress)
|
### 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:
|
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
|
## Privacy Policy
|
||||||
|
@ -78,5 +79,5 @@ $ python setup.py test
|
||||||
## License and Credits
|
## License and Credits
|
||||||
- Licensed under GPLv3. See LICENSE.txt for details.
|
- Licensed under GPLv3. See LICENSE.txt for details.
|
||||||
- Uses the excellent [BorgBackup](https://www.borgbackup.org)
|
- 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)
|
- Icons by [FontAwesome](https://fontawesome.com)
|
||||||
|
|
|
@ -23,9 +23,6 @@ long_description = file: README.md
|
||||||
long_description_content_type = text/markdown
|
long_description_content_type = text/markdown
|
||||||
license_file = LICENSE.txt
|
license_file = LICENSE.txt
|
||||||
|
|
||||||
[aliases]
|
|
||||||
test=pytest
|
|
||||||
|
|
||||||
[options]
|
[options]
|
||||||
python_requires = >= 3.6
|
python_requires = >= 3.6
|
||||||
setup_requires =
|
setup_requires =
|
||||||
|
@ -50,6 +47,7 @@ tests =
|
||||||
pytest
|
pytest
|
||||||
pytest-qt
|
pytest-qt
|
||||||
pytest-mock
|
pytest-mock
|
||||||
|
pytest-faulthandler
|
||||||
mypy
|
mypy
|
||||||
mypy-extensions
|
mypy-extensions
|
||||||
|
|
||||||
|
@ -59,7 +57,7 @@ gui_scripts =
|
||||||
|
|
||||||
|
|
||||||
[tool:pytest]
|
[tool:pytest]
|
||||||
addopts = -s
|
addopts = -vs
|
||||||
testpaths = tests
|
testpaths = tests
|
||||||
qt_default_raising = true
|
qt_default_raising = true
|
||||||
filterwarnings =
|
filterwarnings =
|
||||||
|
|
|
@ -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 pytest
|
||||||
import io
|
import io
|
||||||
import peewee
|
|
||||||
from PyQt5 import QtCore
|
from PyQt5 import QtCore
|
||||||
|
|
||||||
import vorta.borg_runner
|
import vorta.borg_runner
|
||||||
import vorta.models
|
import vorta.models
|
||||||
from vorta.application import VortaApp
|
|
||||||
from vorta.views.repo_add import AddRepoWindow
|
from vorta.views.repo_add import AddRepoWindow
|
||||||
from vorta.models import EventLogModel, RepoModel
|
from vorta.models import EventLogModel, RepoModel
|
||||||
|
|
||||||
|
from .fixtures import *
|
||||||
@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
|
|
||||||
|
|
||||||
|
|
||||||
def test_repo_tab(main, qtbot):
|
def test_repo_tab(main, qtbot):
|
||||||
qtbot.mouseClick(main.createStartBtn, QtCore.Qt.LeftButton)
|
qtbot.mouseClick(main.createStartBtn, QtCore.Qt.LeftButton)
|
||||||
|
|
|
@ -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 New Issue