-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
171 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[pytest] | ||
DJANGO_SETTINGS_MODULE=test_project.settings | ||
python_files = tests.py test_*.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,59 @@ | ||
[wheel] | ||
universal = 1 | ||
|
||
[aliases] | ||
test=pytest | ||
|
||
[flake8] | ||
extend-ignore = E203,E501,C901 | ||
max-line-length = 88 | ||
extend-ignore = E203,E501,C901,W503,B950 | ||
select = C,E,F,W,B,B950 | ||
exclude = .git,__pycache__,docs/source/conf.py,old,build,dist,migrations | ||
max-complexity = 10 | ||
|
||
[isort] | ||
profile = black | ||
src_paths = froide | ||
src_paths = filingcabinet | ||
default_section = THIRDPARTY | ||
known_first_party = filingcabinet | ||
known_django = django | ||
sections = FUTURE,STDLIB,DJANGO,THIRDPARTY,FIRSTPARTY,LOCALFOLDER | ||
|
||
[coverage:run] | ||
branch = true | ||
source = filingcabinet | ||
omit = | ||
*/migrations/* | ||
*/wsgi.py | ||
plugins = | ||
django_coverage_plugin | ||
|
||
[coverage:report] | ||
show_missing = True | ||
skip_covered = True | ||
exclude_lines = | ||
pragma: no cover | ||
|
||
[mypy] | ||
python_version = 3.10 | ||
plugins = | ||
mypy_django_plugin.main, | ||
mypy_drf_plugin.main | ||
|
||
check_untyped_defs = True | ||
disallow_any_generics = True | ||
disallow_untyped_calls = True | ||
disallow_untyped_decorators = True | ||
ignore_errors = False | ||
ignore_missing_imports = True | ||
implicit_reexport = False | ||
strict_optional = True | ||
strict_equality = True | ||
no_implicit_optional = True | ||
warn_unused_ignores = True | ||
warn_redundant_casts = True | ||
warn_unused_configs = True | ||
warn_unreachable = True | ||
warn_no_return = True | ||
|
||
[mypy.plugins.django-stubs] | ||
django_settings_module = "test_project.settings" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import os | ||
|
||
import pytest | ||
from pytest_factoryboy import register | ||
|
||
from .factories import ( | ||
DocumentCollectionFactory, | ||
DocumentFactory, | ||
PageFactory, | ||
UserFactory, | ||
) | ||
|
||
register(UserFactory) | ||
register(DocumentFactory) | ||
register(DocumentCollectionFactory) | ||
register(PageFactory) | ||
|
||
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 processed_document(): | ||
path = "docs/ef/39/5b/ef395b666014488aa551e431e653a1d9" | ||
doc = DocumentFactory( | ||
uid="ef395b66-6014-488a-a551-e431e653a1d9", | ||
pdf_file=f"{path}/example.pdf", | ||
file_size=260082, | ||
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
from django.conf import settings | ||
from django.template.defaultfilters import slugify | ||
|
||
import factory | ||
|
||
from filingcabinet import get_document_model, get_documentcollection_model | ||
from filingcabinet.models import Page | ||
|
||
Document = get_document_model() | ||
DocumentCollection = get_documentcollection_model() | ||
|
||
|
||
class UserFactory(factory.django.DjangoModelFactory): | ||
class Meta: | ||
model = settings.AUTH_USER_MODEL | ||
|
||
|
||
class DocumentFactory(factory.django.DjangoModelFactory): | ||
class Meta: | ||
model = Document | ||
|
||
title = factory.Sequence(lambda n: "Document {}".format(n)) | ||
slug = factory.LazyAttribute(lambda o: slugify(o.title)) | ||
|
||
|
||
class PageFactory(factory.django.DjangoModelFactory): | ||
class Meta: | ||
model = Page | ||
|
||
document = factory.SubFactory(DocumentFactory) | ||
number = factory.Sequence(lambda n: n) | ||
|
||
|
||
class DocumentCollectionFactory(factory.django.DjangoModelFactory): | ||
class Meta: | ||
model = DocumentCollection | ||
|
||
title = factory.Sequence(lambda n: "DocumentCollection {}".format(n)) | ||
slug = factory.LazyAttribute(lambda o: slugify(o.title)) | ||
user = factory.SubFactory(UserFactory) |