Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] update test matrix to the current standards #35

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 34 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
sudo: required
dist: trusty
dist: xenial

language: python
cache: pip
Expand All @@ -19,9 +19,37 @@ script:
# cache: pip
matrix:
include:
- env: TOXENV=py34-dj20-wt20
python: 3.4
- env: TOXENV=py35-dj20-wt20
python: 3.5
- env: TOXENV=py36-dj20-wt20
- env: TOXENV=py36-dj22-wt27
python: 3.6
- env: TOXENV=py37-dj22-wt27
python: 3.7
- env: TOXENV=py38-dj22-wt27
python: 3.8
- env: TOXENV=py36-dj22-wt211
python: 3.6
- env: TOXENV=py37-dj22-wt211
python: 3.7
- env: TOXENV=py38-dj22-wt211
python: 3.8
- env: TOXENV=py36-dj31-wt211
python: 3.6
- env: TOXENV=py37-dj31-wt211
python: 3.7
- env: TOXENV=py38-dj31-wt211
python: 3.8
- env: TOXENV=py36-dj22-wt212
python: 3.6
- env: TOXENV=py37-dj22-wt212
python: 3.7
- env: TOXENV=py38-dj22-wt212
python: 3.8
- env: TOXENV=py39-dj22-wt212
python: 3.9
- env: TOXENV=py36-dj31-wt212
python: 3.6
- env: TOXENV=py37-dj31-wt212
python: 3.7
- env: TOXENV=py38-dj31-wt212
python: 3.8
- env: TOXENV=py39-dj31-wt212
python: 3.9
13 changes: 9 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
env:
virtualenv --python=`which python3` env
ENV = env
PYTHON_VERSION = 3.9
PYTHON = $(ENV)/bin/python$(PYTHON_VERSION)

$(ENV):
$(shell which python$(PYTHON_VERSION)) -m venv $(ENV)
$(PYTHON) -m pip install --upgrade pip setuptools wheel

tessdata:
mkdir tessdata
cd tessdata && curl -LJO https://github.com/tesseract-ocr/tessdata/raw/master/eng.traineddata

test: tessdata env
env/bin/pip install -e ".[test]"
coverage run env/bin/pytest
$(PYTHON) -m pip install -e '.[test]'
$(ENV)/bin/coverage run $(ENV)/bin/pytest
13 changes: 1 addition & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,15 @@ the live search finds it:
The assumption is that this search should not only be available in Wagtail's admin interface,
but also in a public-facing search view, for which we provide a code example.


## Requirements

- Wagtail 2 (see [tox.ini](./tox.ini))
- The [Textract dependencies][8]


## Maturity

We have been using this package in production since August 2018 on https://nuffic.nl.


## Installation

- Install the [Textract dependencies][8]
Expand All @@ -57,7 +54,6 @@ textract 1.6.1 has requirement beautifulsoup4==4.5.3, but you'll have beautifuls

We haven't seen this leading to problems, but it's something to keep in mind.


### Tesseract

In order to make `textract` use [Tesseract][4], which happens if regular
Expand All @@ -67,7 +63,6 @@ base its word matching on.
Create a `tessdata` directory in your project directory, and download the
[languages][5] you want.


## Transcribing

Transcription is done automatically after Document save,
Expand All @@ -79,7 +74,6 @@ To transcribe all existing Documents, run the management command::

This may take a long time, obviously.


## Usage in custom view

Here is a code example for a search view (outside Wagtail's admin interface)
Expand All @@ -89,7 +83,7 @@ that shows both Page and Document results.
from itertools import chain

from wagtail.core.models import Page
from wagtail.documents.models import get_document_model
from wagtail.documents import get_document_model


def search(request):
Expand Down Expand Up @@ -123,7 +117,6 @@ because you can't do `pageurl result` on a Document:
{% endif %}
```


## What if you already use a custom Document model?

In order to use wagtail_textract, your `CustomizedDocument` model should do
Expand All @@ -149,19 +142,16 @@ class CustomizedDocument(TranscriptionMixin, ...):
Note that the first class to subclass should be `TranscriptionMixin`,
so its `save()` takes precedence over that of the other parent classes.


## Tests

To run tests, checkout this repository and:

make test


### Coverage

A coverage report will be generated in `./coverage_html_report/`.


## Contributors

- Karl Hobley
Expand All @@ -174,7 +164,6 @@ A coverage report will be generated in `./coverage_html_report/`.
- Dan Braghis
- Dan Swain


[1]: https://wagtail.io/
[2]: https://github.com/deanmalmgren/textract
[3]: https://github.com/wagtail/wagtail/issues/542
Expand Down
9 changes: 4 additions & 5 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@


install_requires = [
"wagtail>=2,<2.6",
"wagtail>=2.7,<2.13",
"textract",
]

Expand Down Expand Up @@ -47,14 +47,13 @@
'Operating System :: OS Independent',
'Programming Language :: Python',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Framework :: Django',
'Framework :: Django :: 2.0',
'Framework :: Django :: 2.1',
'Framework :: Django :: 2.2',
'Framework :: Django :: 3.1',
'Framework :: Wagtail',
'Framework :: Wagtail :: 2',
'Topic :: Internet :: WWW/HTTP :: Site Management',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from django.core.management.base import BaseCommand

from wagtail.documents.models import get_document_model
from wagtail.documents import get_document_model

from wagtail_textract.handlers import async_transcribe_document

Expand Down
2 changes: 1 addition & 1 deletion src/wagtail_textract/settings.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from wagtail.tests.settings import *

WAGTAILDOCS_DOCUMENT_MODEL = 'wagtail_textract.document'
INSTALLED_APPS = INSTALLED_APPS + ('wagtail_textract',)
INSTALLED_APPS = INSTALLED_APPS + ['wagtail_textract']
2 changes: 1 addition & 1 deletion src/wagtail_textract/tests/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

MEDIA_ROOT = '.'
WAGTAILDOCS_DOCUMENT_MODEL = 'wagtail_textract.document'
INSTALLED_APPS = INSTALLED_APPS + ('wagtail_textract',)
INSTALLED_APPS = INSTALLED_APPS + ['wagtail_textract']
2 changes: 1 addition & 1 deletion src/wagtail_textract/tests/test_document_class.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from wagtail.documents.models import get_document_model
from wagtail.documents import get_document_model


def test_document_class():
Expand Down
2 changes: 1 addition & 1 deletion src/wagtail_textract/tests/test_management_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

from django.core.files import File
from django.core.management import call_command
from wagtail.documents.models import get_document_model
from wagtail.documents import get_document_model

Document = get_document_model()

Expand Down
25 changes: 10 additions & 15 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,36 +1,31 @@
[tox]
envlist =
py{34,35,36}-dj{20}-wt{20,21,22}
py{35,36}-dj{21}-wt{23}
py{35,36,37}-dj{21}-wt{24}
py{35,36,37}-dj{22}-wt{25}
py{36,37,38}-dj{22}-wt{27}
py{36,37,38}-dj{22,31}-wt{211}
py{36,37,38,39}-dj{22,31}-wt{212}

[testenv]
basepython =
py34: python3.4
py35: python3.5
py36: python3.6
py37: python3.7
py38: python3.8
py39: python3.9

deps =
pytest
pytest-django
coverage
codecov
dj20: Django>=2.0,<2.1
dj21: Django>=2.1,<2.2
dj22: Django>=2.2,<2.3
wt20: wagtail>=2.0,<2.1
wt21: wagtail>=2.1,<2.2
wt22: wagtail>=2.2,<2.3
wt23: wagtail>=2.3,<2.4
wt24: wagtail>=2.4,<2.5
wt25: wagtail>=2.5,<2.6
dj31: Django>=3.1,<3.2
wt27: wagtail>=2.7,<2.8
wt211: wagtail>=2.11,<2.12
wt212: wagtail>=2.12,<2.13

whitelist_externals =
make

install_command = pip install -e ".[test]" --upgrade {opts} {packages}
; install_command = pip install -e '.[test]' --upgrade {opts} {packages}

# include {envsitepackagesdir}/wagtail_textract b/c "import file mismatch":
# http://tox.readthedocs.io/en/latest/example/pytest.html#known-issues-and-limitations
Expand Down
2 changes: 1 addition & 1 deletion travis-textract-requirements/debian
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ antiword
unrtf

# parse image files
tesseract-ocr=3.03\*
tesseract-ocr=4.1.1\*
libjpeg-dev

# parse pdfs
Expand Down
2 changes: 1 addition & 1 deletion travis-textract-requirements/debian.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ base=$(pwd)

# Install all of the dependencies required in the examples.
# http://docs.travis-ci.com/user/installing-dependencies/#Installing-Ubuntu-packages
add-apt-repository ppa:mc3man/trusty-media -y
# add-apt-repository ppa:mc3man/trusty-media -y
apt-get update -qq
sed 's/\(.*\)\#.*/\1/' < $base/travis-textract-requirements/debian | xargs apt-get install -y --fix-missing