Skip to content

Commit

Permalink
Merge branch 'master' into issue1869
Browse files Browse the repository at this point in the history
  • Loading branch information
m3nu authored Apr 6, 2024
2 parents 5e22d5b + 58137f0 commit b92fc69
Show file tree
Hide file tree
Showing 6 changed files with 110 additions and 4 deletions.
64 changes: 63 additions & 1 deletion src/vorta/assets/exclusion_presets/dev.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
"patterns":
[
"fm:*/node_modules",
"fm:*/.npm"
"fm:*/.npm",
"fm:*/npm-global"
],
"tags": ["type:dev", "lang:javascript", "os:linux", "os:darwin"],
"author": "Divi"
Expand Down Expand Up @@ -33,5 +34,66 @@
],
"tags": ["type:dev", "lang:rust", "os:linux", "os:darwin"],
"author": "Divi"
},
{
"name": "Visual Studio Code cache and config files",
"slug": "vscode-cache",
"patterns": [
"fm:*/.config/Code",
"fm:*/.vscode/extensions/*"
],
"tags": ["type:editor", "editor:vscode", "os:linux"],
"author": "shivansh02"
},
{
"name": "Android Studio Artefacts",
"slug": "android-studio",
"patterns": [
"fm:*/.android",
"fm:*/.gradle",
"fm:*/Android/Sdk",
"fm:*/.AndroidStudio"
],
"tags": ["type:dev", "editor:android-studio", "os:linux"],
"author": "shivansh02"
},
{
"name": "Jetbrains IDEs cache, config, path and logs",
"slug": "jetbrains",
"patterns": [
"fm:*/.config/JetBrains",
"fm:*/.cache/JetBrains",
"fm:*/.local/share/JetBrains"
],
"tags": ["type:dev", "editor:jetbrains", "os:linux"],
"author": "SAMAD101"
},
{
"name": "AWS artefacts",
"slug": "aws-artefacts",
"patterns": [
"fm:*/.aws"
],
"tags": ["type:dev", "cloud:aws", "os:linux", "os:darwin"],
"author": "SAMAD101"
},
{
"name": "Spotify cache and config files",
"slug": "spotify",
"patterns": [
"fm:*/.cache/spotify",
"fm:*/.config/spotify"
],
"tags": ["type:media", "media:spotify", "os:linux"],
"author": "SAMAD101"
},
{
"name": "Docker artefacts",
"slug": "docker-artefacts",
"patterns": [
"fm:*/.docker"
],
"tags": ["type:dev", "cloud:docker", "os:linux", "os:darwin"],
"author": "SAMAD101"
}
]
2 changes: 1 addition & 1 deletion src/vorta/tray_menu.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def build_menu(self):
cancel_action.triggered.connect(self.app.backup_cancelled_event.emit)
else:
status.setText(self.tr('Next Task: %s') % next_task_time)
profiles = BackupProfileModel.select()
profiles = BackupProfileModel.select().order_by(BackupProfileModel.name)
if profiles.count() > 1:
profile_menu = menu.addMenu(self.tr('Backup Now'))
for profile in profiles:
Expand Down
3 changes: 3 additions & 0 deletions src/vorta/views/diff_result.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,10 +190,13 @@ def change_display_mode(self, selection: int):
"""
if selection == 0:
mode = FileTreeModel.DisplayMode.TREE
self.bCollapseAll.setEnabled(True)
elif selection == 1:
mode = FileTreeModel.DisplayMode.SIMPLIFIED_TREE
self.bCollapseAll.setEnabled(True)
elif selection == 2:
mode = FileTreeModel.DisplayMode.FLAT
self.bCollapseAll.setEnabled(False)
else:
raise Exception("Unknown item in comboBoxDisplayMode with index {}".format(selection))

Expand Down
2 changes: 2 additions & 0 deletions src/vorta/views/extract_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,8 +185,10 @@ def change_display_mode(self, selection: int):
"""
if selection == 0:
mode = FileTreeModel.DisplayMode.TREE
self.bCollapseAll.setEnabled(True)
elif selection == 1:
mode = FileTreeModel.DisplayMode.SIMPLIFIED_TREE
self.bCollapseAll.setEnabled(True)
else:
raise Exception("Unknown item in comboBoxDisplayMode with index {}".format(selection))

Expand Down
19 changes: 19 additions & 0 deletions tests/unit/test_diff.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,17 @@
import vorta.views.archive_tab
from PyQt6.QtCore import QDateTime, QItemSelectionModel, Qt
from PyQt6.QtWidgets import QMenu
from vorta.store.models import ArchiveModel
from vorta.views.diff_result import (
ChangeType,
DiffData,
DiffResultDialog,
DiffTree,
FileType,
parse_diff_json,
parse_diff_lines,
)
from vorta.views.partials.treemodel import FileTreeModel


def setup_diff_result_window(qtbot, mocker, tab, borg_json_output, json_mock_file="diff_archives"):
Expand Down Expand Up @@ -457,3 +460,19 @@ def test_archive_diff_json_parser(line, expected):

assert item.path == PurePath(expected[0]).parts
assert item.data == DiffData(*expected[1:])


@pytest.mark.parametrize(
"selection, expected_mode, expected_bCollapseAllEnabled",
[
(0, FileTreeModel.DisplayMode.TREE, True),
(1, FileTreeModel.DisplayMode.SIMPLIFIED_TREE, True),
(2, FileTreeModel.DisplayMode.FLAT, False),
],
)
def test_change_display_mode(selection: int, expected_mode, expected_bCollapseAllEnabled):
dialog = DiffResultDialog(ArchiveModel(), ArchiveModel(), DiffTree())
dialog.change_display_mode(selection)

assert dialog.model.mode == expected_mode
assert dialog.bCollapseAll.isEnabled() == expected_bCollapseAllEnabled
24 changes: 22 additions & 2 deletions tests/unit/test_extract.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
import pytest
import vorta.borg
from PyQt6.QtCore import QModelIndex, Qt
from vorta.views.extract_dialog import ExtractTree, FileData, FileType, parse_json_lines
from vorta.views.partials.treemodel import FileSystemItem
from vorta.store.models import ArchiveModel
from vorta.views.extract_dialog import (
ExtractDialog,
ExtractTree,
FileData,
FileType,
parse_json_lines,
)
from vorta.views.partials.treemodel import FileSystemItem, FileTreeModel


def prepare_borg(mocker, borg_json_output):
Expand Down Expand Up @@ -177,3 +185,15 @@ def test_selection():

select(model, iab)
assert a.data.checkstate == Qt.CheckState(1)


@pytest.mark.parametrize(
"selection, expected_mode, expected_bCollapseAllEnabled",
[(0, FileTreeModel.DisplayMode.TREE, True), (1, FileTreeModel.DisplayMode.SIMPLIFIED_TREE, True)],
)
def test_change_display_mode(selection: int, expected_mode, expected_bCollapseAllEnabled):
dialog = ExtractDialog(ArchiveModel(), ExtractTree())
dialog.change_display_mode(selection)

assert dialog.model.mode == expected_mode
assert dialog.bCollapseAll.isEnabled() == expected_bCollapseAllEnabled

0 comments on commit b92fc69

Please sign in to comment.