2021-05-13 14:42:22 +00:00
|
|
|
import ./make-test-python.nix ({ lib, ... }: {
|
2022-04-12 15:48:53 +00:00
|
|
|
name = "paperless";
|
2022-06-26 17:12:18 +00:00
|
|
|
meta.maintainers = with lib.maintainers; [ erikarvstedt Flakebi ];
|
2021-05-13 14:42:22 +00:00
|
|
|
|
|
|
|
nodes.machine = { pkgs, ... }: {
|
|
|
|
environment.systemPackages = with pkgs; [ imagemagick jq ];
|
2022-04-12 15:48:53 +00:00
|
|
|
services.paperless = {
|
2021-05-13 14:42:22 +00:00
|
|
|
enable = true;
|
|
|
|
passwordFile = builtins.toFile "password" "admin";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
testScript = ''
|
2022-04-11 15:06:02 +00:00
|
|
|
import json
|
|
|
|
|
2022-04-12 15:48:53 +00:00
|
|
|
machine.wait_for_unit("paperless-consumer.service")
|
2021-05-13 14:42:22 +00:00
|
|
|
|
2022-04-11 15:06:02 +00:00
|
|
|
with subtest("Add a document via the file system"):
|
2021-05-13 14:42:22 +00:00
|
|
|
machine.succeed(
|
|
|
|
"convert -size 400x40 xc:white -font 'DejaVu-Sans' -pointsize 20 -fill black "
|
|
|
|
"-annotate +5+20 'hello world 16-10-2005' /var/lib/paperless/consume/doc.png"
|
|
|
|
)
|
|
|
|
|
|
|
|
with subtest("Web interface gets ready"):
|
2022-04-12 15:48:53 +00:00
|
|
|
machine.wait_for_unit("paperless-web.service")
|
2021-05-13 14:42:22 +00:00
|
|
|
# Wait until server accepts connections
|
|
|
|
machine.wait_until_succeeds("curl -fs localhost:28981")
|
|
|
|
|
2023-01-02 11:19:27 +00:00
|
|
|
# Required for consuming documents via the web interface
|
|
|
|
with subtest("Task-queue gets ready"):
|
|
|
|
machine.wait_for_unit("paperless-task-queue.service")
|
|
|
|
|
2022-04-11 15:06:02 +00:00
|
|
|
with subtest("Add a document via the web interface"):
|
2021-08-23 06:58:16 +00:00
|
|
|
machine.succeed(
|
|
|
|
"convert -size 400x40 xc:white -font 'DejaVu-Sans' -pointsize 20 -fill black "
|
|
|
|
"-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/")
|
|
|
|
|
|
|
|
with subtest("Documents are consumed"):
|
2021-05-13 14:42:22 +00:00
|
|
|
machine.wait_until_succeeds(
|
2021-08-23 06:58:16 +00:00
|
|
|
"(($(curl -u admin:admin -fs localhost:28981/api/documents/ | jq .count) == 2))"
|
2021-05-13 14:42:22 +00:00
|
|
|
)
|
2022-04-11 15:06:02 +00:00
|
|
|
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[1]['created']
|
2022-09-11 22:09:45 +00:00
|
|
|
|
|
|
|
# Detects gunicorn issues, see PR #190888
|
|
|
|
with subtest("Document metadata can be accessed"):
|
|
|
|
metadata = json.loads(machine.succeed("curl -u admin:admin -fs localhost:28981/api/documents/1/metadata/"))
|
|
|
|
assert "original_checksum" in metadata
|
|
|
|
|
|
|
|
metadata = json.loads(machine.succeed("curl -u admin:admin -fs localhost:28981/api/documents/2/metadata/"))
|
|
|
|
assert "original_checksum" in metadata
|
2021-05-13 14:42:22 +00:00
|
|
|
'';
|
|
|
|
})
|