1import ./make-test-python.nix ({ lib, ... } : {
2 name = "paperless";
3 meta = with lib.maintainers; {
4 maintainers = [ earvstedt ];
5 };
6
7 machine = { pkgs, ... }: {
8 environment.systemPackages = with pkgs; [ imagemagick jq ];
9 services.paperless = {
10 enable = true;
11 ocrLanguages = [ "eng" ];
12 };
13 };
14
15 testScript = ''
16 machine.wait_for_unit("paperless-consumer.service")
17
18 # Create test doc
19 machine.succeed(
20 "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"
21 )
22
23 with subtest("Service gets ready"):
24 machine.wait_for_unit("paperless-server.service")
25 # Wait until server accepts connections
26 machine.wait_until_succeeds("curl -fs localhost:28981")
27
28 with subtest("Test document is consumed"):
29 machine.wait_until_succeeds(
30 "(($(curl -fs localhost:28981/api/documents/ | jq .count) == 1))"
31 )
32 assert "2005-10-16" in machine.succeed(
33 "curl -fs localhost:28981/api/documents/ | jq '.results | .[0] | .created'"
34 )
35 '';
36})