<commit_before>import ./make-test.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->waitForUnit("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');

    $machine->waitForUnit("paperless-server.service");
    # Wait until server accepts connections
    $machine->waitUntilSucceeds("curl -s localhost:28981");
    # Wait until document is consumed
    $machine->waitUntilSucceeds('(($(curl -s localhost:28981/api/documents/ | jq .count) == 1))');
    $machine->succeed("curl -s localhost:28981/api/documents/ | jq '.results | .[0] | .created'")
      =~ /2005-10-16/ or die;
  '';
})<commit_msg>nixosTests.paperless: Port tests to python<commit_after>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 -s localhost:28981")

    with subtest("Test document is consumed"):
        machine.wait_until_succeeds(
            "(($(curl -s localhost:28981/api/documents/ | jq .count) == 1))"
        )
        assert "2005-10-16" in machine.succeed(
            "curl -s localhost:28981/api/documents/ | jq '.results | .[0] | .created'"
        )
  '';
})
{'fraction_non_alphanumeric': 0.15821947994711327, 'fraction_numerical': 0.0379021595416483, 'mean_word_length': 2.777038269550749, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1328110', 'n_tokens_mistral': 851, 'n_tokens_neox': 755, 'n_words': 157}