1
0
Fork 0
mirror of https://github.com/borgbase/vorta synced 2025-01-03 05:36:19 +00:00
vorta/tests/test_misc.py
yfprojects 618a1fe278
Add tooltips to settings. (#1521)
This adds tooltips to the settings as well as a 'info' button that shows the tooltip when hovering over it.

* Add tooltips to settings.

* src/vorta/store/models.py (SettingsModel): Add `tooltip` column.

* src/vorta/store/migrations.py (run_migrations): Create `tooltip` column.

* src/vorta/store/connection.py (init_db): Populate `tooltip` column. Increase `SCHEMA_VERSION`.

* src/vorta/views/misc_tab.py (MiscTab.populate): Set tooltip of checkbox widgets.

* src/vorta/store/settings.py : Add tooltips and update label of `override_mount_permissions`

* Add *help* button to settings.

* src/vorta/assets/icons/help-about.svg: Add info icon.

* src/vorta/views/partials/tooltip_button.py: Implement `ToolTipButton`.

* src/vorta/views/misc_tab.py: Add `ToolTipButton` for each setting with a tooltip.
	Add `set_icons` and connect it to palette change.

* tests/test_misc.py (test_autostart): Update test.

---------

Co-authored-by: real-yfprojects <real-yfprojects@users.noreply.github.com>
2023-02-25 10:10:43 +00:00

44 lines
1.6 KiB
Python

import os
import sys
from pathlib import Path
import pytest
from PyQt5 import QtCore
from PyQt5.QtWidgets import QCheckBox, QFormLayout
def test_autostart(qapp, qtbot):
'''Check if file exists only on Linux, otherwise just check it doesn't crash'''
main = qapp.main_window
main.tabWidget.setCurrentIndex(4)
tab = main.miscTab
def click_autostart():
for x in range(0, tab.checkboxLayout.count()):
item = tab.checkboxLayout.itemAt(x, QFormLayout.ItemRole.FieldRole)
if not item:
continue
checkbox = item.itemAt(0).widget()
checkbox.__class__ = QCheckBox
if checkbox.text().startswith("Automatically"):
# Have to use pos to click checkbox correctly
# https://stackoverflow.com/questions/19418125/pysides-qtest-not-checking-box/24070484#24070484
qtbot.mouseClick(checkbox, QtCore.Qt.LeftButton, pos=QtCore.QPoint(2, int(checkbox.height() / 2)))
break
click_autostart()
if sys.platform == 'linux':
autostart_path = (
Path(os.environ.get("XDG_CONFIG_HOME", os.path.expanduser("~") + '/.config') + "/autostart")
/ "vorta.desktop"
)
qtbot.waitUntil(lambda: autostart_path.exists(), **pytest._wait_defaults)
with open(autostart_path) as desktop_file:
desktop_file_text = desktop_file.read()
assert desktop_file_text.startswith("[Desktop Entry]")
click_autostart()
if sys.platform == 'linux':
assert not os.path.exists(autostart_path)