-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathconftest.py
109 lines (91 loc) · 2.64 KB
/
conftest.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
import os
import shutil
import uuid
import pytest
from pytest_factoryboy import register
from .factories import (
CollectionDirectoryFactory,
DocumentCollectionFactory,
DocumentFactory,
DocumentPortalFactory,
PageFactory,
UserFactory,
)
register(UserFactory)
register(DocumentFactory)
register(DocumentCollectionFactory)
register(PageFactory)
register(CollectionDirectoryFactory)
register(DocumentPortalFactory)
os.environ.setdefault("DJANGO_ALLOW_ASYNC_UNSAFE", "true")
@pytest.fixture
def dummy_user():
yield UserFactory(username="dummy")
@pytest.fixture()
def page(browser):
context = browser.new_context(locale="en")
page = context.new_page()
yield page
page.close()
@pytest.fixture()
def long_timeout_page(browser):
context = browser.new_context(locale="en")
context.set_default_timeout(10000)
page = context.new_page()
yield page
page.close()
@pytest.fixture()
def processed_document(tmp_path, dummy_user, settings):
path = "{}/ef/39/5b/ef395b666014488aa551e431e653a1d9".format(
settings.FILINGCABINET_MEDIA_PUBLIC_PREFIX
)
shutil.copytree(
settings.TEST_DATA_ROOT / "example-doc",
tmp_path / path,
)
settings.MEDIA_ROOT = tmp_path
doc = DocumentFactory(
title="Test Document",
description="Description of Test Document",
uid=uuid.UUID("ef395b66-6014-488a-a551-e431e653a1d9"),
pdf_file=f"{path}/example.pdf",
file_size=260082,
user=dummy_user,
pending=False,
num_pages=4,
language="de",
public=True,
)
for i in range(1, 5):
PageFactory(
document=doc,
number=i,
width=2481,
height=3508,
image=f"{path}/page-p{i}-original.png",
image_large=f"{path}/page-p{i}-large.png",
image_normal=f"{path}/page-p{i}-normal.png",
image_small=f"{path}/page-p{i}-small.png",
)
yield doc
@pytest.fixture()
def document_collection(processed_document, document_collection_factory):
collection = document_collection_factory(
title="Test Collection",
slug="test-collection",
description="Test Collection Description",
public=True,
)
collection.documents.add(processed_document)
yield collection
@pytest.fixture()
def document_portal(processed_document, document_portal_factory):
portal = document_portal_factory(
title="Test Portal",
slug="test-portal",
description="Test Portal Description",
public=True,
)
processed_document.portal = portal
processed_document.save()
yield portal