mirror of
https://github.com/freedomofpress/dangerzone.git
synced 2025-04-28 18:02:38 +02:00
Move Qubes-specific tests also to containers
Now that Qubes and Containers essentially share the same code, we can have both run the same tests.
This commit is contained in:
parent
61e7a3c107
commit
943bab2def
3 changed files with 45 additions and 31 deletions
|
@ -9,7 +9,14 @@ 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
|
||||
from .. import (
|
||||
pdf_11k_pages,
|
||||
sample_bad_height,
|
||||
sample_bad_width,
|
||||
sample_doc,
|
||||
sanitized_text,
|
||||
uncommon_text,
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.skipif(
|
||||
|
@ -30,3 +37,32 @@ class IsolationProviderTest:
|
|||
with pytest.raises(errors.ConverterProcException):
|
||||
provider.doc_to_pixels(doc, tmpdir)
|
||||
assert provider.get_proc_exception() == errors.MaxPagesException
|
||||
|
||||
def test_max_pages_client_enforcement(
|
||||
self,
|
||||
sample_doc: str,
|
||||
provider: base.IsolationProvider,
|
||||
mocker: MockerFixture,
|
||||
tmpdir: str,
|
||||
) -> None:
|
||||
provider.progress_callback = mocker.MagicMock()
|
||||
mocker.patch(
|
||||
"dangerzone.conversion.errors.MAX_PAGES", 1
|
||||
) # sample_doc has 4 pages > 1
|
||||
doc = Document(sample_doc)
|
||||
with pytest.raises(errors.MaxPagesException):
|
||||
provider.doc_to_pixels(doc, tmpdir)
|
||||
|
||||
def test_max_dimensions(
|
||||
self,
|
||||
sample_bad_width: str,
|
||||
sample_bad_height: str,
|
||||
provider: base.IsolationProvider,
|
||||
mocker: MockerFixture,
|
||||
tmpdir: str,
|
||||
) -> None:
|
||||
provider.progress_callback = mocker.MagicMock()
|
||||
with pytest.raises(errors.MaxPageWidthException):
|
||||
provider.doc_to_pixels(Document(sample_bad_width), tmpdir)
|
||||
with pytest.raises(errors.MaxPageHeightException):
|
||||
provider.doc_to_pixels(Document(sample_bad_height), tmpdir)
|
||||
|
|
|
@ -9,7 +9,14 @@ from dangerzone.document import Document
|
|||
from dangerzone.isolation_provider.container import Container
|
||||
|
||||
# XXX Fixtures used in abstract Test class need to be imported regardless
|
||||
from .. import pdf_11k_pages, sanitized_text, uncommon_text
|
||||
from .. import (
|
||||
pdf_11k_pages,
|
||||
sample_bad_height,
|
||||
sample_bad_width,
|
||||
sample_doc,
|
||||
sanitized_text,
|
||||
uncommon_text,
|
||||
)
|
||||
from .base import IsolationProviderTest
|
||||
|
||||
|
||||
|
|
|
@ -30,35 +30,6 @@ def provider() -> Qubes:
|
|||
|
||||
@pytest.mark.skipif(not running_on_qubes(), reason="Not on a Qubes system")
|
||||
class TestQubes(IsolationProviderTest):
|
||||
def test_max_pages_client_enforcement(
|
||||
self,
|
||||
sample_doc: str,
|
||||
provider: Qubes,
|
||||
mocker: MockerFixture,
|
||||
tmpdir: str,
|
||||
) -> None:
|
||||
provider.progress_callback = mocker.MagicMock()
|
||||
mocker.patch(
|
||||
"dangerzone.conversion.errors.MAX_PAGES", 1
|
||||
) # sample_doc has 4 pages > 1
|
||||
doc = Document(sample_doc)
|
||||
with pytest.raises(errors.MaxPagesException):
|
||||
provider.doc_to_pixels(doc, tmpdir)
|
||||
|
||||
def test_max_dimensions(
|
||||
self,
|
||||
sample_bad_width: str,
|
||||
sample_bad_height: str,
|
||||
provider: Qubes,
|
||||
mocker: MockerFixture,
|
||||
tmpdir: str,
|
||||
) -> None:
|
||||
provider.progress_callback = mocker.MagicMock()
|
||||
with pytest.raises(errors.MaxPageWidthException):
|
||||
provider.doc_to_pixels(Document(sample_bad_width), tmpdir)
|
||||
with pytest.raises(errors.MaxPageHeightException):
|
||||
provider.doc_to_pixels(Document(sample_bad_height), tmpdir)
|
||||
|
||||
def test_out_of_ram(
|
||||
self,
|
||||
provider: Qubes,
|
||||
|
|
Loading…
Reference in a new issue