Add pytest CI
ci/woodpecker/push/test Pipeline is pending Details
ci/woodpecker/push/lint Pipeline failed Details
ci/woodpecker/push/static_analysis Pipeline failed Details

This commit is contained in:
Marty Oehme 2023-08-29 10:40:40 +02:00
parent c9a6030591
commit b5208b966a
Signed by: Marty
GPG Key ID: EDBF2ED917B2EF6A
5 changed files with 97 additions and 3 deletions

10
.woodpecker/test.yml Normal file
View File

@ -0,0 +1,10 @@
branches: feat/add-ci-pipeline
pipeline:
pytest:
image: ghcr.io/withlogicco/poetry:1.5.1
commands:
- poetry install
- python --version && poetry --version
- echo "------------- running pytest -------------"
- poetry run pytest

View File

@ -173,12 +173,22 @@ Known issues to be fixed:
- [x] if both content and text are empty, do not extract an annotation
- [x] Speed?
- should be fine, on my machine (old i5 laptop) it takes around 90s for ~1000 documents with ~4000 annotations
- [ ] ensure all cmdline options do what they should
- [x] ensure all cmdline options do what they should
- [ ] annotations carry over color object from fitz, should just be Color object or simple tuple with rgb vals
- [ ] docstrings, docstrings!
- [ ] testing testing testing!!
- [ ] refactor into some better abstractions (e.g. Exporter Protocol -> stdout/markdown implementations; Extractor Protocol -> PDF implementation)
features to be implemented:
- [ ] CICD
- [x] static analysis (lint, typecheck etc) on pushes
- [ ] test pipeline on master pushes
- [ ] release pipeline to pypi on tags
- [ ] on_add hook to extract annotations as files are added
- needs upstream help, 'on_add' hook, and pass-through of affected documents
- [ ] add page number if available
- exists in Annotation, just need to place in output
- [ ] show overall amount of extractions at the end
- [ ] custom formatting decided by user
- [ ] improved default exporters
@ -186,7 +196,14 @@ features to be implemented:
- pretty display on stdout (rich?)
- csv/tsv to stdout
- table fmt stdout?
- [ ] arbitrary color -> name settings not dependent on color name existing
- [ ] allow custom colors -> tag name settings not dependent on color name existing (e.g. {"important": (1.0,0.0,0.0)})
- [ ] `--overwrite` mode where existing annotations are not dropped but overwritten on same line of note
- [ ] `--force` mode where we simply do not drop anything
upstream changes:
- [ ] need a hook for adding a document/file
- [ ] need hooks to actually pass through information on the thing they worked on (i.e. their document)
## Issues

59
poetry.lock generated
View File

@ -224,6 +224,17 @@ files = [
{file = "idna-3.4.tar.gz", hash = "sha256:814f528e8dead7d329833b91c5faa87d60bf71824cd12a7530b5526063d02cb4"},
]
[[package]]
name = "iniconfig"
version = "2.0.0"
description = "brain-dead simple config-ini parsing"
optional = false
python-versions = ">=3.7"
files = [
{file = "iniconfig-2.0.0-py3-none-any.whl", hash = "sha256:b6a85871a79d2e3b22d2d1b94ac2824226a63c6b741c88f7ae975f18b6778374"},
{file = "iniconfig-2.0.0.tar.gz", hash = "sha256:2d91e135bf72d31a410b17c16da610a82cb55f6b0477d1a902134b24a455b8b3"},
]
[[package]]
name = "isbnlib"
version = "3.10.14"
@ -456,6 +467,17 @@ html5 = ["html5lib"]
htmlsoup = ["BeautifulSoup4"]
source = ["Cython (>=0.29.35)"]
[[package]]
name = "packaging"
version = "23.1"
description = "Core utilities for Python packages"
optional = false
python-versions = ">=3.7"
files = [
{file = "packaging-23.1-py3-none-any.whl", hash = "sha256:994793af429502c4ea2ebf6bf664629d07c1a9fe974af92966e4b8d2df7edc61"},
{file = "packaging-23.1.tar.gz", hash = "sha256:a392980d2b6cffa644431898be54b0045151319d1e7ec34f0cfed48767dd334f"},
]
[[package]]
name = "papis"
version = "0.13"
@ -504,6 +526,21 @@ files = [
{file = "pbr-5.11.1.tar.gz", hash = "sha256:aefc51675b0b533d56bb5fd1c8c6c0522fe31896679882e1c4c63d5e4a0fccb3"},
]
[[package]]
name = "pluggy"
version = "1.3.0"
description = "plugin and hook calling mechanisms for python"
optional = false
python-versions = ">=3.8"
files = [
{file = "pluggy-1.3.0-py3-none-any.whl", hash = "sha256:d89c696a773f8bd377d18e5ecda92b7a3793cbe66c87060a6fb58c7b6e1061f7"},
{file = "pluggy-1.3.0.tar.gz", hash = "sha256:cf61ae8f126ac6f7c451172cf30e3e43d3ca77615509771b3a984a0730651e12"},
]
[package.extras]
dev = ["pre-commit", "tox"]
testing = ["pytest", "pytest-benchmark"]
[[package]]
name = "prompt-toolkit"
version = "3.0.39"
@ -598,6 +635,26 @@ files = [
[package.extras]
diagrams = ["jinja2", "railroad-diagrams"]
[[package]]
name = "pytest"
version = "7.4.0"
description = "pytest: simple powerful testing with Python"
optional = false
python-versions = ">=3.7"
files = [
{file = "pytest-7.4.0-py3-none-any.whl", hash = "sha256:78bf16451a2eb8c7a2ea98e32dc119fd2aa758f1d5d66dbf0a59d69a3969df32"},
{file = "pytest-7.4.0.tar.gz", hash = "sha256:b4bf8c45bd59934ed84001ad51e11b4ee40d40a1229d2c79f9c592b0a3f6bd8a"},
]
[package.dependencies]
colorama = {version = "*", markers = "sys_platform == \"win32\""}
iniconfig = "*"
packaging = "*"
pluggy = ">=0.12,<2.0"
[package.extras]
testing = ["argcomplete", "attrs (>=19.2.0)", "hypothesis (>=3.56)", "mock", "nose", "pygments (>=2.7.2)", "requests", "setuptools", "xmlschema"]
[[package]]
name = "python-doi"
version = "0.2.0"
@ -923,4 +980,4 @@ files = [
[metadata]
lock-version = "2.0"
python-versions = "^3.11"
content-hash = "2e158747df6100e105c98494d8b5f4b23b7076ae76295ce7a28facf02488ebd5"
content-hash = "05de3adba18945d28a166e5a3575e312779c0c7bbb0e7a991096460d85d160ed"

View File

@ -18,6 +18,10 @@ python-magic = "^0.4.27"
[tool.poetry.plugins."papis.command"]
extract = "papis_extract:main"
[tool.poetry.group.dev.dependencies]
pytest = "^7.4.0"
[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"

6
tests/test_annotation.py Normal file
View File

@ -0,0 +1,6 @@
from papis_extract.annotation_data import Annotation
def test_colorname_exact():
sut = Annotation("testfile", colors={"stroke": (1.0, 0.0, 0.0)})
c_name = sut.colorname
assert c_name == "red"