summary refs log tree commit diff
path: root/nixos/tests/paperless.nix
blob: fb83e6f976de6dd7ae42a8fef4d8f49e19ad6b31 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import ./make-test-python.nix ({ lib, ... } : {
  name = "paperless";
  meta = with lib.maintainers; {
    maintainers = [ earvstedt ];
  };

  machine = { pkgs, ... }: {
    environment.systemPackages = with pkgs; [ imagemagick jq ];
    services.paperless = {
      enable = true;
      ocrLanguages = [ "eng" ];
    };
  };

  testScript = ''
    machine.wait_for_unit("paperless-consumer.service")

    # Create test doc
    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("Service gets ready"):
        machine.wait_for_unit("paperless-server.service")
        # Wait until server accepts connections
        machine.wait_until_succeeds("curl -fs localhost:28981")

    with subtest("Test document is consumed"):
        machine.wait_until_succeeds(
            "(($(curl -fs localhost:28981/api/documents/ | jq .count) == 1))"
        )
        assert "2005-10-16" in machine.succeed(
            "curl -fs localhost:28981/api/documents/ | jq '.results | .[0] | .created'"
        )
  '';
})