1import ./make-test-python.nix ({ lib, ... }: {
2 name = "paperless-ng";
3 meta.maintainers = with lib.maintainers; [ earvstedt Flakebi ];
4
5 nodes.machine = { pkgs, ... }: {
6 environment.systemPackages = with pkgs; [ imagemagick jq ];
7 services.paperless-ng = {
8 enable = true;
9 passwordFile = builtins.toFile "password" "admin";
10 };
11 };
12
13 testScript = ''
14 machine.wait_for_unit("paperless-ng-consumer.service")
15
16 with subtest("Create test doc"):
17 machine.succeed(
18 "convert -size 400x40 xc:white -font 'DejaVu-Sans' -pointsize 20 -fill black "
19 "-annotate +5+20 'hello world 16-10-2005' /var/lib/paperless/consume/doc.png"
20 )
21
22 with subtest("Web interface gets ready"):
23 machine.wait_for_unit("paperless-ng-web.service")
24 # Wait until server accepts connections
25 machine.wait_until_succeeds("curl -fs localhost:28981")
26
27 with subtest("Create web test doc"):
28 machine.succeed(
29 "convert -size 400x40 xc:white -font 'DejaVu-Sans' -pointsize 20 -fill black "
30 "-annotate +5+20 'hello web 16-10-2005' /tmp/webdoc.png"
31 )
32 machine.wait_until_succeeds("curl -u admin:admin -F document=@/tmp/webdoc.png -fs localhost:28981/api/documents/post_document/")
33
34 with subtest("Documents are consumed"):
35 machine.wait_until_succeeds(
36 "(($(curl -u admin:admin -fs localhost:28981/api/documents/ | jq .count) == 2))"
37 )
38 assert "2005-10-16" in machine.succeed(
39 "curl -u admin:admin -fs localhost:28981/api/documents/ | jq '.results | .[0] | .created'"
40 )
41 assert "2005-10-16" in machine.succeed(
42 "curl -u admin:admin -fs localhost:28981/api/documents/ | jq '.results | .[1] | .created'"
43 )
44 '';
45})