dangerzone/tests/isolation_provider/base.py
deeplow 61e7a3c107
Fix isolation provider tests
Conversions methods had changed and that was part of the reason why
the tests were failing. Furthermore, due to the `provider.proc`, which
stores the associated qrexec / container process, "server" exceptions
raise a IterruptedConversion error (now ConverterProcException), which
then requires interpretation of the process exit code to obtain the
"real" exception.
2024-02-06 19:42:41 +00:00

32 lines
1 KiB
Python

import os
import pytest
from colorama import Style
from pytest_mock import MockerFixture
from dangerzone.conversion import errors
from dangerzone.document import Document
from dangerzone.isolation_provider import base
from dangerzone.isolation_provider.qubes import running_on_qubes
from .. import pdf_11k_pages, sanitized_text, uncommon_text
@pytest.mark.skipif(
os.environ.get("DUMMY_CONVERSION", False),
reason="dummy conversions not supported",
)
@pytest.mark.skipif(not running_on_qubes(), reason="Not on a Qubes system")
class IsolationProviderTest:
def test_max_pages_server_enforcement(
self,
pdf_11k_pages: str,
provider: base.IsolationProvider,
mocker: MockerFixture,
tmpdir: str,
) -> None:
provider.progress_callback = mocker.MagicMock()
doc = Document(pdf_11k_pages)
with pytest.raises(errors.ConverterProcException):
provider.doc_to_pixels(doc, tmpdir)
assert provider.get_proc_exception() == errors.MaxPagesException