python3Packages.orjson: Disable failing tests on 32 bit
[NixPkgs.git] / nixos / tests / shiori.nix
blobd0f68b903f8c33474459281b53a3ce925ffb7e82
1 import ./make-test-python.nix ({ pkgs, lib, ...}:
4   name = "shiori";
5   meta.maintainers = with lib.maintainers; [ minijackson ];
7   nodes.machine =
8     { ... }:
9     { services.shiori.enable = true; };
11   testScript = let
12     authJSON = pkgs.writeText "auth.json" (builtins.toJSON {
13       username = "shiori";
14       password = "gopher";
15       owner = true;
16     });
18   insertBookmark = {
19     url = "http://example.org";
20     title = "Example Bookmark";
21   };
23   insertBookmarkJSON = pkgs.writeText "insertBookmark.json" (builtins.toJSON insertBookmark);
24   in ''
25     import json
27     machine.wait_for_unit("shiori.service")
28     machine.wait_for_open_port(8080)
29     machine.succeed("curl --fail http://localhost:8080/")
30     machine.succeed("curl --fail --location http://localhost:8080/ | grep -i shiori")
32     with subtest("login"):
33         auth_json = machine.succeed(
34             "curl --fail --location http://localhost:8080/api/login "
35             "-X POST -H 'Content-Type:application/json' -d @${authJSON}"
36         )
37         auth_ret = json.loads(auth_json)
38         session_id = auth_ret["session"]
40     with subtest("bookmarks"):
41         with subtest("first use no bookmarks"):
42             bookmarks_json = machine.succeed(
43                 (
44                     "curl --fail --location http://localhost:8080/api/bookmarks "
45                     "-H 'X-Session-Id:{}'"
46                 ).format(session_id)
47             )
49             if json.loads(bookmarks_json)["bookmarks"] != []:
50                 raise Exception("Shiori have a bookmark on first use")
52         with subtest("insert bookmark"):
53             machine.succeed(
54                 (
55                     "curl --fail --location http://localhost:8080/api/bookmarks "
56                     "-X POST -H 'X-Session-Id:{}' "
57                     "-H 'Content-Type:application/json' -d @${insertBookmarkJSON}"
58                 ).format(session_id)
59             )
61         with subtest("get inserted bookmark"):
62             bookmarks_json = machine.succeed(
63                 (
64                     "curl --fail --location http://localhost:8080/api/bookmarks "
65                     "-H 'X-Session-Id:{}'"
66                 ).format(session_id)
67             )
69             bookmarks = json.loads(bookmarks_json)["bookmarks"]
70             if len(bookmarks) != 1:
71                 raise Exception("Shiori didn't save the bookmark")
73             bookmark = bookmarks[0]
74             if (
75                 bookmark["url"] != "${insertBookmark.url}"
76                 or bookmark["title"] != "${insertBookmark.title}"
77             ):
78                 raise Exception("Inserted bookmark doesn't have same URL or title")
79   '';