Commit graph

38 commits

Author SHA1 Message Date
Alexis Métaireau
acd8717839
Update container installation logic to allow in-place updates
The isolation provider `install()` method is now passed a
`should_upgrade` argument, which is read from the settings and
represents the user decision about updates.

The tests have been updated to reflect these changes.
2025-04-22 12:55:46 +02:00
Alexis Métaireau
61c8f2a6ad
Replace the updater_check setting by updater_check_all
This new setting triggers the same user prompts, but the actual meaning of
it differs, since users will now be accepting to upgrade the container image
rather than just checking for new releases.

Changing the name of the setting will trigger this prompt for all users, effectively
ensuring they want their image to be automatically upgraded.
2025-04-22 12:55:44 +02:00
Alexis Métaireau
d91a09a299
Split updater GUI code from the code checking for release updates
The code making the actual requests and checks now lives in the
`updater.releases` module. The code should be easier to read and to
reason about.

Tests have been updated to reflect this.
2025-04-22 12:55:44 +02:00
Alexis Métaireau
b551a4dec4
Mock the settings rather than monkeypatching external modules 2025-03-31 16:20:28 +02:00
Alexis Métaireau
3d5cacfffb
Warn users if the minimum version of Docker Desktop is not met
This only happens on Windows and macOS.

Fixes #693
2025-01-21 10:21:24 +01:00
jkarasti
cecfe63338
Lint: Fix unused-import (F401) 2024-12-17 17:44:32 +01:00
jkarasti
4da6b92e12
Format: Run ruff format over the source code 2024-12-17 17:44:31 +01:00
Alex Pyrgiotis
0383081394
Factor out container utilities to separate module 2024-12-10 11:31:39 +02:00
Alex Pyrgiotis
25fba42022
Extend the interface of the isolation provider
Add the following two methods in the isolation provider:
1. `.is_available()`: Mainly used for the Container isolation provider,
   it specifies whether the container runtime is up and running. May be
   used in the future by other similar providers.
2. `.should_wait_install()`: Whether the isolation provider takes a
   while to be installed. Should be `True` only for the Container
   isolation provider, for the time being.
2024-12-10 11:29:00 +02:00
Alex Pyrgiotis
309bd12423
Move container-specific method from base class
Move the `is_runtime_available()` method from the base
`IsolationProvider` class, and into the `Dummy` provider class. This
method was originally defined in the base class, in order to be mocked
in our tests for the `Dummy` provider. There's no reason for the `Qubes`
class to have it though, so we can just move it to the `Dummy` provider.
2024-12-09 19:19:21 +02:00
Alexis Métaireau
a95b612e78
Catch installation errors and display them.
Fixes #193
2024-10-17 16:20:56 +02:00
Alexis Métaireau
0c9f426b68
Do not throw on malformed Desktop Entries on Linux.
This just skips the malformed entry when it's found.

Fixes #899
2024-09-10 15:25:45 +02:00
deeplow
d0e1df5546
Add drag and drop support for document selection 2024-06-27 11:51:41 +02:00
Ro
54ab9ce98f
Order list of PDF viewers and return default application first (Linux). 2024-06-12 22:41:04 +02:00
81ad3a65c2
tests: use qt_updater fixture rather than updater
I'm actually ensure how the previous version was working, but since we
are now loading the pytest fixtures automatically, it uncovered a misuse
in the tests.

The `updater` fixture sets `updater.dangerzone.app` to a magic mock
instance, whereas `qt_updater` returns the real QT app, which is what we
want in our tests.
2024-06-05 17:13:31 +02:00
9bad001c04
chore: remove fixture imports in the tests
They ideally should find their way by themselves.

> You don’t need to import the fixture you want to use in a test,
> it automatically gets discovered by pytest. The discovery of fixture
> functions starts at test classes, then test modules, then conftest.py
> files and finally builtin and third party plugins.>
>
> — [pytest docs](https://docs.pytest.org/en/4.6.x/fixture.html#conftest-py-sharing-fixture-functions)
2024-06-05 15:56:09 +02:00
Alexis Métaireau
697b1e0d03
chore: mark some lines as unreachable for mypy 2024-06-05 14:19:31 +02:00
Alexis Métaireau
65a8827daa
chore: minor linting
A few minor changes about when to use `==` and when to use `is`.
Basically, this uses `is` for booleans, and `==` for other values.

With a few other changes about coding style which was enforced by
`ruff`.
2024-06-05 14:19:31 +02:00
Alexis Métaireau
cbbd6afcc1
chore: remove unused code
This commit removes code that's not being used, it can be exceptions
with the `as e` where the exception itself is not used, the same with
`with` statements, and some other parts where there were duplicated
code.
2024-06-05 14:19:31 +02:00
Alexis Métaireau
5aa4863b52
chore(imports): remove useless imports
As detected by [ruff](https://github.com/astral-sh/ruff)

Related to #254, although it doesn't provide the command to lint the
codebase itself.
2024-06-05 14:19:30 +02:00
Alex Pyrgiotis
307ecd495c
tests: Ignore a lint error found by mypy 1.9.0
Ignore a lint error that has started showing up since mypy 1.9.0. The
official docs show that the `.instance()` method does not accept a `cls`
argument [1], so either the stubs or mypy are wrong here.

[1]: https://doc.qt.io/qtforpython-6.5/PySide6/QtCore/QCoreApplication.html#PySide6.QtCore.PySide6.QtCore.QCoreApplication.instance
2024-04-25 16:23:39 +03:00
deeplow
9bb1993e77
Create tests/test_settings.py with extra coverage
Previously settings was implicitly tested on tests/gui/test_updater.py.
However this was concerned with updater-related tests only, which
incidentally covered almost all of settings.py. However, a few tests
were missing. This commit increases the test coverage, but also tests
additional test conditions.

The goal is to help us increase the test coverage of the previous
scenario, which tested for the persistence of user data (settings). This
way we can drop the requirement to test this on linux hosts, which is
slightly harder (more cumbersome) to do.
2024-04-01 18:18:41 +03:00
Garrett Robinson
53115b3ffa
Use more descriptive button labels in update check prompt 2023-10-31 12:52:34 +00:00
Alex Pyrgiotis
ba5adb33c0
Fix a bug in "Change Selection"
Fix a bug in the "Change Selection" action, whereby changing your
selection and picking files from another directory results in:

    "Dangerzone does not support adding documents from multiple
    locations. The newly added documents were ignored."

To fix this, change the output directory when we change selection as
well.
2023-10-13 22:45:11 +03:00
Alex Pyrgiotis
89a36efe89
tests: Fix typo 2023-10-03 11:32:37 +03:00
deeplow
8221a56c7d
Revert "Propagate "update check" prompt to UI checkbox"
This reverts commit 3915a86642502b673aa0e47931823acbe66f1043.
2023-08-23 16:46:44 +01:00
deeplow
1695cc7a6c
Propagate "update check" prompt to UI checkbox
The "check for updates" button wasn't showing up immediately as checked
as soon as the user is prompted for checking updates. This fixes that.

Fixes #513
2023-08-23 16:46:33 +01:00
Alex Pyrgiotis
81811e0aac
Add collapsible dialog for errors
Move the error message from a text browser to a collapsible widget.
2023-08-01 14:29:27 +03:00
deeplow
53ec1cad63
Add update error red dot to hamburger menu 2023-08-01 14:29:11 +03:00
Alex Pyrgiotis
c9eac42855
Improve updater messages
Improve the wording of updater messages for better UX.
2023-08-01 14:29:10 +03:00
Alex Pyrgiotis
bc4bba4fa1
tests: Add full test coverage for updater checks
Fully test the update check logic, by introducing several Qt tests.
Also, improve the `UpdaterThread.get_letest_info()` method, that gets
the latest version and changelog from GitHub, with several checks.
These checks are also tested in our newly added tests.
2023-07-28 12:18:59 +03:00
Alex Pyrgiotis
24ba914cc8
updater: Differentiate between "X" and "Cancel"
We want to differentiate between the user clicking on "Cancel" and
clicking on "X", since in the second case, we want to remind them again
on the next run.
2023-07-28 11:50:44 +03:00
deeplow
8254844724
Pass sample_pdf as fixture instead of via class
Now that sample_doc was renamed to sample_pdf it could cause some
confusion the fact that that the TestBase class had an attribute called
sample_doc which referenced  the sample PDF.

By removing this attribute and passing the fixture instead we are
following a more pytest-native approach of passing arguments explicitly.
2023-07-25 15:00:32 +01:00
deeplow
6216761058
remove number from test_doc2 variable
create a pytest fixture for a .doc file and .pdf file
2023-07-25 15:00:31 +01:00
deeplow
9ca27fd6fe
Add unit test to document change button
Fixes #428
2023-07-25 15:00:29 +01:00
Alex Pyrgiotis
47b337143c
tests: Add Qt test for updates
Add a very rudimentary test for GUI update logic.

Refs #290
2023-07-24 16:54:16 +03:00
Alex Pyrgiotis
47171a2722
tests: Add tests for update logic 2023-07-24 14:22:27 +03:00
Alex Pyrgiotis
f6e945805e
tests: Add a Pytest fixture for Updater
Add a Pytest fixture that returns an UpdaterThread instance which has
its own unique settings directory. Note that the UpdaterThread instance
needs to be slightly nerfed, so that it doesn't rely on Qt functionality
or any isolation providers.
2023-07-24 14:22:27 +03:00