nixos/paperless: add test for plaintext document

This commit is contained in:
Gregor Godbersen 2023-08-05 22:06:01 +02:00
parent abb697a0cd
commit 540a20546a

View File

@ -30,20 +30,27 @@ import ./make-test-python.nix ({ lib, ... }: {
with subtest("Task-queue gets ready"): with subtest("Task-queue gets ready"):
machine.wait_for_unit("paperless-task-queue.service") machine.wait_for_unit("paperless-task-queue.service")
with subtest("Add a document via the web interface"): with subtest("Add a png document via the web interface"):
machine.succeed( machine.succeed(
"convert -size 400x40 xc:white -font 'DejaVu-Sans' -pointsize 20 -fill black " "convert -size 400x40 xc:white -font 'DejaVu-Sans' -pointsize 20 -fill black "
"-annotate +5+20 'hello web 16-10-2005' /tmp/webdoc.png" "-annotate +5+20 'hello web 16-10-2005' /tmp/webdoc.png"
) )
machine.wait_until_succeeds("curl -u admin:admin -F document=@/tmp/webdoc.png -fs localhost:28981/api/documents/post_document/") machine.wait_until_succeeds("curl -u admin:admin -F document=@/tmp/webdoc.png -fs localhost:28981/api/documents/post_document/")
with subtest("Add a txt document via the web interface"):
machine.succeed(
"echo 'hello web 16-10-2005' > /tmp/webdoc.txt"
)
machine.wait_until_succeeds("curl -u admin:admin -F document=@/tmp/webdoc.txt -fs localhost:28981/api/documents/post_document/")
with subtest("Documents are consumed"): with subtest("Documents are consumed"):
machine.wait_until_succeeds( machine.wait_until_succeeds(
"(($(curl -u admin:admin -fs localhost:28981/api/documents/ | jq .count) == 2))" "(($(curl -u admin:admin -fs localhost:28981/api/documents/ | jq .count) == 3))"
) )
docs = json.loads(machine.succeed("curl -u admin:admin -fs localhost:28981/api/documents/"))['results'] docs = json.loads(machine.succeed("curl -u admin:admin -fs localhost:28981/api/documents/"))['results']
assert "2005-10-16" in docs[0]['created'] assert "2005-10-16" in docs[0]['created']
assert "2005-10-16" in docs[1]['created'] assert "2005-10-16" in docs[1]['created']
assert "2005-10-16" in docs[2]['created']
# Detects gunicorn issues, see PR #190888 # Detects gunicorn issues, see PR #190888
with subtest("Document metadata can be accessed"): with subtest("Document metadata can be accessed"):
@ -52,5 +59,8 @@ import ./make-test-python.nix ({ lib, ... }: {
metadata = json.loads(machine.succeed("curl -u admin:admin -fs localhost:28981/api/documents/2/metadata/")) metadata = json.loads(machine.succeed("curl -u admin:admin -fs localhost:28981/api/documents/2/metadata/"))
assert "original_checksum" in metadata assert "original_checksum" in metadata
metadata = json.loads(machine.succeed("curl -u admin:admin -fs localhost:28981/api/documents/3/metadata/"))
assert "original_checksum" in metadata
''; '';
}) })