2022-02-09 10:55:26 +00:00
|
|
|
from datetime import date
|
|
|
|
from datetime import datetime as dt
|
|
|
|
from datetime import time
|
|
|
|
|
2018-11-01 06:01:44 +00:00
|
|
|
from PyQt5 import QtCore
|
|
|
|
|
|
|
|
|
2020-03-03 05:19:36 +00:00
|
|
|
def test_schedule_tab(qapp, qtbot):
|
|
|
|
main = qapp.main_window
|
2018-11-05 10:30:59 +00:00
|
|
|
tab = main.scheduleTab
|
2022-02-09 10:55:26 +00:00
|
|
|
|
|
|
|
# Work around
|
|
|
|
# because already 'deleted' scheduletabs are still connected to the signal
|
|
|
|
qapp.scheduler.schedule_changed.disconnect()
|
|
|
|
qapp.scheduler.schedule_changed.connect(lambda *args: tab.draw_next_scheduled_backup())
|
|
|
|
|
|
|
|
# Test
|
2021-10-27 04:37:28 +00:00
|
|
|
qtbot.mouseClick(tab.scheduleOffRadio, QtCore.Qt.LeftButton)
|
2018-11-17 10:12:00 +00:00
|
|
|
assert tab.nextBackupDateTimeLabel.text() == 'None scheduled'
|
2018-11-01 06:01:44 +00:00
|
|
|
|
2021-10-27 04:37:28 +00:00
|
|
|
tab.scheduleIntervalCount.setValue(5)
|
|
|
|
qtbot.mouseClick(tab.scheduleIntervalRadio, QtCore.Qt.LeftButton)
|
|
|
|
assert "None" not in tab.nextBackupDateTimeLabel.text()
|
2018-11-01 06:01:44 +00:00
|
|
|
|
|
|
|
tab.scheduleFixedTime.setTime(QtCore.QTime(23, 59))
|
2021-10-27 04:37:28 +00:00
|
|
|
qtbot.mouseClick(tab.scheduleFixedRadio, QtCore.Qt.LeftButton)
|
2018-11-01 06:01:44 +00:00
|
|
|
next_backup = dt.combine(date.today(), time(23, 59))
|
|
|
|
assert tab.nextBackupDateTimeLabel.text() == next_backup.strftime('%Y-%m-%d %H:%M')
|